コード例 #1
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #2
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #3
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #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);
            }
        }
コード例 #5
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #6
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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;
        }
コード例 #7
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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();
            }
        }
コード例 #8
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
 /// <summary>
 ///     Sets the window state of the window to maximized.
 /// </summary>
 public void MinimizeWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Minimized);
 }
コード例 #9
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #10
0
 public static void RemoveWindowRectChangedHandler(MdiWindow window, RoutedPropertyChangedEventHandler<Rect> handler)
 {
     window.RemoveHandler(WindowRectChangedEvent, handler);
 }
コード例 #11
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #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();
            }
        }
コード例 #13
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #14
0
 public static void RemoveWindowRectChangedHandler(MdiWindow window,
                                                   RoutedPropertyChangedEventHandler <Rect> handler)
 {
     window.RemoveHandler(WindowRectChangedEvent, handler);
 }
コード例 #15
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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);
        }
コード例 #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;
        }
コード例 #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;
        }
コード例 #18
0
 /// <summary>
 ///     Sets the window state of the window to normal.
 /// </summary>
 public void RestoreWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Normal);
 }
コード例 #19
0
 /// <summary>
 ///     Sets the window state of the window to maximized.
 /// </summary>
 public void MinimizeWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Minimized);
 }
コード例 #20
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
        /// <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;
        }
コード例 #21
0
ファイル: MdiFloater.cs プロジェクト: terminar/PresetMagician
 /// <summary>
 ///     Sets the window state of the window to normal.
 /// </summary>
 public void RestoreWindow(MdiWindow window)
 {
     SetWindowState(window, WindowState.Normal);
 }