private Rect GetScreenWorkingArea(Point p)
        {
            // Get the screen rect associated with the point
            Screen screen = Screen.FromPoint(ToDrawingPoint(p));

            return(ToRect(screen.WorkingArea));
        }
Exemple #2
0
        /// <summary>
        /// Calculates Y co-ordinate of main window top left corner
        /// </summary>
        /// <returns>Y co-ordinate of main window top left corner</returns>
        private double WindowTop()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dpi2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = (dpi2.Y - this.SearchBox.Height) / 4 + dpi1.Y;

            return(top);
        }
Exemple #3
0
        /// <summary>
        /// Calculates X co-ordinate of main window top left corner.
        /// </summary>
        /// <returns>X co-ordinate of main window top left corner</returns>
        private double WindowLeft()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            var dpi2   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            var left   = (dpi2.X - this.Width) / 2 + dpi1.X;

            return(left);
        }
Exemple #4
0
        private double WindowTop()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowIntelopHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dip2   = WindowIntelopHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = (dip2.Y - QueryTextBox.ActualHeight) / 4 + dip1.Y;

            return(top);
        }
        private double SetWindowTopPosition()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var top    = ((dip2.Y - LauncherControl.ActualHeight) / 4) + dip1.Y;

            return(top);
        }
        private double SetWindowLeftPosition()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dip1   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
            var dip2   = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
            var left   = ((dip2.X - Width) / 2) + dip1.X;

            return(left);
        }
        /// <summary>
        /// Calculates Y co-ordinate of main window top left corner
        /// </summary>
        /// <returns>Y co-ordinate of main window top left corner</returns>
        private double WindowTop()
        {
            var screen      = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dpi1        = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
            var dpi2        = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
            var totalHeight = this.SearchBoxBorder.Margin.Top + this.SearchBoxBorder.Margin.Bottom + this.SearchBox.Height + this.ListBoxBorder.Margin.Top + this.ListBoxBorder.Margin.Bottom + MAX_LIST_HEIGHT;
            var top         = (dpi2.Y - totalHeight) / 4 + dpi1.Y;

            return(top);
        }
Exemple #8
0
        private double GetWindowsTop()
        {
            if (UserSettingStorage.Instance.RememberLastLaunchLocation)
            {
                return(UserSettingStorage.Instance.WindowTop);
            }

            var screen   = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dipPoint = WindowIntelopHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);

            UserSettingStorage.Instance.WindowTop = (dipPoint.Y - tbQuery.ActualHeight) / 4;
            return(UserSettingStorage.Instance.WindowTop);
        }
Exemple #9
0
        private double GetWindowsLeft()
        {
            if (UserSettingStorage.Instance.RememberLastLaunchLocation)
            {
                return(UserSettingStorage.Instance.WindowLeft);
            }

            var screen   = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
            var dipPoint = WindowIntelopHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);

            UserSettingStorage.Instance.WindowLeft = (dipPoint.X - ActualWidth) / 2;
            return(UserSettingStorage.Instance.WindowLeft);
        }
Exemple #10
0
        private double GetWindowsTop()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);

            if (UserSettingStorage.Instance.RememberLastLaunchLocation)
            {
                var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
                var coordY     = (Top - origScreen.WorkingArea.Top) / (origScreen.WorkingArea.Height - ActualHeight);
                UserSettingStorage.Instance.WindowTop = (screen.WorkingArea.Height - ActualHeight) * coordY + screen.WorkingArea.Top;
            }
            else
            {
                UserSettingStorage.Instance.WindowTop = (screen.WorkingArea.Height - tbQuery.ActualHeight) / 4 + screen.WorkingArea.Top;
            }
            return(UserSettingStorage.Instance.WindowTop);
        }
Exemple #11
0
        private double GetWindowsLeft()
        {
            var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);

            if (UserSettingStorage.Instance.RememberLastLaunchLocation)
            {
                var origScreen = Screen.FromRectangle(new Rectangle((int)Left, (int)Top, (int)ActualWidth, (int)ActualHeight));
                var coordX     = (Left - origScreen.WorkingArea.Left) / (origScreen.WorkingArea.Width - ActualWidth);
                UserSettingStorage.Instance.WindowLeft = (screen.WorkingArea.Width - ActualWidth) * coordX + screen.WorkingArea.Left;
            }
            else
            {
                UserSettingStorage.Instance.WindowLeft = (screen.WorkingArea.Width - ActualWidth) / 2 + screen.WorkingArea.Left;
            }

            return(UserSettingStorage.Instance.WindowLeft);
        }
Exemple #12
0
        private Screen GetScreen()
        {
            ManagedCommon.StartupPosition position = _settings.StartupPosition;
            switch (position)
            {
            case ManagedCommon.StartupPosition.PrimaryMonitor:
                return(Screen.PrimaryScreen);

            case ManagedCommon.StartupPosition.Focus:
                IntPtr foregroundWindowHandle = NativeMethods.GetForegroundWindow();
                Screen activeScreen           = Screen.FromHandle(foregroundWindowHandle);
                return(activeScreen);

            case ManagedCommon.StartupPosition.Cursor:
            default:
                return(Screen.FromPoint(System.Windows.Forms.Cursor.Position));
            }
        }