/// <summary>The OnMaximizeClick.</summary> /// <param name="sender">The sender.</param> /// <param name="e">The event args.</param> protected virtual void OnMaximizeClick(object sender, EventArgs e) { if (ParentForm.WindowState == FormWindowState.Normal) { if (_maximizeButton.BoxType == ControlBoxButton.ControlBoxType.Default) { _maximizeButton.Text = @"2"; } ParentForm.WindowState = FormWindowState.Maximized; MaximizeClick?.Invoke(new ControlBoxEventArgs(ParentForm)); } else { if (_maximizeButton.BoxType == ControlBoxButton.ControlBoxType.Default) { _maximizeButton.Text = @"1"; } ParentForm.WindowState = FormWindowState.Normal; RestoredFormWindow?.Invoke(new ControlBoxEventArgs(ParentForm)); } }
/// <summary>Restores the form window.</summary> /// <param name="form">The form.</param> public void RestoreFormWindow(Form form) { if (form == null) { form = ParentForm; } if (form.WindowState == FormWindowState.Maximized) { if (form is VisualForm visualForm) { if (!visualForm.MaximizeBox) { // Disabled restoring form. return; } } else { if (!form.MaximizeBox) { // Disabled restoring form. return; } } if (_maximizeButton.BoxType == ControlBoxButton.ControlBoxType.Default) { _maximizeButton.Text = ControlBoxConstants.MaximizeText; } form.WindowState = ToggleFormWindowState(form.WindowState); Invalidate(); RestoredFormWindow?.Invoke(new ControlBoxEventArgs(form)); } }