Example #1
0
        public static WpfScreen GetScreenFrom(Window window)
        {
            WindowInteropHelper windowInteropHelper = new WindowInteropHelper(window);
            Screen    screen    = Screen.FromHandle(windowInteropHelper.Handle);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Example #2
0
        private void SetPosition()
        {
            var screens        = WpfScreen.AllScreens().ToArray();
            var farBottomRight =
                screens.OrderByDescending(scr => scr.WorkingArea.Right).First();

            Left = farBottomRight.WorkingArea.BottomRight.X - Width;
            Top  = farBottomRight.WorkingArea.BottomRight.Y - Height;
        }
Example #3
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);
            Screen    screen    = Screen.FromPoint(drawingPoint);
            WpfScreen wpfScreen = new WpfScreen(screen);

            return(wpfScreen);
        }
Example #4
0
        public MainWindow()
        {
            InitializeComponent();

            var screenCount = WpfScreen.AllScreens().Count();

            currentScreen = screenCount;
            moveCount     = screenCount * 2;

            Browser.Address = Settings.Default.TargetUri;

            SetPosition();
            Visibility = Visibility.Visible;
        }
Example #5
0
        public void Move()
        {
            var screens = WpfScreen.AllScreens().ToArray();

            // determine target locations
            var nextScreenSide = ++moveCount % 2 == 0;  // false == left, true == right

            // screenSide = left ? time to move onto the next screen. Make sure to rotate back to the first screen
            currentScreen = ((nextScreenSide == LEFT ? ++currentScreen : currentScreen) % screens.Length);

            var screen    = screens[currentScreen];
            var dockPoint = nextScreenSide == RIGHT
                ? screen.WorkingArea.BottomRight
                : screen.WorkingArea.BottomLeft;

            Left = nextScreenSide == RIGHT
                ? dockPoint.X - Width
                : dockPoint.X;
            Top = dockPoint.Y - Height;
        }