protected override void Dispose(bool disposing) { if (disposing) { if (this.singleInstanceManager != null) { PaintDotNet.SystemLayer.SingleInstanceManager singleInstanceManager = this.singleInstanceManager; this.SingleInstanceManager = null; singleInstanceManager.Dispose(); singleInstanceManager = null; } if (this.components != null) { this.components.Dispose(); this.components = null; } } try { base.Dispose(disposing); } catch (RankException) { } }
protected override void OnClosing(CancelEventArgs e) { if ((!e.Cancel && (this.appWorkspace != null)) && !this.appWorkspace.IsDisposed) { CloseAllWorkspacesAction performMe = new CloseAllWorkspacesAction(); this.appWorkspace.PerformAction(performMe); e.Cancel = performMe.Cancelled; } if (!e.Cancel) { if (base.Visible) { this.SaveSettings(); } if (this.floatingToolForms != null) { FloatingToolForm[] floatingToolForms = this.floatingToolForms; for (int i = 0; i < floatingToolForms.Length; i++) { floatingToolForms[i].Hide(); } } base.Hide(); if (this.queuedInstanceMessages != null) { this.queuedInstanceMessages.Clear(); } PaintDotNet.SystemLayer.SingleInstanceManager singleInstanceManager = this.singleInstanceManager; this.SingleInstanceManager = null; if (singleInstanceManager != null) { singleInstanceManager.Dispose(); singleInstanceManager = null; } } base.OnClosing(e); }
private void StartPart2() { // Set up locale / resource details string locale = Settings.CurrentUser.GetString(SettingNames.LanguageName, null); if (locale == null) { locale = Settings.SystemWide.GetString(SettingNames.LanguageName, null); } if (locale != null) { try { CultureInfo ci = new CultureInfo(locale, true); Thread.CurrentThread.CurrentUICulture = ci; } catch (Exception) { // Don't want bad culture name to crash us } } // Check system requirements if (!OS.CheckOSRequirement()) { string message = PdnResources.GetString("Error.OSRequirement"); Utility.ErrorBox(null, message); return; } // Parse command-line arguments if (this.args.Length == 1 && this.args[0] == Updates.UpdatesOptionsDialog.CommandLineParameter) { Updates.UpdatesOptionsDialog.ShowUpdateOptionsDialog(null, false); } else { SingleInstanceManager singleInstanceManager = new SingleInstanceManager(InvariantStrings.SingleInstanceMonikerName); // If this is not the first instance of PDN.exe, then forward the command-line // parameters over to the first instance. if (!singleInstanceManager.IsFirstInstance) { singleInstanceManager.FocusFirstInstance(); foreach (string arg in this.args) { singleInstanceManager.SendInstanceMessage(arg, 30); } singleInstanceManager.Dispose(); singleInstanceManager = null; return; } // Create main window this.mainForm = new MainForm(this.args); this.mainForm.SingleInstanceManager = singleInstanceManager; singleInstanceManager = null; // mainForm owns it now // 3 2 1 go Application.Run(this.mainForm); try { this.mainForm.Dispose(); } catch (Exception) { } this.mainForm = null; } }
private void StartPart2() { // Set up locale / resource details string locale = Settings.CurrentUser.GetString(PdnSettings.LanguageName, null); if (locale == null) { locale = Settings.SystemWide.GetString(PdnSettings.LanguageName, null); } if (locale != null) { CultureInfo ci = new CultureInfo(locale, true); Thread.CurrentThread.CurrentUICulture = ci; } // Check system requirements if (!OS.CheckOSRequirement()) { string message = PdnResources.GetString("Error.OSRequirement"); Utility.ErrorBox(null, message); return; } // Parse command-line arguments if (this.args.Length == 1 && this.args[0] == Updates.UpdatesOptionsDialog.CommandLineParameter) { Updates.UpdatesOptionsDialog.ShowUpdateOptionsDialog(null, false); } else { SingleInstanceManager singleInstanceManager = new SingleInstanceManager("PaintDotNet"); // If this is not the first instance of PDN.exe, then forward the command-line // parameters over to the first instance. if (!singleInstanceManager.IsFirstInstance) { singleInstanceManager.FocusFirstInstance(); foreach (string arg in this.args) { singleInstanceManager.SendInstanceMessage(arg, 30); } singleInstanceManager.Dispose(); singleInstanceManager = null; return; } // Create main window this.mainForm = new MainForm(this.args); // if the display is set to a portrait mode (tall), then orient the PDN window the same way if (this.mainForm.ScreenAspect < 1.0) { int width = mainForm.Width; int height = mainForm.Height; this.mainForm.Width = height; this.mainForm.Height = width; } // if the window opens and part of it is off screen, correct this Screen screen = Screen.FromControl(this.mainForm); Rectangle intersect = Rectangle.Intersect(screen.Bounds, mainForm.Bounds); if (intersect.Width == 0 || intersect.Height == 0) { mainForm.Location = new Point(screen.Bounds.Left + 16, screen.Bounds.Top + 16); } // if the window is not big enough, correct this if (this.mainForm.Width < 200) { this.mainForm.Width = 200; // this value was chosen arbitrarily } if (this.mainForm.Height < 200) { this.mainForm.Height = 200; // this value was chosen arbitrarily } this.mainForm.SingleInstanceManager = singleInstanceManager; singleInstanceManager = null; // mainForm owns it now // 3 2 1 go Application.Run(this.mainForm); this.mainForm.Dispose(); this.mainForm = null; } }