mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-11-24 04:12:32 +08:00
[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:
parent
b5f6722ae7
commit
9cf404250b
@ -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();
|
||||
|
@ -42,6 +42,7 @@
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<Border
|
||||
x:Name="gridBorder"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Background="{DynamicResource SecondaryBackgroundBrush}"
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user