private void MainWindow_FormClosing(object Sender, FormClosingEventArgs EventArgs) { if (!bAllowClose && Settings.bKeepInTray) { Hide(); EventArgs.Cancel = true; } else { for (int Idx = 0; Idx < TabControl.GetTabCount(); Idx++) { WorkspaceControl Workspace = (WorkspaceControl)TabControl.GetTabData(Idx); if (!Workspace.CanClose()) { EventArgs.Cancel = true; return; } } ActivationListener.OnActivate -= OnActivationListenerAsyncCallback; ActivationListener.Stop(); UpdateMonitor.OnUpdateAvailable -= OnUpdateAvailable; UpdateMonitor.Close(); // prevent race condition StopScheduleTimer(); Rectangle SaveBounds = (WindowState == FormWindowState.Normal)? Bounds : RestoreBounds; Settings.WindowRectangle = SaveBounds; Settings.bWindowVisible = Visible; Settings.Save(); } }
bool TabControl_OnTabClosing(object TabData) { WorkspaceControl Workspace = (WorkspaceControl)TabData; return(Workspace.CanClose()); }