private bool IsDraggableArea(WM message, IntPtr lParam)
            {
                if (message != WM.LBUTTONDOWN && message != WM.LBUTTONDBLCLK)
                {
                    return(false);
                }

                var point = new Point((int)lParam);

                return(_framelessOption.IsDraggable(_nativeHost, point));
            }
            private bool IsDraggableArea(WM message, IntPtr lParam)
            {
                if (message != WM.LBUTTONDOWN)
                {
                    return(false);
                }

                var point = new Point((int)lParam);

                AdjustPointDpi(_nativeHost.Handle, ref point);
                return(_framelessOption.IsDraggable(_nativeHost, point));
            }
示例#3
0
        public bool IsCursorInDraggableRegion(ref POINT cursorLoc, ref POINT windowTopLeftPoint)
        {
            // Cache location for zone
            var zonePt = new Point(cursorLoc.x, cursorLoc.y);

            var rectCurCursorLoc = new Point(cursorLoc.x, cursorLoc.y);

            ClientToScreen(MainWindowHandle, ref rectCurCursorLoc);
            cursorLoc = new POINT(rectCurCursorLoc.X, rectCurCursorLoc.Y);

            RECT rect = new RECT();

            GetWindowRect(MainWindowHandle, ref rect);

            Rectangle rectangle = rect;

            Point curCursorLoc = new Point(rectCurCursorLoc.X, rectCurCursorLoc.Y);

            // Mouse must be within Window
            if (!rectangle.Contains(curCursorLoc))
            {
                return(false);
            }

            // If no drag zones are defined, by default we drag the entire window
            if (_framelessOption?.DragZones == null)
            {
                windowTopLeftPoint = new POINT(rectangle.Left, rectangle.Top);
                return(true);
            }

            // This is using webkitapp regions as defined in the DragHandler
            if (_framelessOption.UseWebkitAppRegions)
            {
                if (_framelessOption.IsDraggable != null)
                {
                    bool isDraggable = _framelessOption.IsDraggable(zonePt);
                    if (isDraggable)
                    {
                        windowTopLeftPoint = new POINT(rectangle.Left, rectangle.Top);
                        return(true);
                    }
                }

                return(false);
            }

            // If no drag zones are defined, by default we drag the entire window
            if (!_framelessOption.DragZones.Any())
            {
                windowTopLeftPoint = new POINT(rectangle.Left, rectangle.Top);
                return(true);
            }

            foreach (var zone in _framelessOption.DragZones)
            {
                var size  = GetWindowClientSize();
                var scale = GetWindowDpiScale();
                if (zone.InZone(size, zonePt, scale))
                {
                    windowTopLeftPoint = new POINT(rectangle.Left, rectangle.Top);
                    return(true);
                }
            }

            return(false);
        }
示例#4
0
 // TODO: Enchance to configurable region.
 private bool IsForwardedArea()
 {
     GetCursorPos(out var point);
     DpiScreenToClient(_nativeHost.Handle, ref point);
     return(_framelessOption.IsDraggable(_nativeHost, new System.Drawing.Point(point.X, point.Y)));
 }