[PT Run] Run dialog now has monitor positioning options (#9492)

* Run dialog now has monitor positioning options

* add monitor index validation in window position calculation

* correct path in page

* change how radio buttons are declared to resolve them not being set based on setting

* Change "follow mouse" wording

Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>

* PowerLauncher -> PowerToysRun for new variables/resources

* correct header label id and update wording to PowerToys Run

* only enable custom index if BOTH custom position radio checked and Run is enabled

* retrieve list count of detected monitors to limit selection of MonitorToDisplayOn

* add a link to Windows Display settings

* fix display settings link

* change how we get the number of connected monitors so we're not relying on presentation core, windowsbase etc which seem to fail the build

* combine position and appearance headers

* change references for custom position to "focus"

* restore accidentally removed files

* remove unused directives

* hook up "active window" position with the launcher window

* remove left overs

* remove uneeded itemgroup

* make resource prefixes consistent; using "Run_"

* add etcoreapp to spell check

* undo change to file not modified in the end

* remove unused checkbox post rebase

* remove change to reduce diff size

* changes according to review

* revert whitespace changes post rebase

* revert resources

* add changes back

* Update src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw

Add comment

Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>

* remove unneeded resource string

Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>
Co-authored-by: Enrico Giordani <enricogior@users.noreply.github.com>
This commit is contained in:
Adam Short
2021-03-09 17:20:49 +00:00
committed by GitHub
parent 964286ab99
commit 5c45f2c7b8
9 changed files with 160 additions and 4 deletions

View File

@@ -207,7 +207,7 @@ namespace PowerLauncher
/// <returns>X co-ordinate of main window top left corner</returns>
private double WindowLeft()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var screen = GetScreen();
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0);
var left = ((dip2.X - ActualWidth) / 2) + dip1.X;
@@ -216,13 +216,30 @@ namespace PowerLauncher
private double WindowTop()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var screen = GetScreen();
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height);
var top = ((dip2.Y - SearchBox.ActualHeight) / 4) + dip1.Y;
return top;
}
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);
}
}
private void Launcher_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Tab && Keyboard.IsKeyDown(Key.LeftShift))

View File

@@ -126,6 +126,11 @@ namespace PowerLauncher
_themeManager.ChangeTheme(_settings.Theme, true);
}
if (_settings.StartupPosition != overloadSettings.Properties.Position)
{
_settings.StartupPosition = overloadSettings.Properties.Position;
}
retry = false;
}