mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-21 16:33:05 +08:00
[QuickAccent]Fix showing selector window (#22435)
* [Quick Accent] fix showing selector window * Update layout before using size to calculate position * Correct offset issues due to margin * Up the offset to 24, as the margin value removed
This commit is contained in:
parent
ec0fb6a4c7
commit
3afa124bea
@ -20,7 +20,7 @@ namespace PowerAccent.Core.Tools
|
|||||||
|
|
||||||
public static Point GetRawCoordinatesFromPosition(Position position, Rect screen, Size window)
|
public static Point GetRawCoordinatesFromPosition(Position position, Rect screen, Size window)
|
||||||
{
|
{
|
||||||
int offset = 10;
|
int offset = 24;
|
||||||
|
|
||||||
double pointX = position switch
|
double pointX = position switch
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
|
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
<Grid Margin="24,24,24,24">
|
<Grid>
|
||||||
<Border
|
<Border
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
|
@ -63,14 +63,18 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
|
|||||||
{
|
{
|
||||||
CharacterNameVisibility = _powerAccent.ShowUnicodeDescription ? Visibility.Visible : Visibility.Collapsed;
|
CharacterNameVisibility = _powerAccent.ShowUnicodeDescription ? Visibility.Visible : Visibility.Collapsed;
|
||||||
|
|
||||||
this.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed;
|
|
||||||
|
|
||||||
if (isActive)
|
if (isActive)
|
||||||
{
|
{
|
||||||
characters.ItemsSource = chars;
|
characters.ItemsSource = chars;
|
||||||
CenterWindow();
|
this.UpdateLayout(); // Required for filling the actual width/height before positioning.
|
||||||
|
SetWindowPosition();
|
||||||
|
Show();
|
||||||
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
|
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MenuExit_Click(object sender, RoutedEventArgs e)
|
private void MenuExit_Click(object sender, RoutedEventArgs e)
|
||||||
@ -78,11 +82,10 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
|
|||||||
Application.Current.Shutdown();
|
Application.Current.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CenterWindow()
|
private void SetWindowPosition()
|
||||||
{
|
{
|
||||||
UpdateLayout();
|
Size windowSize = new (((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth, ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight);
|
||||||
Size window = new (((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth, ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight);
|
Point position = _powerAccent.GetDisplayCoordinates(windowSize);
|
||||||
Point position = _powerAccent.GetDisplayCoordinates(window);
|
|
||||||
this.Left = position.X;
|
this.Left = position.X;
|
||||||
this.Top = position.Y;
|
this.Top = position.Y;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user