示例#1
0
        protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
        {
            var window = VisualTreeExtension.FindMDIWindow(this);

            if (window != null && window.Container != null)
            {
                switch (window.WindowState)
                {
                case WindowState.Maximized:
                    window.Normalize();
                    break;

                case WindowState.Normal:
                    window.Maximize();
                    break;

                case WindowState.Minimized:
                    window.Normalize();
                    break;

                default:
                    throw new InvalidOperationException("Unsupported WindowsState mode");
                }
            }

            e.Handled = true;
        }
示例#2
0
        protected override void OnMouseDown(MouseButtonEventArgs e)
        {
            var window = VisualTreeExtension.FindMDIWindow(this);

            if (window != null)
            {
                window.Focus();
            }

            base.OnMouseDown(e);
        }
示例#3
0
        private void OnResizing(object sender, DragDeltaEventArgs e)
        {
            var window = VisualTreeExtension.FindMDIWindow(this);

            if (window != null)
            {
                if (window.IsFocused == false)
                {
                    window.Focus();
                }

                window.Height = window.ActualHeight;
                window.Width  = window.ActualWidth;

                switch (this.VerticalAlignment)
                {
                case VerticalAlignment.Bottom:
                    var deltaVertical = Math.Min(-e.VerticalChange, window.ActualHeight - window.MinHeight);
                    window.Height -= deltaVertical;
                    break;

                case VerticalAlignment.Top:
                    deltaVertical = Math.Min(e.VerticalChange, window.ActualHeight - window.MinHeight);
                    Canvas.SetTop(window, Canvas.GetTop(window) + deltaVertical);
                    window.Height -= deltaVertical;
                    break;

                default:
                    break;
                }

                switch (this.HorizontalAlignment)
                {
                case HorizontalAlignment.Left:
                    var deltaHorizontal = Math.Min(e.HorizontalChange, window.ActualWidth - window.MinWidth);
                    Canvas.SetLeft(window, Canvas.GetLeft(window) + deltaHorizontal);
                    window.Width -= deltaHorizontal;
                    break;

                case HorizontalAlignment.Right:
                    deltaHorizontal = Math.Min(-e.HorizontalChange, window.ActualWidth - window.MinWidth);
                    window.Width   -= deltaHorizontal;
                    break;

                default:
                    break;
                }
            }

            e.Handled = true;
        }
示例#4
0
        private void OnMoveThumbDragDelta(object sender, DragDeltaEventArgs e)
        {
            var window = VisualTreeExtension.FindMDIWindow(this);

            if (window != null)
            {
                if (window.WindowState == WindowState.Maximized)
                {
                    window.Normalize();
                }

                if (window.WindowState != WindowState.Minimized)
                {
                    window.LastLeft = Canvas.GetLeft(window);
                    window.LastTop  = Canvas.GetTop(window);

                    Canvas.SetLeft(window, window.LastLeft + e.HorizontalChange);
                    Canvas.SetTop(window, window.LastTop + e.VerticalChange);
                }
            }
        }