/// <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 IntPtr _HandleNCHITTEST(WM uMsg, IntPtr wParam, IntPtr lParam, out bool handled) { // We always want to handle hit-testing handled = true; var dpi = this.AssociatedObject.GetDpi(); // Let the system know if we consider the mouse to be in our effective non-client area. var mousePosScreen = Utility.GetPoint(lParam); //new Point(Utility.GET_X_LPARAM(lParam), Utility.GET_Y_LPARAM(lParam)); var windowPosition = this._GetWindowRect(); var mousePosWindow = mousePosScreen; mousePosWindow.Offset(-windowPosition.X, -windowPosition.Y); mousePosWindow = DpiHelper.DevicePixelsToLogical(mousePosWindow, dpi.DpiScaleX, dpi.DpiScaleY); var ht = this._HitTestNca(DpiHelper.DeviceRectToLogical(windowPosition, dpi.DpiScaleX, dpi.DpiScaleY), DpiHelper.DevicePixelsToLogical(mousePosScreen, dpi.DpiScaleX, dpi.DpiScaleY)); if (ht != HT.CLIENT || this.AssociatedObject.ResizeMode == ResizeMode.CanResizeWithGrip) { // If the app is asking for content to be treated as client then that takes precedence over _everything_, even DWM caption buttons. // This allows apps to set the glass frame to be non-empty, still cover it with WPF content to hide all the glass, // yet still get DWM to draw a drop shadow. var inputElement = this.AssociatedObject.InputHitTest(mousePosWindow); if (inputElement is not null) { if (WindowChrome.GetIsHitTestVisibleInChrome(inputElement)) { return(new IntPtr((int)HT.CLIENT)); } var direction = WindowChrome.GetResizeGripDirection(inputElement); if (direction != ResizeGripDirection.None) { return(new IntPtr((int)this._GetHTFromResizeGripDirection(direction))); } } } return(new IntPtr((int)ht)); }