mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 19:27:56 +01:00
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Add Quotation mark Add local quotation based on ~~VK_OEM_7(0xDE)~~ VK_OEM_COMMA(0xBC) key. Not all quotes have been added, only `‟ „ ” « » ‚ , ‘ ’ › ‹ '「 」 《 》 『 』〈 〉″ ‴ ⁗` Why not added : - ` ⹂ ⌜ ⌝ ❛ ❜ ❝ ❞ 🙶 🙷 🙸 ' 「 」 ` its redundant and would make too much and not readable. - ` ﹁ ﹂ ﹃ ﹄ ` I did not put them because there use for horizontal text <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: https://github.com/microsoft/PowerToys/issues/29371 https://github.com/microsoft/PowerToys/issues/24832 - [ ] **Communication:** I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end user facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places (None) - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> This PR is currently a draft, I still need to know if adding language-related keyboard management is a good idea or specifying the use of a gobal key to make it easier to manage all the keyboards in one. Some languages can use different keyboards, I think this would become problematic if the keyboard does not match the key used by default. However, using a universal key can also pose an issue to finding the key. that remains to be discussed <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
118 lines
3.4 KiB
C#
118 lines
3.4 KiB
C#
// Copyright (c) Microsoft Corporation
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
|
|
using Wpf.Ui.Controls;
|
|
|
|
using Point = PowerAccent.Core.Point;
|
|
using Size = PowerAccent.Core.Size;
|
|
|
|
namespace PowerAccent.UI;
|
|
|
|
public partial class Selector : FluentWindow, IDisposable, INotifyPropertyChanged
|
|
{
|
|
private readonly Core.PowerAccent _powerAccent = new();
|
|
|
|
private Visibility _characterNameVisibility = Visibility.Visible;
|
|
|
|
private int _selectedIndex;
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
public Visibility CharacterNameVisibility
|
|
{
|
|
get
|
|
{
|
|
return _characterNameVisibility;
|
|
}
|
|
|
|
set
|
|
{
|
|
_characterNameVisibility = value;
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CharacterNameVisibility)));
|
|
}
|
|
}
|
|
|
|
public Selector()
|
|
{
|
|
InitializeComponent();
|
|
|
|
Wpf.Ui.Appearance.SystemThemeWatcher.Watch(this);
|
|
|
|
Application.Current.MainWindow.ShowActivated = false;
|
|
}
|
|
|
|
protected override void OnSourceInitialized(EventArgs e)
|
|
{
|
|
base.OnSourceInitialized(e);
|
|
_powerAccent.OnChangeDisplay += PowerAccent_OnChangeDisplay;
|
|
_powerAccent.OnSelectCharacter += PowerAccent_OnSelectionCharacter;
|
|
this.Visibility = Visibility.Hidden;
|
|
}
|
|
|
|
private void PowerAccent_OnSelectionCharacter(int index, string character)
|
|
{
|
|
_selectedIndex = index;
|
|
characters.SelectedIndex = _selectedIndex;
|
|
characterName.Text = _powerAccent.CharacterDescriptions[_selectedIndex];
|
|
characters.ScrollIntoView(character);
|
|
}
|
|
|
|
private void PowerAccent_OnChangeDisplay(bool isActive, string[] chars)
|
|
{
|
|
// Topmost is conditionally set here to address hybrid graphics issues on laptops.
|
|
this.Topmost = isActive;
|
|
|
|
CharacterNameVisibility = _powerAccent.ShowUnicodeDescription ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
if (isActive)
|
|
{
|
|
characters.ItemsSource = chars;
|
|
characters.SelectedIndex = _selectedIndex;
|
|
this.UpdateLayout(); // Required for filling the actual width/height before positioning.
|
|
SetWindowsSize();
|
|
SetWindowPosition();
|
|
Show();
|
|
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
|
|
}
|
|
else
|
|
{
|
|
Hide();
|
|
}
|
|
}
|
|
|
|
private void MenuExit_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
Application.Current.Shutdown();
|
|
}
|
|
|
|
private void SetWindowPosition()
|
|
{
|
|
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;
|
|
}
|
|
|
|
private void SetWindowsSize()
|
|
{
|
|
this.characters.MaxWidth = _powerAccent.GetDisplayMaxWidth();
|
|
}
|
|
|
|
protected override void OnClosed(EventArgs e)
|
|
{
|
|
_powerAccent.SaveUsageInfo();
|
|
_powerAccent.Dispose();
|
|
base.OnClosed(e);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
GC.SuppressFinalize(this);
|
|
}
|
|
}
|