[New PowerToy] PowerAccent (#19212)

* add poweraccent (draft) for PR

* removing french text for Spell checking job

* add 'poweraccent' to spell checker

* add 'damienleroy' to spell checker file

* adding RuntimeIdentifiers for PowerAccent project

* duplicate image for settings

* update commandline arguments for launch settings

* Removing WndProc for testing with inter-process connection

* add PowerAccent sources for PowerToys

* fix spellcheck

* fixing stylecop conventions

* Remove StyleCop.Analyzers because of duplicate

* fixing command line reference

* Fixing CS8012 for PowerAccent.

* ARM64 processor

* - Modify PowerAccent fluenticon for dark mode
- Try fix arm64 release

* Remove taskbar

* init Oobe view

* - added POwerAccent to App.xaml.cs
- change style to markdown in Oobe display

* - fixing poweraccent crash
- change Oobe LearnMore link

* Installer and signing

* Cleanup
Add settings

* Issue template

* Add some more characters

* Disabled by default

* Proper ToUnicodeEx calling and remove hacks

* Fix spellcheck

* Remove CommandLine dependency and debug prints. Add logs

* fix signing

* Fix binary metadata with version

* Fix the added space bug

* Only type space if it was the trigger method

* Take account of InputTime for displaying UI

* Fix code styling

* Remove the Trace WriteLine hack and add a delay instead

* Reinstate logs

* Better explanations

* Add telemetry for showing the menu

* Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw

* Update src/settings-ui/Settings.UI/Strings/en-us/Resources.resw

* Update src/modules/poweraccent/PowerAccent.Core/Tools/KeyboardListener.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Add accented characters for S

* Default to both activation methods

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

* Update src/modules/poweraccent/PowerAccent.Core/Services/SettingsService.cs

Co-authored-by: Damien LEROY <dleroy@veepee.com>
This commit is contained in:
damienleroy
2022-08-26 18:01:50 +02:00
committed by GitHub
parent 785160653c
commit d9c0af232b
66 changed files with 2836 additions and 7 deletions

View File

@@ -0,0 +1,17 @@
<Application x:Class="PowerAccent.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:PowerAccent"
StartupUri="Selector.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!-- MahApps.Metro resource dictionaries. Make sure that all file names are Case Sensitive! -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<!-- Theme setting -->
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,33 @@
// 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.Threading;
using System.Windows;
namespace PowerAccent.UI
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
private static Mutex _mutex;
protected override void OnStartup(StartupEventArgs e)
{
const string appName = "PowerAccent";
bool createdNew;
_mutex = new Mutex(true, appName, out createdNew);
if (!createdNew)
{
// app is already running! Exiting the application
Application.Current.Shutdown();
}
base.OnStartup(e);
}
}
}

View File

@@ -0,0 +1,10 @@
// 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.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, // where theme specific resource dictionaries are located (used if a resource is not found in the page, or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly) // where the generic resource dictionary is locate (used if a resource is not found in the page, app, or any theme specific resource dictionaries)
]

View File

@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\Version.props" />
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
<Nullable>disable</Nullable>
<UseWPF>true</UseWPF>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<ApplicationIcon>a-icon.ico</ApplicationIcon>
<AssemblyName>PowerAccent</AssemblyName>
<XamlDebuggingInformation>True</XamlDebuggingInformation>
</PropertyGroup>
<ItemGroup>
<None Remove="win11desktop.jpg" />
</ItemGroup>
<ItemGroup>
<Resource Include="a-icon.ico">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
<Resource Include="win11desktop.jpg" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="gong-wpf-dragdrop" Version="3.1.1" />
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PowerAccent.Core\PowerAccent.Core.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,55 @@
<Window x:Class="PowerAccent.UI.Selector"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:PowerAccent"
mc:Ignorable="d" SizeToContent="WidthAndHeight" ShowInTaskbar="False" ResizeMode="NoResize"
Title="MainWindow" Height="50" Width="50" Visibility="Collapsed" WindowStyle="None">
<Grid>
<ListBox x:Name="characters" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" IsHitTestVisible="False"
BorderThickness="1" BorderBrush="SlateGray">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel IsItemsHost="False" Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock TextAlignment="Center" VerticalAlignment="Center" Text="{Binding}" FontSize="18" />
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style x:Name="ItemStyle" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="myBorder"
Padding="0" Margin="0"
SnapsToDevicePixels="true"
Style="{DynamicResource borderContent}">
<ContentPresenter />
</Border>
<ControlTemplate.Resources>
<Style x:Key="borderContent" TargetType="Border">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Background" Value="#ECECEC"/>
<Setter Property="Width" Value="50"/>
<Setter Property="Height" Value="50"/>
</Style>
</ControlTemplate.Resources>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="myBorder" Property="Background" Value="White"/>
<Setter Property="FontWeight" Value="Bold"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
</Window>

View File

@@ -0,0 +1,71 @@
// 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.Windows;
using Point = PowerAccent.Core.Point;
using Size = PowerAccent.Core.Size;
namespace PowerAccent.UI;
public partial class Selector : Window, IDisposable
{
private Core.PowerAccent _powerAccent = new Core.PowerAccent();
public Selector()
{
InitializeComponent();
Application.Current.MainWindow.ShowActivated = false;
Application.Current.MainWindow.Topmost = true;
}
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, char character)
{
characters.SelectedIndex = index;
}
private void PowerAccent_OnChangeDisplay(bool isActive, char[] chars)
{
this.Visibility = isActive ? Visibility.Visible : Visibility.Collapsed;
if (isActive)
{
CenterWindow();
characters.ItemsSource = chars;
Microsoft.PowerToys.Telemetry.PowerToysTelemetry.Log.WriteEvent(new PowerAccent.Core.Telemetry.PowerAccentShowAccentMenuEvent());
}
}
private void MenuExit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
private void CenterWindow()
{
UpdateLayout();
Size window = new Size(((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualWidth, ((System.Windows.Controls.Panel)Application.Current.MainWindow.Content).ActualHeight);
Point position = _powerAccent.GetDisplayCoordinates(window);
this.Left = position.X;
this.Top = position.Y;
}
protected override void OnClosed(EventArgs e)
{
_powerAccent.Dispose();
base.OnClosed(e);
}
public void Dispose()
{
GC.SuppressFinalize(this);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB