internal void SetWindowState(Form form, FormWindowState old_window_state, FormWindowState new_window_state, bool is_activating_child) { bool mdiclient_layout; MdiWindowManager wm = (MdiWindowManager)form.window_manager; if (!is_activating_child && new_window_state == FormWindowState.Maximized && !wm.IsActive) { ActivateChild(form); return; } if (old_window_state == FormWindowState.Normal) { wm.NormalBounds = form.Bounds; } if (SetWindowStates(wm)) { return; } if (old_window_state == new_window_state) { return; } mdiclient_layout = old_window_state == FormWindowState.Maximized || new_window_state == FormWindowState.Maximized; switch (new_window_state) { case FormWindowState.Minimized: ArrangeIconicWindows(false); break; case FormWindowState.Maximized: form.Bounds = wm.MaximizedBounds; break; case FormWindowState.Normal: form.Bounds = wm.NormalBounds; break; } wm.UpdateWindowDecorations(new_window_state); form.ResetCursor(); if (mdiclient_layout) { Parent.PerformLayout(); } XplatUI.RequestNCRecalc(Parent.Handle); XplatUI.RequestNCRecalc(form.Handle); if (!setting_windowstates) { SizeScrollBars(); } }
public virtual void UpdateWindowDecorations(FormWindowState window_state) { ThemeEngine.Current.ManagedWindowSetButtonLocations(this); if (form.IsHandleCreated) { XplatUI.RequestNCRecalc(form.Handle); } }
internal virtual void Invalidate() { if ((Parent == null) || !(Parent is MainMenu) || (Parent.Wnd == null)) { return; } Form form = Parent.Wnd.FindForm(); if ((form == null) || (!form.IsHandleCreated)) { return; } XplatUI.RequestNCRecalc(form.Handle); }
internal void ChildFormClosed(Form form) { FormWindowState closed_form_windowstate = form.WindowState; form.Visible = false; Controls.Remove(form); if (Controls.Count == 0) { ((MdiWindowManager)form.window_manager).RaiseDeactivate(); } else if (closed_form_windowstate == FormWindowState.Maximized) { Form current = (Form)Controls [0]; current.WindowState = FormWindowState.Maximized; ActivateChild(current); } if (Controls.Count == 0) { XplatUI.RequestNCRecalc(Parent.Handle); ParentForm.PerformLayout(); #if NET_2_0 // If we closed the last child, unmerge the menus. // If it's not the last child, the menu will be unmerged // when another child takes focus. MenuStrip parent_menu = form.MdiParent.MainMenuStrip; if (parent_menu != null) { if (parent_menu.IsCurrentlyMerged) { ToolStripManager.RevertMerge(parent_menu); } } #endif } SizeScrollBars(); SetParentText(false); form.Dispose(); }
internal bool SetWindowStates(MdiWindowManager wm) { /* * MDI WindowState behaviour: * - If the active window is maximized, all other maximized windows are normalized. * - If a normal window gets focus and the original active window was maximized, * the normal window gets maximized and the original window gets normalized. * - If a minimized window gets focus and the original window was maximized, * the minimzed window gets maximized and the original window gets normalized. * If the ex-minimized window gets deactivated, it will be normalized. */ Form form = wm.form; if (setting_windowstates) { return(false); } if (!form.Visible) { return(false); } bool is_active = wm.IsActive; bool maximize_this = false; if (!is_active) { return(false); } ArrayList minimize_these = new ArrayList(); ArrayList normalize_these = new ArrayList(); setting_windowstates = true; foreach (Form frm in mdi_child_list) { if (frm == form) { continue; } else if (!frm.Visible) { continue; } if (frm.WindowState == FormWindowState.Maximized && is_active) { maximize_this = true; if (((MdiWindowManager)frm.window_manager).was_minimized) { minimize_these.Add(frm); } else { normalize_these.Add(frm); } } } if (maximize_this && form.WindowState != FormWindowState.Maximized) { wm.was_minimized = form.window_state == FormWindowState.Minimized; form.WindowState = FormWindowState.Maximized; } foreach (Form frm in minimize_these) { frm.WindowState = FormWindowState.Minimized; } foreach (Form frm in normalize_these) { frm.WindowState = FormWindowState.Normal; } SetParentText(false); XplatUI.RequestNCRecalc(ParentForm.Handle); XplatUI.RequestNCRecalc(Handle); SizeScrollBars(); setting_windowstates = false; if (form.MdiParent.MainMenuStrip != null) { form.MdiParent.MainMenuStrip.RefreshMdiItems(); } // Implicit menu strip merging // - When child is activated // - Parent form must have a MainMenuStrip // - Find the first menustrip on the child // - Merge MenuStrip parent_menu = form.MdiParent.MainMenuStrip; if (parent_menu != null) { if (parent_menu.IsCurrentlyMerged) { ToolStripManager.RevertMerge(parent_menu); } MenuStrip child_menu = LookForChildMenu(form); if (form.WindowState != FormWindowState.Maximized) { RemoveControlMenuItems(wm); } if (form.WindowState == FormWindowState.Maximized) { bool found = false; foreach (ToolStripItem tsi in parent_menu.Items) { if (tsi is MdiControlStrip.SystemMenuItem) { (tsi as MdiControlStrip.SystemMenuItem).MdiForm = form; found = true; } else if (tsi is MdiControlStrip.ControlBoxMenuItem) { (tsi as MdiControlStrip.ControlBoxMenuItem).MdiForm = form; found = true; } } if (!found) { parent_menu.SuspendLayout(); parent_menu.Items.Insert(0, new MdiControlStrip.SystemMenuItem(form)); parent_menu.Items.Add(new MdiControlStrip.ControlBoxMenuItem(form, MdiControlStrip.ControlBoxType.Close)); parent_menu.Items.Add(new MdiControlStrip.ControlBoxMenuItem(form, MdiControlStrip.ControlBoxType.Max)); parent_menu.Items.Add(new MdiControlStrip.ControlBoxMenuItem(form, MdiControlStrip.ControlBoxType.Min)); parent_menu.ResumeLayout(); } } if (child_menu != null) { ToolStripManager.Merge(child_menu, parent_menu); } } return(maximize_this); }