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)
|
||||
{
|
||||
int offset = 10;
|
||||
int offset = 24;
|
||||
|
||||
double pointX = position switch
|
||||
{
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
|
||||
</Window.Resources>
|
||||
<Grid Margin="24,24,24,24">
|
||||
<Grid>
|
||||
<Border
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -63,14 +63,18 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
|
||||
{
|
||||
CharacterNameVisibility = _powerAccent.ShowUnicodeDescription ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
this.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
if (isActive)
|
||||
{
|
||||
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());
|
||||
}
|
||||
else
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuExit_Click(object sender, RoutedEventArgs e)
|
||||
@ -78,11 +82,10 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
private void CenterWindow()
|
||||
private void SetWindowPosition()
|
||||
{
|
||||
UpdateLayout();
|
||||
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(window);
|
||||
Size windowSize = new (((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth, ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight);
|
||||
Point position = _powerAccent.GetDisplayCoordinates(windowSize);
|
||||
this.Left = position.X;
|
||||
this.Top = position.Y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user