public static RevertMerge ( |
||
targetToolStrip | ||
Результат | bool |
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); }