private HT _GetHTFromResizeGripDirection(ResizeGripDirection direction) { var isRightToLeft = this.AssociatedObject.FlowDirection == FlowDirection.RightToLeft; return(direction switch { ResizeGripDirection.Bottom => HT.BOTTOM, ResizeGripDirection.BottomLeft => isRightToLeft ? HT.BOTTOMRIGHT : HT.BOTTOMLEFT, ResizeGripDirection.BottomRight => isRightToLeft ? HT.BOTTOMLEFT : HT.BOTTOMRIGHT, ResizeGripDirection.Left => isRightToLeft ? HT.RIGHT : HT.LEFT, ResizeGripDirection.Right => isRightToLeft ? HT.LEFT : HT.RIGHT, ResizeGripDirection.Top => HT.TOP, ResizeGripDirection.TopLeft => isRightToLeft ? HT.TOPRIGHT : HT.TOPLEFT, ResizeGripDirection.TopRight => isRightToLeft ? HT.TOPLEFT : HT.TOPRIGHT, ResizeGripDirection.Caption => HT.CAPTION, _ => HT.NOWHERE });
// Token: 0x06000EFE RID: 3838 RVA: 0x00039EB8 File Offset: 0x000380B8 private HT _GetHTFromResizeGripDirection(ResizeGripDirection direction) { bool flag = this._window.FlowDirection == FlowDirection.RightToLeft; switch (direction) { case ResizeGripDirection.TopLeft: if (!flag) { return(HT.TOPLEFT); } return(HT.TOPRIGHT); case ResizeGripDirection.Top: return(HT.TOP); case ResizeGripDirection.TopRight: if (!flag) { return(HT.TOPRIGHT); } return(HT.TOPLEFT); case ResizeGripDirection.Right: if (!flag) { return(HT.RIGHT); } return(HT.LEFT); case ResizeGripDirection.BottomRight: if (!flag) { return(HT.BOTTOMRIGHT); } return(HT.BOTTOMLEFT); case ResizeGripDirection.Bottom: return(HT.BOTTOM); case ResizeGripDirection.BottomLeft: if (!flag) { return(HT.BOTTOMLEFT); } return(HT.BOTTOMRIGHT); case ResizeGripDirection.Left: if (!flag) { return(HT.LEFT); } return(HT.RIGHT); default: return(HT.NOWHERE); } }
public static void SetResizeGripDirection(IInputElement inputElement, ResizeGripDirection direction) { if (inputElement is not DependencyObject dependencyObject) { throw new ArgumentException("The element must be a DependencyObject", nameof(inputElement)); } dependencyObject.SetValue(ResizeGripDirectionProperty, direction); }
public static void SetResizeGripDirection(IInputElement inputElement, ResizeGripDirection direction) { Verify.IsNotNull(inputElement, "inputElement"); var dobj = inputElement as DependencyObject; if (dobj == null) { throw new ArgumentException("The element must be a DependencyObject", "inputElement"); } dobj.SetValue(ResizeGripDirectionProperty, direction); }
/// <summary>Sets the value of the <see cref="P:System.Windows.Shell.WindowChrome.ResizeGripDirection" /> attached property on the specified input element.</summary> /// <param name="inputElement">The element on which to set the <see cref="P:System.Windows.Shell.WindowChrome.ResizeGripDirection" /> attached property.</param> /// <param name="direction">The property value to set.</param> /// <exception cref="T:System.ArgumentNullException"> /// <paramref name="inputElement" /> is <see langword="null" />.</exception> /// <exception cref="T:System.ArgumentException"> /// <paramref name="inputElement" /> is not a <see cref="T:System.Windows.DependencyObject" />.</exception> // Token: 0x06000ED3 RID: 3795 RVA: 0x00038C00 File Offset: 0x00036E00 public static void SetResizeGripDirection(IInputElement inputElement, ResizeGripDirection direction) { Verify.IsNotNull <IInputElement>(inputElement, "inputElement"); DependencyObject dependencyObject = inputElement as DependencyObject; if (dependencyObject == null) { throw new ArgumentException("The element must be a DependencyObject", "inputElement"); } dependencyObject.SetValue(WindowChrome.ResizeGripDirectionProperty, direction); }
/// <summary> /// Creates the thumb. /// </summary> /// <param name="direction">The direction.</param> /// <param name="visualCursor">The visual cursor.</param> /// <returns></returns> protected ResizeThumb CreateThumb(ResizeGripDirection direction, Cursor visualCursor) { ResizeThumb thumb = new ResizeThumb { ResizeGripDirection = direction, Cursor = visualCursor }; thumb.DragStarted += Thumb_DragStarted; thumb.DragDelta += Thumb_DragDelta; this.visualChildren.Add(thumb); return(thumb); }
private void AssociatedObject_MouseUp(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { _currentResizeGripDirection = ResizeGripDirection.None; if (_isResizing) { _isResizing = false; _lastDragMoveTime = DateTime.Now; Mouse.Capture(null); AssociatedObject.Cursor = CursorDefault; DockablePanelWindowBehavior.EnableDockBehavior(AssociatedObject); #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"not resizing"); #endif } } }
private IntPtr _HandleNCHitTest(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled) { DpiScale dpi = this._window.GetDpi(); Point point = new Point((double)Utility.GET_X_LPARAM(lParam), (double)Utility.GET_Y_LPARAM(lParam)); Rect deviceRectangle = this._GetWindowRect(); Point point2 = point; point2.Offset(-deviceRectangle.X, -deviceRectangle.Y); point2 = DpiHelper.DevicePixelsToLogical(point2, dpi.DpiScaleX, dpi.DpiScaleY); IInputElement inputElement = this._window.InputHitTest(point2); if (inputElement != null) { if (WindowChrome.GetIsHitTestVisibleInChrome(inputElement)) { handled = true; return(new IntPtr(1)); } ResizeGripDirection resizeGripDirection = WindowChrome.GetResizeGripDirection(inputElement); if (resizeGripDirection != ResizeGripDirection.None) { handled = true; return(new IntPtr((int)this._GetHTFromResizeGripDirection(resizeGripDirection))); } } if (this._chromeInfo.UseAeroCaptionButtons && Utility.IsOSVistaOrNewer && this._chromeInfo.GlassFrameThickness != default(Thickness) && this._isGlassEnabled) { IntPtr intPtr; handled = NativeMethods.DwmDefWindowProc(this._hwnd, uMsg, wParam, lParam, out intPtr); if (IntPtr.Zero != intPtr) { return(intPtr); } } HT value = this._HitTestNca(DpiHelper.DeviceRectToLogical(deviceRectangle, dpi.DpiScaleX, dpi.DpiScaleY), DpiHelper.DevicePixelsToLogical(point, dpi.DpiScaleX, dpi.DpiScaleY)); handled = true; return(new IntPtr((int)value)); }
private HT _GetHTFromResizeGripDirection(ResizeGripDirection direction) { var compliment = this.AssociatedObject.FlowDirection == FlowDirection.RightToLeft; switch (direction) { case ResizeGripDirection.Bottom: return(HT.BOTTOM); case ResizeGripDirection.BottomLeft: return(compliment ? HT.BOTTOMRIGHT : HT.BOTTOMLEFT); case ResizeGripDirection.BottomRight: return(compliment ? HT.BOTTOMLEFT : HT.BOTTOMRIGHT); case ResizeGripDirection.Left: return(compliment ? HT.RIGHT : HT.LEFT); case ResizeGripDirection.Right: return(compliment ? HT.LEFT : HT.RIGHT); case ResizeGripDirection.Top: return(HT.TOP); case ResizeGripDirection.TopLeft: return(compliment ? HT.TOPRIGHT : HT.TOPLEFT); case ResizeGripDirection.TopRight: return(compliment ? HT.TOPLEFT : HT.TOPRIGHT); case ResizeGripDirection.Caption: return(HT.CAPTION); default: return(HT.NOWHERE); } }
/// <summary> /// Sets the WindowChrome ResizeGripDirection to a CrystalWindow template child. /// </summary> /// <param name="window">The CrystalWindow.</param> /// <param name="name">The name of the template child.</param> /// <param name="direction">The direction.</param> public static void SetWindowChromeResizeGripDirection([NotNull] this CrystalWindow window, string name, ResizeGripDirection direction) { if (window is null) { throw new ArgumentNullException(nameof(window)); } var inputElement = window.GetPart<IInputElement>(name); Debug.Assert(inputElement != null, $"{name} is not a IInputElement"); if (inputElement is not null && WindowChrome.GetResizeGripDirection(inputElement) != direction) { WindowChrome.SetResizeGripDirection(inputElement, direction); } }
/// <summary> /// Sets the WindowChrome ResizeGripDirection to a MetroWindow template child. /// </summary> /// <param name="window">The MetroWindow.</param> /// <param name="name">The name of the template child.</param> /// <param name="direction">The direction.</param> public static void SetWindowChromeResizeGripDirection(this MetroWindow window, string name, ResizeGripDirection direction) { if (window == null) { throw new ArgumentNullException(nameof(window)); } var inputElement = window.GetPart(name) as IInputElement; Debug.Assert(inputElement != null, $"{name} is not a IInputElement"); if (WindowChrome.GetResizeGripDirection(inputElement) != direction) { WindowChrome.SetResizeGripDirection(inputElement, direction); } }
private HT _GetHTFromResizeGripDirection(ResizeGripDirection direction) { bool compliment = _window.FlowDirection == FlowDirection.RightToLeft; switch (direction) { case ResizeGripDirection.Bottom: return HT.BOTTOM; case ResizeGripDirection.BottomLeft: return compliment ? HT.BOTTOMRIGHT : HT.BOTTOMLEFT; case ResizeGripDirection.BottomRight: return compliment ? HT.BOTTOMLEFT : HT.BOTTOMRIGHT; case ResizeGripDirection.Left: return compliment ? HT.RIGHT : HT.LEFT; case ResizeGripDirection.Right: return compliment ? HT.LEFT : HT.RIGHT; case ResizeGripDirection.Top: return HT.TOP; case ResizeGripDirection.TopLeft: return compliment ? HT.TOPRIGHT : HT.TOPLEFT; case ResizeGripDirection.TopRight: return compliment ? HT.TOPLEFT : HT.TOPRIGHT; default: return HT.NOWHERE; } }
public static void SetWindowChromeResizeGripDirection(this MetroWindow window, string name, ResizeGripDirection direction) { if (window == null) { return; } IInputElement part = window.GetPart(name) as IInputElement; if (part != null) { WindowChrome.SetResizeGripDirection(part, direction); } }
private void AssociatedObject_MouseMove( object sender, MouseEventArgs e) { if (!IsResizable) { return; } var p = e.GetPosition(AssociatedObject); if (_isResizing) { var elapsed = DateTime.Now - _lastDragMoveTime; if (LimitFrameRate && elapsed.TotalMilliseconds < MaximumMoveEventRate) { return; } #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"mouse move x={p.X},y={p.Y}"); #endif p.X += _initialDx; p.Y += _initialDy; double newLeft = AssociatedObject.Left; double newTop = AssociatedObject.Top; double newWidth = AssociatedObject.ActualWidth; double newHeight = AssociatedObject.ActualHeight; double calcLeft, calcTop, calcWidth, calcHeight; switch (_currentResizeGripDirection) { case ResizeGripDirection.Left: calcLeft = AssociatedObject.Left + p.X; calcWidth = AssociatedObject.ActualWidth - p.X; if (calcWidth < AssociatedObject.MinWidth) { calcLeft = AssociatedObject.Left; } calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); newLeft = calcLeft; newWidth = calcWidth; break; case ResizeGripDirection.Right: calcWidth = p.X; calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); newWidth = calcWidth; break; case ResizeGripDirection.Top: calcTop = AssociatedObject.Top + p.Y; calcHeight = AssociatedObject.ActualHeight - p.Y; if (calcHeight < AssociatedObject.MinHeight) { calcTop = AssociatedObject.Top; } calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); newTop = calcTop; newHeight = calcHeight; break; case ResizeGripDirection.Bottom: calcHeight = p.Y; calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); newHeight = calcHeight; break; case ResizeGripDirection.BottomRight: calcWidth = p.X; calcHeight = p.Y; calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); newHeight = calcHeight; calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); newWidth = calcWidth; break; case ResizeGripDirection.BottomLeft: calcLeft = AssociatedObject.Left + p.X; calcHeight = p.Y; calcWidth = AssociatedObject.ActualWidth - p.X; calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); if (calcWidth < AssociatedObject.MinWidth) { calcLeft = AssociatedObject.Left; } calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); newHeight = calcHeight; newLeft = calcLeft; newWidth = calcWidth; break; case ResizeGripDirection.TopRight: calcTop = AssociatedObject.Top + p.Y; calcHeight = AssociatedObject.ActualHeight - p.Y; calcWidth = p.X; if (calcHeight < AssociatedObject.MinHeight) { calcTop = AssociatedObject.Top; } calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); newWidth = calcWidth; newTop = calcTop; newHeight = calcHeight; break; case ResizeGripDirection.TopLeft: calcTop = AssociatedObject.Top + p.Y; calcLeft = AssociatedObject.Left + p.X; calcHeight = AssociatedObject.ActualHeight - p.Y; calcWidth = AssociatedObject.ActualWidth - p.X; if (calcWidth < AssociatedObject.MinWidth) { calcLeft = AssociatedObject.Left; } calcWidth = Math.Max(calcWidth, AssociatedObject.MinWidth); if (calcHeight < AssociatedObject.MinHeight) { calcTop = AssociatedObject.Top; } calcHeight = Math.Max(calcHeight, AssociatedObject.MinHeight); newTop = calcTop; newHeight = calcHeight; newLeft = calcLeft; newWidth = calcWidth; break; } if (ValidateResize == null) { AssociatedObject.SetPosAndSize(newLeft, newTop, newWidth, newHeight); } else { var(validatedWidth, validatedHeight) = ValidateResize(newWidth, newHeight); if (validatedWidth && validatedHeight) { AssociatedObject.SetPosAndSize(newLeft, newTop, newWidth, newHeight); } else { if (validatedWidth) { AssociatedObject.SetPosAndSize(newLeft, AssociatedObject.Top, newWidth, AssociatedObject.Height); } if (validatedHeight) { AssociatedObject.SetPosAndSize(AssociatedObject.Left, newTop, AssociatedObject.ActualWidth, newHeight); } } } _lastDragMoveTime = DateTime.Now; } else { var rgd = CheckRGD(p.X, p.Y); AssociatedObject.Cursor = _curDrs[rgd.hy, rgd.hx]; _currentResizeGripDirection = rgd.rgd; #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"mouse move x={p.X},y={p.Y} (rgd={CurrentResizeGripDirection}) (resizing={IsResizing})"); #endif } }
/// <summary> /// Creates the thumb. /// </summary> /// <param name="direction">The direction.</param> /// <param name="visualCursor">The visual cursor.</param> /// <returns></returns> protected ResizeThumb CreateThumb(ResizeGripDirection direction, Cursor visualCursor) { ResizeThumb thumb = new ResizeThumb { ResizeGripDirection = direction, Cursor = visualCursor }; thumb.DragStarted += Thumb_DragStarted; thumb.DragDelta += Thumb_DragDelta; this.visualChildren.Add(thumb); return thumb; }