public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Thickness thickness = (Thickness)value; MdiWindowEdge edges = (MdiWindowEdge)Enum.Parse(typeof(MdiWindowEdge), (string)parameter); if ((edges & MdiWindowEdge.Left) == 0) { thickness.Left = 0; } if ((edges & MdiWindowEdge.Top) == 0) { thickness.Top = 0; } if ((edges & MdiWindowEdge.Right) == 0) { thickness.Right = 0; } if ((edges & MdiWindowEdge.Bottom) == 0) { thickness.Bottom = 0; } return(thickness); }
/// <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; }
public AdjustWindowRectParameter(Vector delta, MdiWindowEdge interactiveEdges) { Delta = delta; InteractiveEdges = interactiveEdges; }