mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
[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:
@@ -239,6 +239,22 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
}
|
||||
}
|
||||
|
||||
private bool powerAccent;
|
||||
|
||||
[JsonPropertyName("PowerAccent")]
|
||||
public bool PowerAccent
|
||||
{
|
||||
get => powerAccent;
|
||||
set
|
||||
{
|
||||
if (powerAccent != value)
|
||||
{
|
||||
LogTelemetryEvent(value);
|
||||
powerAccent = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool powerOCR = true;
|
||||
|
||||
[JsonPropertyName("PowerOCR")]
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// 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.
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.Enumerations
|
||||
{
|
||||
public enum PowerAccentActivationKey
|
||||
{
|
||||
LeftRightArrow,
|
||||
Space,
|
||||
Both,
|
||||
}
|
||||
}
|
||||
25
src/settings-ui/Settings.UI.Library/PowerAccentProperties.cs
Normal file
25
src/settings-ui/Settings.UI.Library/PowerAccentProperties.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
// 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.Text.Json.Serialization;
|
||||
using ManagedCommon;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PowerAccentProperties
|
||||
{
|
||||
[JsonPropertyName("activation_key")]
|
||||
public PowerAccentActivationKey ActivationKey { get; set; }
|
||||
|
||||
[JsonPropertyName("toolbar_position")]
|
||||
public StringProperty ToolbarPosition { get; set; }
|
||||
|
||||
public PowerAccentProperties()
|
||||
{
|
||||
ActivationKey = PowerAccentActivationKey.Both;
|
||||
ToolbarPosition = "Top center";
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/settings-ui/Settings.UI.Library/PowerAccentSettings.cs
Normal file
35
src/settings-ui/Settings.UI.Library/PowerAccentSettings.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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.Text.Json.Serialization;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class PowerAccentSettings : BasePTModuleSettings, ISettingsConfig
|
||||
{
|
||||
public const string ModuleName = "PowerAccent";
|
||||
public const string ModuleVersion = "0.0.1";
|
||||
|
||||
[JsonPropertyName("properties")]
|
||||
public PowerAccentProperties Properties { get; set; }
|
||||
|
||||
public PowerAccentSettings()
|
||||
{
|
||||
Name = ModuleName;
|
||||
Version = ModuleVersion;
|
||||
Properties = new PowerAccentProperties();
|
||||
}
|
||||
|
||||
public string GetModuleName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public bool UpgradeSettingsConfiguration()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 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.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library
|
||||
{
|
||||
public class SndPowerAccentSettings
|
||||
{
|
||||
[JsonPropertyName("PowerAccent")]
|
||||
public PowerAccentSettings PowerAccentSettings { get; set; }
|
||||
|
||||
public SndPowerAccentSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public SndPowerAccentSettings(PowerAccentSettings settings)
|
||||
{
|
||||
PowerAccentSettings = settings;
|
||||
}
|
||||
|
||||
public string ToJsonString()
|
||||
{
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
// 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.Runtime.CompilerServices;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Enumerations;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Helpers;
|
||||
using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
public class PowerAccentViewModel : Observable
|
||||
{
|
||||
private GeneralSettings GeneralSettingsConfig { get; set; }
|
||||
|
||||
private readonly PowerAccentSettings _powerAccentSettings;
|
||||
|
||||
private readonly ISettingsUtils _settingsUtils;
|
||||
|
||||
private Func<string, int> SendConfigMSG { get; }
|
||||
|
||||
public PowerAccentViewModel(ISettingsUtils settingsUtils, ISettingsRepository<GeneralSettings> settingsRepository, Func<string, int> ipcMSGCallBackFunc)
|
||||
{
|
||||
// To obtain the general settings configurations of PowerToys Settings.
|
||||
if (settingsRepository == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(settingsRepository));
|
||||
}
|
||||
|
||||
_settingsUtils = settingsUtils ?? throw new ArgumentNullException(nameof(settingsUtils));
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
|
||||
_isEnabled = GeneralSettingsConfig.Enabled.PowerAccent;
|
||||
if (_settingsUtils.SettingsExists(PowerAccentSettings.ModuleName))
|
||||
{
|
||||
_powerAccentSettings = _settingsUtils.GetSettingsOrDefault<PowerAccentSettings>(PowerAccentSettings.ModuleName);
|
||||
}
|
||||
else
|
||||
{
|
||||
_powerAccentSettings = new PowerAccentSettings();
|
||||
}
|
||||
|
||||
switch (_powerAccentSettings.Properties.ToolbarPosition.Value)
|
||||
{
|
||||
case "Top center":
|
||||
_toolbarPositionIndex = 0;
|
||||
break;
|
||||
case "Bottom center":
|
||||
_toolbarPositionIndex = 1;
|
||||
break;
|
||||
case "Left":
|
||||
_toolbarPositionIndex = 2;
|
||||
break;
|
||||
case "Right":
|
||||
_toolbarPositionIndex = 3;
|
||||
break;
|
||||
case "Top right corner":
|
||||
_toolbarPositionIndex = 4;
|
||||
break;
|
||||
case "Top left corner":
|
||||
_toolbarPositionIndex = 5;
|
||||
break;
|
||||
case "Bottom right corner":
|
||||
_toolbarPositionIndex = 6;
|
||||
break;
|
||||
case "Bottom left corner":
|
||||
_toolbarPositionIndex = 7;
|
||||
break;
|
||||
case "Center":
|
||||
_toolbarPositionIndex = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
// set the callback functions value to hangle outgoing IPC message.
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
if (_isEnabled != value)
|
||||
{
|
||||
_isEnabled = value;
|
||||
|
||||
GeneralSettingsConfig.Enabled.PowerAccent = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
SendConfigMSG(outgoing.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int ActivationKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return (int)_powerAccentSettings.Properties.ActivationKey;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != (int)_powerAccentSettings.Properties.ActivationKey)
|
||||
{
|
||||
_powerAccentSettings.Properties.ActivationKey = (PowerAccentActivationKey)value;
|
||||
OnPropertyChanged(nameof(ActivationKey));
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int _toolbarPositionIndex;
|
||||
|
||||
public int ToolbarPositionIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _toolbarPositionIndex;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (_toolbarPositionIndex != value)
|
||||
{
|
||||
_toolbarPositionIndex = value;
|
||||
switch (_toolbarPositionIndex)
|
||||
{
|
||||
case 0:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Top center";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Bottom center";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Left";
|
||||
break;
|
||||
|
||||
case 3:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Right";
|
||||
break;
|
||||
|
||||
case 4:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Top right corner";
|
||||
break;
|
||||
|
||||
case 5:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Top left corner";
|
||||
break;
|
||||
|
||||
case 6:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Bottom right corner";
|
||||
break;
|
||||
|
||||
case 7:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Bottom left corner";
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_powerAccentSettings.Properties.ToolbarPosition.Value = "Center";
|
||||
break;
|
||||
}
|
||||
|
||||
RaisePropertyChanged(nameof(ToolbarPositionIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RaisePropertyChanged([CallerMemberName] string propertyName = null)
|
||||
{
|
||||
// Notify UI of property change
|
||||
OnPropertyChanged(propertyName);
|
||||
|
||||
if (SendConfigMSG != null)
|
||||
{
|
||||
SndPowerAccentSettings snd = new SndPowerAccentSettings(_powerAccentSettings);
|
||||
SndModuleSettings<SndPowerAccentSettings> ipcMessage = new SndModuleSettings<SndPowerAccentSettings>(snd);
|
||||
SendConfigMSG(ipcMessage.ToJsonString());
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user