This commit is made due to BUG-1775. Although it might not fix it, it ensures that every window has an icon and only than when it loaded. Also added improved error handling.

This commit is contained in:
Robin 2015-04-17 11:06:57 +02:00
parent eed5b66116
commit 7938ab5dad
29 changed files with 32 additions and 34 deletions

View file

@ -146,9 +146,6 @@ namespace Greenshot {
// Only use double-buffering when we are NOT in a Terminal Server session // Only use double-buffering when we are NOT in a Terminal Server session
DoubleBuffered = !isTerminalServerSession; DoubleBuffered = !isTerminalServerSession;
// Not needed for a Tool Window, but still for the task manager it's important
Icon = GreenshotResources.getGreenshotIcon();
// Use the self drawn image, first we create the background to be the backcolor (as we animate from this) // Use the self drawn image, first we create the background to be the backcolor (as we animate from this)
gBitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96); gBitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
pictureBox1.Image = gBitmap; pictureBox1.Image = gBitmap;

View file

@ -31,7 +31,6 @@ namespace Greenshot.Forms {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
Icon = GreenshotResources.getGreenshotIcon();
WindowDetails.ToForeground(Handle); WindowDetails.ToForeground(Handle);
} }

View file

@ -61,7 +61,7 @@ namespace Greenshot.Forms {
this.Cursor = System.Windows.Forms.Cursors.Cross; this.Cursor = System.Windows.Forms.Cursors.Cross;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "CaptureForm"; this.Name = "CaptureForm";
this.ShowIcon = false; this.ShowIcon = true;
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.TopMost = true; this.TopMost = true;
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown);

View file

@ -123,6 +123,7 @@ namespace Greenshot.Forms {
LOG.Debug("Closing captureform"); LOG.Debug("Closing captureform");
WindowDetails.UnregisterIgnoreHandle(Handle); WindowDetails.UnregisterIgnoreHandle(Handle);
} }
/// <summary> /// <summary>
/// This creates the capture form /// This creates the capture form
/// </summary> /// </summary>
@ -130,7 +131,7 @@ namespace Greenshot.Forms {
/// <param name="windows"></param> /// <param name="windows"></param>
public CaptureForm(ICapture capture, List<WindowDetails> windows) { public CaptureForm(ICapture capture, List<WindowDetails> windows) {
if (_currentForm != null) { if (_currentForm != null) {
LOG.Debug("Found currentForm, Closing already opened CaptureForm"); LOG.Warn("Found currentForm, Closing already opened CaptureForm");
_currentForm.Close(); _currentForm.Close();
_currentForm = null; _currentForm = null;
Application.DoEvents(); Application.DoEvents();

View file

@ -31,7 +31,6 @@ namespace Greenshot.Forms {
public DropShadowSettingsForm(DropShadowEffect effect) { public DropShadowSettingsForm(DropShadowEffect effect) {
this.effect = effect; this.effect = effect;
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotResources.getGreenshotIcon();
ShowSettings(); ShowSettings();
} }

View file

@ -162,8 +162,6 @@ namespace Greenshot {
} }
private void updateUI() { private void updateUI() {
Icon = GreenshotResources.getGreenshotIcon();
// Disable access to the settings, for feature #3521446 // Disable access to the settings, for feature #3521446
preferencesToolStripMenuItem.Visible = !coreConfiguration.DisableSettings; preferencesToolStripMenuItem.Visible = !coreConfiguration.DisableSettings;
toolStripSeparator12.Visible = !coreConfiguration.DisableSettings; toolStripSeparator12.Visible = !coreConfiguration.DisableSettings;

View file

@ -359,7 +359,6 @@ namespace Greenshot {
throw; throw;
} }
notifyIcon.Icon = GreenshotResources.getGreenshotIcon(); notifyIcon.Icon = GreenshotResources.getGreenshotIcon();
Icon = GreenshotResources.getGreenshotIcon();
// Disable access to the settings, for feature #3521446 // Disable access to the settings, for feature #3521446
contextmenu_settings.Visible = !_conf.DisableSettings; contextmenu_settings.Visible = !_conf.DisableSettings;

View file

@ -33,7 +33,6 @@ namespace Greenshot.Forms {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
Icon = GreenshotResources.getGreenshotIcon();
checkbox_dontaskagain.Checked = false; checkbox_dontaskagain.Checked = false;
} }

View file

@ -37,7 +37,6 @@ namespace Greenshot.Forms {
public ResizeSettingsForm(ResizeEffect effect) { public ResizeSettingsForm(ResizeEffect effect) {
this.effect = effect; this.effect = effect;
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotResources.getGreenshotIcon();
value_pixel = Language.GetString("editor_resize_pixel"); value_pixel = Language.GetString("editor_resize_pixel");
value_percent = Language.GetString("editor_resize_percent"); value_percent = Language.GetString("editor_resize_percent");
combobox_width.Items.Add(value_pixel); combobox_width.Items.Add(value_pixel);

View file

@ -57,7 +57,6 @@ namespace Greenshot {
protected override void OnLoad(EventArgs e) { protected override void OnLoad(EventArgs e) {
base.OnLoad(e); base.OnLoad(e);
Icon = GreenshotResources.getGreenshotIcon();
// Fix for Vista/XP differences // Fix for Vista/XP differences
if (Environment.OSVersion.Version.Major >= 6) { if (Environment.OSVersion.Version.Major >= 6) {

View file

@ -30,7 +30,6 @@ namespace Greenshot.Forms {
public TornEdgeSettingsForm(TornEdgeEffect effect) { public TornEdgeSettingsForm(TornEdgeEffect effect) {
this.effect = effect; this.effect = effect;
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotResources.getGreenshotIcon();
ShowSettings(); ShowSettings();
} }

View file

@ -967,7 +967,13 @@ namespace Greenshot.Helpers {
//} //}
using (CaptureForm captureForm = new CaptureForm(_capture, _windows)) { using (CaptureForm captureForm = new CaptureForm(_capture, _windows)) {
DialogResult result = captureForm.ShowDialog(); // Make sure the form is hidden after showing, even if an exception occurs, so all errors will be shown
DialogResult result = DialogResult.Cancel;
try {
result = captureForm.ShowDialog(MainForm.Instance);
} finally {
captureForm.Hide();
}
if (result == DialogResult.OK) { if (result == DialogResult.OK) {
_selectedCaptureWindow = captureForm.SelectedCaptureWindow; _selectedCaptureWindow = captureForm.SelectedCaptureWindow;
_captureRect = captureForm.CaptureRectangle; _captureRect = captureForm.CaptureRectangle;

View file

@ -39,8 +39,6 @@ namespace GreenshotBoxPlugin {
InitializeComponent(); InitializeComponent();
AcceptButton = buttonOK; AcceptButton = buttonOK;
CancelButton = buttonCancel; CancelButton = buttonCancel;
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
} }
} }
} }

View file

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotDropboxPlugin.Forms; using GreenshotDropboxPlugin.Forms;
@ -39,7 +40,6 @@ namespace GreenshotDropboxPlugin {
InitializeComponent(); InitializeComponent();
AcceptButton = buttonOK; AcceptButton = buttonOK;
CancelButton = buttonCancel; CancelButton = buttonCancel;
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
} }
} }

View file

@ -37,7 +37,6 @@ namespace ExternalCommand {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
AcceptButton = buttonOk; AcceptButton = buttonOk;
CancelButton = buttonCancel; CancelButton = buttonCancel;
UpdateView(); UpdateView();

View file

@ -38,7 +38,6 @@ namespace ExternalCommand {
public SettingsFormDetail(string commando) { public SettingsFormDetail(string commando) {
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
AcceptButton = buttonOk; AcceptButton = buttonOk;
CancelButton = buttonCancel; CancelButton = buttonCancel;
this.commando = commando; this.commando = commando;

View file

@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using GreenshotPlugin.Controls; using GreenshotPlugin.Controls;

View file

@ -37,7 +37,6 @@ namespace GreenshotFlickrPlugin {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
Icon = GreenshotResources.getGreenshotIcon();
CancelButton = buttonCancel; CancelButton = buttonCancel;
AcceptButton = buttonOK; AcceptButton = buttonOK;
} }

View file

@ -18,13 +18,15 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin { namespace GreenshotImgurPlugin {
/// <summary> /// <summary>
/// This class is needed for design-time resolving of the language files /// This class is needed for design-time resolving of the language files
/// </summary> /// </summary>
public class ImgurForm : GreenshotPlugin.Controls.GreenshotForm { public class ImgurForm : GreenshotForm {
public ImgurForm() : base() { public ImgurForm() : base() {
} }
} }

View file

@ -53,7 +53,6 @@ namespace GreenshotImgurPlugin {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
AcceptButton = finishedButton; AcceptButton = finishedButton;
CancelButton = finishedButton; CancelButton = finishedButton;
// Init sorting // Init sorting

View file

@ -35,7 +35,6 @@ namespace GreenshotImgurPlugin {
InitializeComponent(); InitializeComponent();
CancelButton = buttonCancel; CancelButton = buttonCancel;
AcceptButton = buttonOK; AcceptButton = buttonOK;
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
ImgurUtils.LoadHistory(); ImgurUtils.LoadHistory();

View file

@ -34,7 +34,6 @@ namespace GreenshotJiraPlugin {
InitializeComponent(); InitializeComponent();
AcceptButton = buttonOK; AcceptButton = buttonOK;
CancelButton = buttonCancel; CancelButton = buttonCancel;
Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
} }
} }
} }

View file

@ -19,11 +19,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using GreenshotPlugin.Controls;
namespace GreenshotOCR { namespace GreenshotOCR {
/// <summary> /// <summary>
/// This class is needed for design-time resolving of the language files /// This class is needed for design-time resolving of the language files
/// </summary> /// </summary>
public class OCRForm : GreenshotPlugin.Controls.GreenshotForm { public class OCRForm : GreenshotForm {
public OCRForm() : base() { public OCRForm() : base() {
} }
} }

View file

@ -37,7 +37,6 @@ namespace GreenshotOCR {
InitializeComponent(); InitializeComponent();
AcceptButton = buttonOK; AcceptButton = buttonOK;
CancelButton = buttonCancel; CancelButton = buttonCancel;
this.Icon = GreenshotResources.getGreenshotIcon();
comboBox_languages.Items.Clear(); comboBox_languages.Items.Clear();
int index=0; int index=0;

View file

@ -35,7 +35,6 @@ namespace GreenshotPhotobucketPlugin {
InitializeComponent(); InitializeComponent();
AcceptButton = buttonOK; AcceptButton = buttonOK;
CancelButton = buttonCancel; CancelButton = buttonCancel;
Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
} }
} }
} }

View file

@ -38,7 +38,6 @@ namespace GreenshotPicasaPlugin {
InitializeComponent(); InitializeComponent();
CancelButton = buttonCancel; CancelButton = buttonCancel;
AcceptButton = buttonOK; AcceptButton = buttonOK;
Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
} }
} }

View file

@ -18,17 +18,20 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using GreenshotPlugin.UnmanagedHelpers; using GreenshotPlugin.UnmanagedHelpers;
using Greenshot.IniFile; using Greenshot.IniFile;
using log4net;
namespace GreenshotPlugin.Controls { namespace GreenshotPlugin.Controls {
/// <summary> /// <summary>
/// Extend this Form to have the possibility for animations on your form /// Extend this Form to have the possibility for animations on your form
/// </summary> /// </summary>
public class AnimatingForm : GreenshotForm { public class AnimatingForm : GreenshotForm {
private static readonly ILog LOG = LogManager.GetLogger(typeof(AnimatingForm));
private const int DEFAULT_VREFRESH = 60; private const int DEFAULT_VREFRESH = 60;
private int vRefresh = 0; private int vRefresh = 0;
private Timer timer = null; private Timer timer = null;
@ -110,7 +113,11 @@ namespace GreenshotPlugin.Controls {
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void timer_Tick(object sender, EventArgs e) { void timer_Tick(object sender, EventArgs e) {
try {
Animate(); Animate();
} catch (Exception ex) {
LOG.Warn("An exception occured while animating:", ex);
}
} }
/// <summary> /// <summary>

View file

@ -131,6 +131,9 @@ namespace GreenshotPlugin.Controls {
} }
protected override void OnLoad(EventArgs e) { protected override void OnLoad(EventArgs e) {
// Every GreenshotForm should have it's default icon
// And it might not ne needed for a Tool Window, but still for the task manager / switcher it's important
Icon = GreenshotResources.getGreenshotIcon();
if (!DesignMode) { if (!DesignMode) {
if (!applyLanguageManually) { if (!applyLanguageManually) {
ApplyLanguage(); ApplyLanguage();
@ -413,7 +416,7 @@ namespace GreenshotPlugin.Controls {
if (section != null) { if (section != null) {
IniValue iniValue = null; IniValue iniValue = null;
if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) { if (!section.Values.TryGetValue(configBindable.PropertyName, out iniValue)) {
LOG.WarnFormat("Wrong property '{0}' configured for field '{1}'",configBindable.PropertyName,field.Name); LOG.DebugFormat("Wrong property '{0}' configured for field '{1}'",configBindable.PropertyName,field.Name);
continue; continue;
} }

View file

@ -41,7 +41,6 @@ namespace GreenshotPlugin.Controls {
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
Icon = GreenshotResources.getGreenshotIcon();
checkBox_reduceColors.Checked = Settings.ReduceColors; checkBox_reduceColors.Checked = Settings.ReduceColors;
trackBarJpegQuality.Enabled = OutputFormat.jpg.Equals(outputSettings.Format); trackBarJpegQuality.Enabled = OutputFormat.jpg.Equals(outputSettings.Format);