Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
        }
Exemplo n.º 3
0
        /// <summary>
        ///     Execute handler for the MdiCommands.CloseWindow command.
        /// </summary>
        private void ExecuteCloseWindow(ExecutedRoutedEventArgs e)
        {
            MdiWindow window = Content as MdiWindow;

            Debug.Assert(window != null);

            CloseWindow(window);
        }
Exemplo n.º 4
0
        private static void OnWindowRectChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            MdiWindow window = d as MdiWindow;

            if (window != null)
            {
                RoutedPropertyChangedEventArgs <Rect> args = new RoutedPropertyChangedEventArgs <Rect>((Rect)e.OldValue, (Rect)e.NewValue, WindowRectChangedEvent);
                window.RaiseEvent(args);
            }
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Set the window state of a window in the view.
        /// </summary>
        /// <remarks>
        ///     MdiWindow itself will call this method when its
        ///     MdiPanel.WindowState property changes.
        /// </remarks>
        public void SetWindowState(MdiWindow window, WindowState windowState)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            window.SetValue(MdiPanel.WindowStateProperty, windowState);
            this.WindowState = windowState;
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Removes the window from the view.
        /// </summary>
        public void CloseWindow(MdiWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            // Raise the window.Closing event, which can be canceled.
            if (window.Close())
            {
                // close this floater.
                Close();

                // Walk the visual tree looking for disposable elements.
                window.DisposeSubTree();
            }
        }
Exemplo n.º 8
0
 /// <summary>
 ///     Sets the window state of the window to maximized.
 /// </summary>
 public void MinimizeWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Minimized);
 }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
 public static void RemoveWindowRectChangedHandler(MdiWindow window, RoutedPropertyChangedEventHandler<Rect> handler)
 {
     window.RemoveHandler(WindowRectChangedEvent, handler);
 }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        /// <summary>
        ///     Removes the window from the view.
        /// </summary>
        public void CloseWindow(MdiWindow window)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            // Raise the window.Closing event, which can be canceled.
            if (window.Close())
            {
                // close this floater.
                Close();

                // Walk the visual tree looking for disposable elements.
                window.DisposeSubTree();
            }
        }
Exemplo n.º 13
0
        /// <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);
        }
Exemplo n.º 14
0
 public static void RemoveWindowRectChangedHandler(MdiWindow window,
                                                   RoutedPropertyChangedEventHandler <Rect> handler)
 {
     window.RemoveHandler(WindowRectChangedEvent, handler);
 }
Exemplo n.º 15
0
        /// <summary>
        ///     CanExecute handler for the MdiCommands.CloseWindow command.
        /// </summary>
        /// <remarks>
        ///     The command is only enabled if the items are not bound via
        ///     the ItemsSource.
        /// </remarks>
        private void CanExecuteCloseWindow(CanExecuteRoutedEventArgs e)
        {
            MdiWindow window = Content as MdiWindow;

            e.CanExecute = (window != null);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Adjust the window rect of a window.
        /// </summary>
        public void AdjustWindowRect(MdiWindow window, Vector delta, MdiWindowEdge interactiveEdges)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            Rect screenRect = MdiPanel.GetWindowRect(window);

            if (interactiveEdges == MdiWindowEdge.None)
            {
                screenRect.X += delta.X;
                screenRect.Y += delta.Y;
            }
            else
            {
                if ((interactiveEdges & MdiWindowEdge.Left) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Min(delta.X, (screenRect.Width - window.MinWidth));

                    screenRect.X += constrainedDelta;
                    screenRect.Width -= constrainedDelta;
                }
                if ((interactiveEdges & MdiWindowEdge.Right) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Max(delta.X, -(screenRect.Width - window.MinWidth));

                    screenRect.Width += constrainedDelta;
                }
                if ((interactiveEdges & MdiWindowEdge.Top) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Min(delta.Y, (screenRect.Height - window.MinHeight));

                    screenRect.Y += constrainedDelta;
                    screenRect.Height -= constrainedDelta;
                }
                if ((interactiveEdges & MdiWindowEdge.Bottom) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Max(delta.Y, -(screenRect.Height - window.MinHeight));

                    screenRect.Height += constrainedDelta;
                }
            }

            if (window.MinWidth > screenRect.Width)
            {
                if ((interactiveEdges & MdiWindowEdge.Left) != 0)
                {
                    screenRect.X = screenRect.Right - window.MinWidth;
                }
                screenRect.Width = window.MinWidth;
            }

            if (window.MinHeight > screenRect.Height)
            {
                if ((interactiveEdges & MdiWindowEdge.Top) != 0)
                {
                    screenRect.Y = screenRect.Bottom - window.MinHeight;
                }
                screenRect.Height = window.MinHeight;
            }

            MdiPanel.SetWindowRect(window, screenRect);

            this.Left = screenRect.Left;
            this.Top = screenRect.Top;
            this.Width = screenRect.Width;
            this.Height = screenRect.Height;
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Set the window state of a window in the view.
        /// </summary>
        /// <remarks>
        ///     MdiWindow itself will call this method when its
        ///     MdiPanel.WindowState property changes.
        /// </remarks>
        public void SetWindowState(MdiWindow window, WindowState windowState)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            window.SetValue(MdiPanel.WindowStateProperty, windowState);
            this.WindowState = windowState;
        }
Exemplo n.º 18
0
 /// <summary>
 ///     Sets the window state of the window to normal.
 /// </summary>
 public void RestoreWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Normal);
 }
Exemplo n.º 19
0
 /// <summary>
 ///     Sets the window state of the window to maximized.
 /// </summary>
 public void MinimizeWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Minimized);
 }
Exemplo n.º 20
0
        /// <summary>
        ///     Adjust the window rect of a window.
        /// </summary>
        public void AdjustWindowRect(MdiWindow window, Vector delta, MdiWindowEdge interactiveEdges)
        {
            if (window == null)
            {
                throw new ArgumentNullException("window");
            }

            if (Content != window)
            {
                throw new ArgumentException("Window does not belong to this floater.", "window");
            }

            Rect screenRect = MdiPanel.GetWindowRect(window);

            if (interactiveEdges == MdiWindowEdge.None)
            {
                screenRect.X += delta.X;
                screenRect.Y += delta.Y;
            }
            else
            {
                if ((interactiveEdges & MdiWindowEdge.Left) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Min(delta.X, (screenRect.Width - window.MinWidth));

                    screenRect.X     += constrainedDelta;
                    screenRect.Width -= constrainedDelta;
                }

                if ((interactiveEdges & MdiWindowEdge.Right) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Max(delta.X, -(screenRect.Width - window.MinWidth));

                    screenRect.Width += constrainedDelta;
                }

                if ((interactiveEdges & MdiWindowEdge.Top) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Min(delta.Y, (screenRect.Height - window.MinHeight));

                    screenRect.Y      += constrainedDelta;
                    screenRect.Height -= constrainedDelta;
                }

                if ((interactiveEdges & MdiWindowEdge.Bottom) != 0)
                {
                    // Can't size smaller than the minimum size.
                    double constrainedDelta = Math.Max(delta.Y, -(screenRect.Height - window.MinHeight));

                    screenRect.Height += constrainedDelta;
                }
            }

            if (window.MinWidth > screenRect.Width)
            {
                if ((interactiveEdges & MdiWindowEdge.Left) != 0)
                {
                    screenRect.X = screenRect.Right - window.MinWidth;
                }

                screenRect.Width = window.MinWidth;
            }

            if (window.MinHeight > screenRect.Height)
            {
                if ((interactiveEdges & MdiWindowEdge.Top) != 0)
                {
                    screenRect.Y = screenRect.Bottom - window.MinHeight;
                }

                screenRect.Height = window.MinHeight;
            }

            MdiPanel.SetWindowRect(window, screenRect);

            this.Left   = screenRect.Left;
            this.Top    = screenRect.Top;
            this.Width  = screenRect.Width;
            this.Height = screenRect.Height;
        }
Exemplo n.º 21
0
 /// <summary>
 ///     Sets the window state of the window to normal.
 /// </summary>
 public void RestoreWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Normal);
 }