/// <summary> /// This method is called when the tvControls's BeforeSelect event has been fired. /// </summary> /// <param name="sender">The <see cref="object"/> that fired the event.</param> /// <param name="e">The <see cref="TreeViewCancelEventArgs"/> of the event.</param> private void tvControls_BeforeSelect(object sender, TreeViewCancelEventArgs e) { if (splitContainer1.Panel2.Controls.Count == 0) { return; } if (activeControl == null) { return; } IFinanceControl fc = e.Node.Tag as IFinanceControl; if (fc == null) { return; } if (fc == activeControl) { return; } UnloadFinanceControlEventArgs uea = new UnloadFinanceControlEventArgs(); activeControl.UnloadControl(uea); e.Cancel = uea.Cancel; }
/// <summary> /// This method is called when the Form1's FormClosing event has been fired. /// </summary> /// <param name="sender">The <see cref="object"/> that fired the event.</param> /// <param name="e">The <see cref="FormClosingEventArgs"/> of the event.</param> private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Settings.WindowState = (int)WindowState; if (WindowState != FormWindowState.Minimized) { Settings.Width = Width; if (Settings.Width < MinimumSize.Width) { Settings.Width = MinimumSize.Width; } Settings.Height = Height; if (Settings.Height < MinimumSize.Height) { Settings.Height = MinimumSize.Height; } Settings.Top = Top; if (Settings.Top < 0) { Settings.Top = 0; } Settings.Left = Left; if (Settings.Left < 0) { Settings.Left = 0; } } Settings.SplitterDistance = splitContainer1.SplitterDistance; Settings.SplitterCollapsed = splitContainer1.Panel1Collapsed; if (splitContainer1.Panel2.Controls.Count == 0) { Settings.SelectedControlName = null; return; } if (activeControl == null) { Settings.SelectedControlName = null; return; } UnloadFinanceControlEventArgs uea = new UnloadFinanceControlEventArgs(); activeControl.UnloadControl(uea); e.Cancel = uea.Cancel; Settings.SelectedControlName = activeControl.GetType().FullName; Settings.Save(); }