mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -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.TopMost = true;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
|
||||
this.Activated += new System.EventHandler(this.MainFormActivated);
|
||||
this.contextMenu.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Greenshot {
|
|||
// Setup log4j, currently the file is called log4net.xml
|
||||
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
|
||||
if (File.Exists(log4netFilename)) {
|
||||
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(log4netFilename));
|
||||
log4net.Config.XmlConfigurator.Configure(new FileInfo(log4netFilename));
|
||||
} else {
|
||||
MessageBox.Show("Can't find file " + LOG4NET_FILE);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ namespace Greenshot {
|
|||
dataTransport = new DataTransport(CommandEnum.FirstLaunch, null);
|
||||
}
|
||||
MainForm mainForm = new MainForm(dataTransport);
|
||||
Application.Run();
|
||||
Application.Run(mainForm);
|
||||
} catch(Exception ex) {
|
||||
LOG.Error("Exception in startup.", ex);
|
||||
Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
|
||||
|
@ -336,9 +336,14 @@ namespace Greenshot {
|
|||
|
||||
#region mainform events
|
||||
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Info("Closing with reason: " + e.CloseReason);
|
||||
instance = null;
|
||||
exit();
|
||||
}
|
||||
|
||||
void MainFormActivated(object sender, EventArgs e) {
|
||||
Hide();
|
||||
ShowInTaskbar = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -534,37 +539,59 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exit/cleanup
|
||||
/// Shutdown / cleanup
|
||||
/// </summary>
|
||||
public void exit() {
|
||||
LOG.Info("Exit: " + EnvironmentInfo.EnvironmentToString(false));
|
||||
try {
|
||||
// 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
|
||||
SoundHelper.Deinitialize();
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Error deinitializing sound!", e);
|
||||
}
|
||||
|
||||
// Making sure all Windows are closed, gracefull shutdown
|
||||
Application.Exit();
|
||||
|
||||
try {
|
||||
// Inform all registed plugins
|
||||
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
|
||||
conf.Store();
|
||||
} finally {
|
||||
// Remove the application mutex
|
||||
if (applicationMutex != null) {
|
||||
try {
|
||||
applicationMutex.ReleaseMutex();
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Error releasing Mutex!", ex);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.Error("Error storing configuration!", e);
|
||||
}
|
||||
// Remove the application mutex
|
||||
if (applicationMutex != null) {
|
||||
try {
|
||||
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.Dispose();
|
||||
notifyIcon = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -74,6 +74,8 @@ namespace Greenshot.Helpers {
|
|||
foreach(int hotkey in keyHandlers.Keys) {
|
||||
UnregisterHotKey(hnd, hotkey);
|
||||
}
|
||||
// Remove all key handlers
|
||||
keyHandlers.Clear();
|
||||
}
|
||||
|
||||
public static void HandleMessages(ref Message m) {
|
||||
|
|
|
@ -89,6 +89,7 @@ namespace Greenshot.Helpers {
|
|||
foreach(IGreenshotPlugin plugin in plugins.Values) {
|
||||
plugin.Shutdown();
|
||||
}
|
||||
plugins.Clear();
|
||||
}
|
||||
|
||||
// Add plugins to the Listview
|
||||
|
|
|
@ -570,7 +570,7 @@ namespace Greenshot.Forms {
|
|||
if (!saved) {
|
||||
MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
|
||||
// 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;
|
||||
}
|
||||
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