Пример #1
0
        void CheckBounds()
        {
            var screen      = WPFScreen.GetScreenFrom(this);
            var workingArea = screen.WorkingArea;

            // Top
            if (Top < workingArea.Y)
            {
                Top = workingArea.Y;
            }

            // Left
            if (Left < workingArea.X)
            {
                Left = workingArea.X;
            }

            // Bottom
            var windowBottom = Top + Height;
            var screenBottom = workingArea.Y + workingArea.Height;

            if ((Height <= workingArea.Height) && (windowBottom > screenBottom))
            {
                Top -= windowBottom - screenBottom;
            }

            // Right
            var windowRight = Left + Width;
            var screenRight = workingArea.X + workingArea.Width;

            if ((Width <= workingArea.Width) && (windowRight > screenRight))
            {
                Left -= windowRight - screenRight;
            }
        }
        private void Canvas_MouseLeave(object sender, MouseEventArgs e)
        {
            if (rect != null)
            {
                return;
            }

            if (!NativeUtils.GetCursorPos(out var point))
            {
                return;
            }

            var wpfPoint = new Point(point.X, point.Y);
            var screen   = WPFScreen.GetScreenFrom(wpfPoint);

            screen.MoveWindow(this);
        }
Пример #3
0
 public static WPFScreen Screen(this Window wnd)
 {
     return(WPFScreen.GetScreenFrom(wnd));
 }