mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Some small fixes
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@757 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
8ed65f8fc4
commit
0a589956d7
5 changed files with 51 additions and 20 deletions
1
Greenshot/Forms/MainForm.Designer.cs
generated
1
Greenshot/Forms/MainForm.Designer.cs
generated
|
@ -219,6 +219,7 @@ namespace Greenshot {
|
||||||
this.Text = "Greenshot";
|
this.Text = "Greenshot";
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
|
||||||
|
this.Activated += new System.EventHandler(this.MainFormActivated);
|
||||||
this.contextMenu.ResumeLayout(false);
|
this.contextMenu.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Greenshot {
|
||||||
// Setup log4j, currently the file is called log4net.xml
|
// Setup log4j, currently the file is called log4net.xml
|
||||||
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
|
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
|
||||||
if (File.Exists(log4netFilename)) {
|
if (File.Exists(log4netFilename)) {
|
||||||
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4netFilename));
|
log4net.Config.XmlConfigurator.Configure(new FileInfo(log4netFilename));
|
||||||
} else {
|
} else {
|
||||||
MessageBox.Show("Can't find file " + LOG4NET_FILE);
|
MessageBox.Show("Can't find file " + LOG4NET_FILE);
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ namespace Greenshot {
|
||||||
dataTransport = new DataTransport(CommandEnum.FirstLaunch, null);
|
dataTransport = new DataTransport(CommandEnum.FirstLaunch, null);
|
||||||
}
|
}
|
||||||
MainForm mainForm = new MainForm(dataTransport);
|
MainForm mainForm = new MainForm(dataTransport);
|
||||||
Application.Run();
|
Application.Run(mainForm);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
LOG.Error("Exception in startup.", ex);
|
LOG.Error("Exception in startup.", ex);
|
||||||
Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
|
Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
|
||||||
|
@ -336,9 +336,14 @@ namespace Greenshot {
|
||||||
|
|
||||||
#region mainform events
|
#region mainform events
|
||||||
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
|
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
|
||||||
LOG.Info("Closing with reason: " + e.CloseReason);
|
instance = null;
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainFormActivated(object sender, EventArgs e) {
|
||||||
|
Hide();
|
||||||
|
ShowInTaskbar = false;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -534,37 +539,59 @@ namespace Greenshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exit/cleanup
|
/// Shutdown / cleanup
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void exit() {
|
public void exit() {
|
||||||
|
LOG.Info("Exit: " + EnvironmentInfo.EnvironmentToString(false));
|
||||||
try {
|
try {
|
||||||
// Make sure hotkeys are disabled
|
// Make sure hotkeys are disabled
|
||||||
HotkeyHelper.UnregisterHotkeys((int)this.Handle);
|
HotkeyHelper.UnregisterHotkeys(Handle.ToInt32());
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error("Error unregistering hotkeys!", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Now the sound isn't needed anymore
|
// Now the sound isn't needed anymore
|
||||||
SoundHelper.Deinitialize();
|
SoundHelper.Deinitialize();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error("Error deinitializing sound!", e);
|
||||||
|
}
|
||||||
|
|
||||||
// Making sure all Windows are closed, gracefull shutdown
|
try {
|
||||||
Application.Exit();
|
|
||||||
|
|
||||||
// Inform all registed plugins
|
// Inform all registed plugins
|
||||||
PluginHelper.instance.Shutdown();
|
PluginHelper.instance.Shutdown();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error("Error shutting down plugins!", e);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Making sure all Windows are closed, gracefull shutdown
|
||||||
|
Application.Exit();
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error("Error closing application!", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
// Store any open configuration changes
|
// Store any open configuration changes
|
||||||
conf.Store();
|
conf.Store();
|
||||||
} finally {
|
} catch (Exception e) {
|
||||||
// Remove the application mutex
|
LOG.Error("Error storing configuration!", e);
|
||||||
if (applicationMutex != null) {
|
}
|
||||||
try {
|
// Remove the application mutex
|
||||||
applicationMutex.ReleaseMutex();
|
if (applicationMutex != null) {
|
||||||
} catch (Exception ex) {
|
try {
|
||||||
LOG.Error("Error releasing Mutex!", ex);
|
applicationMutex.ReleaseMutex();
|
||||||
}
|
applicationMutex = null;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOG.Error("Error releasing Mutex!", ex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// make the icon invisible otherwise it stays even after exit!!
|
// make the icon invisible otherwise it stays even after exit!!
|
||||||
|
if (notifyIcon != null) {
|
||||||
notifyIcon.Visible = false;
|
notifyIcon.Visible = false;
|
||||||
|
notifyIcon.Dispose();
|
||||||
|
notifyIcon = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -74,6 +74,8 @@ namespace Greenshot.Helpers {
|
||||||
foreach(int hotkey in keyHandlers.Keys) {
|
foreach(int hotkey in keyHandlers.Keys) {
|
||||||
UnregisterHotKey(hnd, hotkey);
|
UnregisterHotKey(hnd, hotkey);
|
||||||
}
|
}
|
||||||
|
// Remove all key handlers
|
||||||
|
keyHandlers.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void HandleMessages(ref Message m) {
|
public static void HandleMessages(ref Message m) {
|
||||||
|
|
|
@ -89,6 +89,7 @@ namespace Greenshot.Helpers {
|
||||||
foreach(IGreenshotPlugin plugin in plugins.Values) {
|
foreach(IGreenshotPlugin plugin in plugins.Values) {
|
||||||
plugin.Shutdown();
|
plugin.Shutdown();
|
||||||
}
|
}
|
||||||
|
plugins.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add plugins to the Listview
|
// Add plugins to the Listview
|
||||||
|
|
|
@ -570,7 +570,7 @@ namespace Greenshot.Forms {
|
||||||
if (!saved) {
|
if (!saved) {
|
||||||
MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
|
MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
|
||||||
// Dissallow "CANCEL" if the application needs to shutdown
|
// Dissallow "CANCEL" if the application needs to shutdown
|
||||||
if (e.CloseReason == CloseReason.ApplicationExitCall || e.CloseReason == CloseReason.WindowsShutDown) {
|
if (e.CloseReason == CloseReason.ApplicationExitCall || e.CloseReason == CloseReason.WindowsShutDown || e.CloseReason == CloseReason.TaskManagerClosing) {
|
||||||
buttons = MessageBoxButtons.YesNo;
|
buttons = MessageBoxButtons.YesNo;
|
||||||
}
|
}
|
||||||
DialogResult result = MessageBox.Show(lang.GetString(LangKey.editor_close_on_save), lang.GetString(LangKey.editor_close_on_save_title), buttons, MessageBoxIcon.Question);
|
DialogResult result = MessageBox.Show(lang.GetString(LangKey.editor_close_on_save), lang.GetString(LangKey.editor_close_on_save_title), buttons, MessageBoxIcon.Question);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue