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; }
protected override void OnMouseDown(MouseButtonEventArgs e) { var window = VisualTreeExtension.FindMDIWindow(this); if (window != null) { window.Focus(); } base.OnMouseDown(e); }
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; }
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); } } }