/// <summary> /// Shutdown / cleanup /// </summary> public void Exit() { Log.Info().WriteLine("Exit: " + EnvironmentInfo.EnvironmentToString(false)); ImageOutput.RemoveTmpFiles(); // make the icon invisible otherwise it stays even after exit!! if (notifyIcon != null) { notifyIcon.Visible = false; notifyIcon.Dispose(); notifyIcon = null; } }
/// <summary> /// Shutdown / cleanup /// </summary> public void Exit() { LOG.Info("Exit: " + EnvironmentInfo.EnvironmentToString(false)); // Close all open forms (except this), use a separate List to make sure we don't get a "InvalidOperationException: Collection was modified" List <Form> formsToClose = new List <Form>(); foreach (Form form in Application.OpenForms) { if (form.Handle != this.Handle && !form.GetType().Equals(typeof(Greenshot.ImageEditorForm))) { formsToClose.Add(form); } } foreach (Form form in formsToClose) { try { LOG.InfoFormat("Closing form: {0}", form.Name); this.Invoke((MethodInvoker) delegate { form.Close(); }); } catch (Exception e) { LOG.Error("Error closing form!", e); } } // Now the sound isn't needed anymore try { SoundHelper.Deinitialize(); } catch (Exception e) { LOG.Error("Error deinitializing sound!", e); } // Inform all registed plugins try { PluginHelper.instance.Shutdown(); } catch (Exception e) { LOG.Error("Error shutting down plugins!", e); } // Gracefull shutdown try { Application.DoEvents(); Application.Exit(); } catch (Exception e) { LOG.Error("Error closing application!", e); } ImageOutput.RemoveTmpFiles(); // Store any open configuration changes try { IniConfig.Save(); } catch (Exception e) { LOG.Error("Error storing configuration!", e); } // Remove the application mutex FreeMutex(); }