public Shell() { InitializeComponent(); regions = new Dictionary <Type, UIElement> { { GetType(), this }, { typeof(Window), this }, { StatusBar.GetType(), StatusBar }, { Menu.GetType(), Menu }, { DockManager.GetType(), DockManager }, { Tabs.GetType(), Tabs }, { ResizingPanel.GetType(), ResizingPanel }, { ButtonBar.GetType(), ButtonBar }, { TaskBarIcon.GetType(), TaskBarIcon }, { StockWatch.GetType(), StockWatch }, }; DockManager.Loaded += (o, e) => { if (File.Exists(settings_file)) { DockManager.RestoreLayout(settings_file); } }; Closing += (o, e) => DockManager.SaveLayout(settings_file); Closing += (o, e) => TaskBarIcon.Dispose(); Loaded += (o, e) => { TaskBarIcon.Icon = UIIcon.Application.AsIcon(); }; }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { TaskBarIcon.Dispose(); if (_clipboardService != null) { _clipboardService.Dispose(); } }
private void HelixTroubleshootingMainWindow_Closed(object sender, EventArgs e) { TaskBarIcon.Dispose(); Process[] processes = Process.GetProcessesByName("HelixTroubleshooting"); foreach (Process p in processes) { p.Kill(); } }
private void AmazonPriceChecker_Closing(object sender, System.ComponentModel.CancelEventArgs e) { //Since this method fires whenever the application begin to close, we must specifically check //if the user is meaning to exit the application so the Balloon Tip doesn't re-fire on exit try { if (CommonFunctions.UserSettings.MinimizeOnClose && !IsExiting) { CommonFunctions.Log.Debug($"Hiding application on close"); this.Visibility = Visibility.Hidden; e.Cancel = true; TaskBarIcon.ShowBalloonTip(this.Title, "App is still running in the background", BalloonIcon.Info); } else { if (DoSettingsDiffer()) { StringBuilder message = new StringBuilder(); message.AppendLine("Your settings have not been saved.\n"); message.AppendLine("Would you like to save your settings before closing?"); ConfirmationWindow shouldSaveWindow = new ConfirmationWindow("Save Settings?", message.ToString()); if (shouldSaveWindow.ShowDialog() == true) { bool shouldSave = shouldSaveWindow.Confirmed; if (shouldSave) { SaveSettings(); } //clean up tray icon TaskBarIcon.Dispose(); IsExiting = true; } else { e.Cancel = true; } } else { //clean up tray icon TaskBarIcon.Dispose(); IsExiting = true; } } } catch (Exception ex) { CommonFunctions.Log.Error("Error closing application", ex); } }