[Quick Accent] fix showing toolbar in the corner position (#22736)

* [Quick Accent] fix showing toolbar in the corner position

* [Quick Accent] set horizontal allignment according to toolbar position

* [Quick Accent] fix spelling mistake
This commit is contained in:
Taras 2022-12-14 12:17:38 +02:00 committed by GitHub
parent b5f6722ae7
commit 9cf404250b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View File

@ -285,6 +285,11 @@ public class PowerAccent : IDisposable
return Calculation.GetRawCoordinatesFromPosition(position, screen, window);
}
public Position GetToolbarPosition()
{
return _settingService.Position;
}
public void Dispose()
{
_keyboardListener.UnInitHook();

View File

@ -42,6 +42,7 @@
</Window.Resources>
<Grid>
<Border
x:Name="gridBorder"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{DynamicResource SecondaryBackgroundBrush}"

View File

@ -9,6 +9,7 @@ using System.Globalization;
using System.Linq;
using System.Unicode;
using System.Windows;
using PowerAccent.Core.Services;
using PowerToys.PowerAccentKeyboardService;
using Point = PowerAccent.Core.Point;
using Size = PowerAccent.Core.Size;
@ -69,6 +70,7 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
characters.SelectedIndex = 0;
this.UpdateLayout(); // Required for filling the actual width/height before positioning.
SetWindowPosition();
SetWindowAlignment();
Show();
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
}
@ -91,6 +93,17 @@ public partial class Selector : Window, IDisposable, INotifyPropertyChanged
this.Top = position.Y;
}
private void SetWindowAlignment()
{
gridBorder.HorizontalAlignment = _powerAccent.GetToolbarPosition() switch
{
Position.Left or Position.TopLeft or Position.BottomLeft => HorizontalAlignment.Left,
Position.Right or Position.TopRight or Position.BottomRight => HorizontalAlignment.Right,
Position.Center or Position.Top or Position.Bottom => HorizontalAlignment.Center,
_ => HorizontalAlignment.Center
};
}
protected override void OnClosed(EventArgs e)
{
_powerAccent.Dispose();