Beispiel #1
0
        public static WpfScreen GetScreenFrom(Window window)
        {
            System.Windows.Interop.WindowInteropHelper windowInteropHelper = new System.Windows.Interop.WindowInteropHelper(window);
            System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromHandle(windowInteropHelper.Handle);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Beispiel #2
0
        public static WpfScreen GetScreenFrom(Point point)
        {
            int x = (int)Math.Round(point.X);
            int y = (int)Math.Round(point.Y);

            // are x,y device-independent-pixels ??
            System.Drawing.Point        drawingPoint = new System.Drawing.Point(x, y);
            System.Windows.Forms.Screen screen       = System.Windows.Forms.Screen.FromPoint(drawingPoint);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Beispiel #3
0
        private Vector CoerceWindowBound(Vector newPoint)
        {
            // Snap to the current desktop border
            var screen = WpfScreen.GetScreenFrom(_window);
            var wa     = screen.WorkingArea;

            if (newPoint.X < wa.Top)
            {
                newPoint.X = wa.Top;
            }
            if (newPoint.Y < wa.Left)
            {
                newPoint.Y = wa.Left;
            }
            if (_window.Width + newPoint.X > wa.Right)
            {
                newPoint.X = wa.Right - _window.Width;
            }
            if (_window.Height + newPoint.Y > wa.Bottom)
            {
                newPoint.Y = wa.Bottom - _window.Height;
            }
            return(newPoint);
        }