/// <summary> /// Execute handler for the MdiCommands.RestoreWindow command. /// </summary> private void ExecuteRestoreWindow(ExecutedRoutedEventArgs e) { MdiWindow window = Content as MdiWindow; Debug.Assert(window != null && MdiPanel.GetWindowState(window) != WindowState.Normal); RestoreWindow(window); }
/// <summary> /// Execute handler for the MdiCommands.MinimizeWindow command. /// </summary> private void ExecuteMinimizeWindow(ExecutedRoutedEventArgs e) { MdiWindow window = Content as MdiWindow; Debug.Assert(window != null && MdiPanel.GetWindowState(window) != WindowState.Minimized); MinimizeWindow(window); }
/// <summary> /// Execute handler for the MdiCommands.AdjustWindowRect command. /// </summary> private void ExecuteAdjustWindowRect(ExecutedRoutedEventArgs e) { UIElement originalSource = (UIElement)e.OriginalSource; AdjustWindowRectParameter swp = (AdjustWindowRectParameter)e.Parameter; MdiWindow window = Content as MdiWindow; Debug.Assert(window != null && MdiPanel.GetWindowState(window) == WindowState.Normal); Vector delta = originalSource.TransformElementToElement(swp.Delta, window); AdjustWindowRect(window, delta, swp.InteractiveEdges); }
// Bring to the front of the windows in the specified state. public void BringToFront(MdiWindow window, WindowState windowState) { int oldIndex = IndexOf(window); int newIndex = Count - 1; if (windowState == WindowState.Minimized) { bool foundSelf = false; for (newIndex = 0; newIndex < (Count - 1); newIndex++) { if (Items[newIndex] == window) { foundSelf = true; } if (MdiPanel.GetWindowState(Items[newIndex]) != WindowState.Minimized) { break; } } if (foundSelf) { newIndex--; } } Move(oldIndex, newIndex); // HACK: how to coordinate Win32 ZOrder with WPF ZOrder? This works, but assumes to many implementation details. if (VisualTreeHelper.GetChildrenCount(window) > 0) { AirspaceDecorator hwndClipper = VisualTreeHelper.GetChild(window, 0) as AirspaceDecorator; if (hwndClipper != null) { if (VisualTreeHelper.GetChildrenCount(hwndClipper) > 0) { HwndSourceHost hwndSourceHost = VisualTreeHelper.GetChild(hwndClipper, 0) as HwndSourceHost; if (hwndSourceHost != null) { HWND hwnd = new HWND(hwndSourceHost.Handle); NativeMethods.SetWindowPos(hwnd, HWND.TOP, 0, 0, 0, 0, SWP.NOMOVE | SWP.NOSIZE); } } } } }
/// <summary> /// CanExecute handler for the MdiCommands.RestoreWindow command. /// </summary> private void CanExecuteRestoreWindow(CanExecuteRoutedEventArgs e) { MdiWindow window = Content as MdiWindow; e.CanExecute = (window != null && MdiPanel.GetWindowState(window) != WindowState.Normal); }
/// <summary> /// CanExecute handler for the MdiCommands.MinimizeWindow command. /// </summary> private void CanExecuteMinimizeWindow(CanExecuteRoutedEventArgs e) { MdiWindow window = Content as MdiWindow; e.CanExecute = (window != null && MdiPanel.GetWindowState(window) != WindowState.Minimized); }
/// <summary> /// CanExecute handler for the MdiCommands.AdjustWindowRect command. /// </summary> private void CanExecuteAdjustWindowRect(CanExecuteRoutedEventArgs e) { MdiWindow window = Content as MdiWindow; e.CanExecute = (window != null && MdiPanel.GetWindowState(window) == WindowState.Normal); }