diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml
index 21a8eb12e1..b5119bcf57 100644
--- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml
@@ -8,7 +8,8 @@
-
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml.cs
index 88b7f7996c..d013209292 100644
--- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml.cs
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml.cs
@@ -7,7 +7,10 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
using ManagedCommon;
+using Microsoft.UI;
+using Microsoft.UI.Dispatching;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
@@ -35,8 +38,14 @@ namespace KeyboardManagerEditorUI
public App()
{
this.InitializeComponent();
- Logger.InitializeLogger("\\Keyboard Manager\\WinUI3Editor\\Logs");
- Logger.LogInfo("keyboard-manager WinUI3 editor logger is initialized");
+
+ Task.Run(() =>
+ {
+ Logger.InitializeLogger("\\Keyboard Manager\\WinUI3Editor\\Logs");
+ Logger.LogInfo("keyboard-manager WinUI3 editor logger is initialized");
+ });
+
+ UnhandledException += App_UnhandledException;
}
///
@@ -46,10 +55,42 @@ namespace KeyboardManagerEditorUI
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
window = new MainWindow();
- window.Activate();
+
+ var appWindow = window.AppWindow;
+ var titleBar = appWindow.TitleBar;
+
+ titleBar.ExtendsContentIntoTitleBar = true;
+ titleBar.BackgroundColor = Colors.Transparent;
+
+ var windowSize = new Windows.Graphics.SizeInt32(960, 600);
+ appWindow.Resize(windowSize);
+
+ Task.Run(() =>
+ {
+ App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
+ {
+ Source = new Uri("ms-appx:///Styles/CommonStyle.xaml"),
+ });
+ }).ContinueWith(_ =>
+ {
+ window.DispatcherQueue.TryEnqueue(() =>
+ {
+ window.Activate();
+ window.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
+ {
+ (window.Content as FrameworkElement)?.UpdateLayout();
+ });
+ });
+ });
+
Logger.LogInfo("keyboard-manager WinUI3 editor window is launched");
}
+ private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
+ {
+ Logger.LogError("Unhandled exception", e.Exception);
+ }
+
private Window? window;
}
}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/FluentIconsKeyboardManager.png b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/FluentIconsKeyboardManager.png
new file mode 100644
index 0000000000..2d6db29ff1
Binary files /dev/null and b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/FluentIconsKeyboardManager.png differ
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/kbm.jpg b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/kbm.jpg
new file mode 100644
index 0000000000..46d0c96f6f
Binary files /dev/null and b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Assets/kbm.jpg differ
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/Remapping.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/Remapping.cs
new file mode 100644
index 0000000000..1f593177cc
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/Remapping.cs
@@ -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;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KeyboardManagerEditorUI.Helpers
+{
+ public class Remapping
+ {
+ public List OriginalKeys { get; set; } = new List();
+
+ public List RemappedKeys { get; set; } = new List();
+
+ public bool IsAllApps { get; set; } = true;
+
+ public string AppName { get; set; } = "All apps";
+
+ public bool IsEnabled { get; set; } = true;
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/URLShortcut.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/URLShortcut.cs
new file mode 100644
index 0000000000..b961b3bc1b
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Helpers/URLShortcut.cs
@@ -0,0 +1,19 @@
+// 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.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace KeyboardManagerEditorUI.Helpers
+{
+ public class URLShortcut
+ {
+ public List Shortcut { get; set; } = new List();
+
+ public string URL { get; set; } = string.Empty;
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/KeyboardManagerEditorUI.csproj b/src/modules/keyboardmanager/KeyboardManagerEditorUI/KeyboardManagerEditorUI.csproj
index eace63f59e..58f7a1e829 100644
--- a/src/modules/keyboardmanager/KeyboardManagerEditorUI/KeyboardManagerEditorUI.csproj
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/KeyboardManagerEditorUI.csproj
@@ -18,6 +18,22 @@
..\..\..\..\$(Platform)\$(Configuration)\$(MSBuildProjectName)
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -42,6 +58,46 @@
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+ MSBuild:Compile
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/ExistingUI.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/ExistingUI.xaml.cs
new file mode 100644
index 0000000000..a0da86f019
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/ExistingUI.xaml.cs
@@ -0,0 +1,102 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+// WinUI3 implementation of the Existing Keyboard Manager UI
+namespace KeyboardManagerEditorUI.Pages
+{
+ public sealed partial class ExistingUI : UserControl
+ {
+ public class KeyboardKey
+ {
+ public int KeyCode { get; set; }
+
+ public string KeyName { get; set; } = string.Empty;
+
+ public override string ToString() => KeyName;
+ }
+
+ // Struct to hold key code and name pairs
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
+ private struct KeyNamePair
+ {
+ public int KeyCode;
+ [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
+ public string KeyName;
+ }
+
+ [DllImport("PowerToys.KeyboardManagerEditorLibraryWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
+ private static extern int GetKeyboardKeysList(bool isShortcut, [Out] KeyNamePair[] keyList, int maxCount);
+
+ [DllImport("PowerToys.KeyboardManagerEditorLibraryWrapper.dll", CallingConvention = CallingConvention.Cdecl)]
+ private static extern bool CheckIfRemappingsAreValid();
+
+ public List KeysList { get; private set; } = new List();
+
+ public ExistingUI()
+ {
+ this.InitializeComponent();
+
+ LoadKeyboardKeys();
+
+ keyComboBox.ItemsSource = KeysList;
+ keyComboBox.DisplayMemberPath = "KeyName";
+
+ newKeyComboBox.ItemsSource = KeysList;
+ newKeyComboBox.DisplayMemberPath = "KeyCode";
+ }
+
+ private void LoadKeyboardKeys()
+ {
+ const int MaxKeys = 300;
+ KeyNamePair[] keyNamePairs = new KeyNamePair[MaxKeys];
+
+ int count = GetKeyboardKeysList(false, keyNamePairs, MaxKeys);
+
+ KeysList = new List(count);
+ for (int i = 0; i < count; i++)
+ {
+ KeysList.Add(new KeyboardKey
+ {
+ KeyCode = keyNamePairs[i].KeyCode,
+ KeyName = keyNamePairs[i].KeyName,
+ });
+ }
+ }
+
+ private void KeyComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ if (e.AddedItems.Count > 0 && e.AddedItems[0] is KeyboardKey key)
+ {
+ Console.WriteLine($"selected key: {key.KeyName} (code: {key.KeyCode})");
+ }
+ }
+
+ private void Button_Click(object sender, RoutedEventArgs e)
+ {
+ var button = sender as Button;
+ if (button == null)
+ {
+ // button.Background = (SolidColorBrush)Application.Current.Resources["SystemControlBackgroundAccentBrush"];
+ return;
+ }
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml
new file mode 100644
index 0000000000..1e5e2b4c86
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml
@@ -0,0 +1,230 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml.cs
new file mode 100644
index 0000000000..c0410222fb
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Programs.xaml.cs
@@ -0,0 +1,46 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using KeyboardManagerEditorUI.Helpers;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace KeyboardManagerEditorUI.Pages
+{
+ public sealed partial class Programs : Page
+ {
+ public ObservableCollection Shortcuts { get; set; }
+
+ public Programs()
+ {
+ this.InitializeComponent();
+
+ Shortcuts = new ObservableCollection();
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Win", "U", }, URL = "https://www.bing.com" });
+ }
+
+ private async void NewShortcutBtn_Click(object sender, RoutedEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+
+ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml
new file mode 100644
index 0000000000..62a6f01376
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml
@@ -0,0 +1,191 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml.cs
new file mode 100644
index 0000000000..02d7346a96
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Shortcuts.xaml.cs
@@ -0,0 +1,57 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using KeyboardManagerEditorUI.Helpers;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace KeyboardManagerEditorUI.Pages
+{
+ public sealed partial class Shortcuts : Page
+ {
+ public ObservableCollection RemappedShortcuts { get; set; }
+
+ public Shortcuts()
+ {
+ this.InitializeComponent();
+
+ RemappedShortcuts = new ObservableCollection();
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Ctrl", "Shift", "F" }, RemappedKeys = new List() { "Shift", "F" }, IsAllApps = true });
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Ctrl (Left)" }, RemappedKeys = new List() { "Ctrl (Right)" }, IsAllApps = true });
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Shift", "M" }, RemappedKeys = new List() { "Ctrl", "M" }, IsAllApps = true });
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Shift", "Alt", "B" }, RemappedKeys = new List() { "Alt", "B" }, IsAllApps = false, AppName = "outlook.exe" });
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Numpad 1" }, RemappedKeys = new List() { "Ctrl", "F" }, IsAllApps = true });
+ RemappedShortcuts.Add(new Remapping() { OriginalKeys = new List() { "Numpad 2" }, RemappedKeys = new List() { "Alt", "F" }, IsAllApps = true, AppName = "outlook.exe" });
+ }
+
+ private async void NewShortcutBtn_Click(object sender, RoutedEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+
+ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
+ {
+ if (e.ClickedItem is Remapping selectedShortcut)
+ {
+ ShortcutControl.SetOriginalKeys(selectedShortcut.OriginalKeys);
+ ShortcutControl.SetRemappedKeys(selectedShortcut.RemappedKeys);
+ ShortcutControl.SetApp(!selectedShortcut.IsAllApps, selectedShortcut.AppName);
+ await KeyDialog.ShowAsync();
+ }
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml
new file mode 100644
index 0000000000..4ccffe69b4
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml
@@ -0,0 +1,180 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml.cs
new file mode 100644
index 0000000000..1a9ae16ee3
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/Text.xaml.cs
@@ -0,0 +1,53 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using KeyboardManagerEditorUI.Helpers;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace KeyboardManagerEditorUI.Pages
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class Text : Page
+ {
+ public ObservableCollection Shortcuts { get; set; }
+
+ public Text()
+ {
+ this.InitializeComponent();
+
+ Shortcuts = new ObservableCollection();
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Shift", "Win", "M" }, URL = "Hello" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Win", "P", }, URL = "Nice!" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Shift", "Win", "M" }, URL = "I like it" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Win", "U", }, URL = "Yes" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Ctrl", "P" }, URL = "OK" });
+ }
+
+ private async void NewShortcutBtn_Click(object sender, RoutedEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+
+ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml
new file mode 100644
index 0000000000..06a2fbed00
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml.cs
new file mode 100644
index 0000000000..05a0b60040
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Pages/URLs.xaml.cs
@@ -0,0 +1,54 @@
+// 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.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using KeyboardManagerEditorUI.Helpers;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace KeyboardManagerEditorUI.Pages
+{
+ ///
+ /// An empty page that can be used on its own or navigated to within a Frame.
+ ///
+ public sealed partial class URLs : Page
+ {
+ public ObservableCollection Shortcuts { get; set; }
+
+ public URLs()
+ {
+ this.InitializeComponent();
+
+ Shortcuts = new ObservableCollection();
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Shift", "Win", "M" }, URL = "https://www.microsoft.com" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Win", "P", }, URL = "https://www.bing.com" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Shift", "Win", "M" }, URL = "https://www.windows.com" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Win", "U", }, URL = "https://www.bing.com" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Ctrl", "P" }, URL = "https://www.surface.com" });
+ Shortcuts.Add(new URLShortcut() { Shortcut = new List() { "Alt", "Ctrl", "Shift" }, URL = "https://www.bing.com" });
+ }
+
+ private async void NewShortcutBtn_Click(object sender, RoutedEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+
+ private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
+ {
+ await KeyDialog.ShowAsync();
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/CommonStyle.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/CommonStyle.xaml
new file mode 100644
index 0000000000..0cc49d716b
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/CommonStyle.xaml
@@ -0,0 +1,203 @@
+
+
+
+ 960
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml
new file mode 100644
index 0000000000..4b29a1af5a
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs
new file mode 100644
index 0000000000..5b319e9c5a
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/InputControl.xaml.cs
@@ -0,0 +1,80 @@
+// 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.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Controls.Primitives;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Input;
+using Microsoft.UI.Xaml.Media;
+using Microsoft.UI.Xaml.Navigation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+
+namespace KeyboardManagerEditorUI.Styles
+{
+ public sealed partial class InputControl : UserControl
+ {
+ public InputControl()
+ {
+ this.InitializeComponent();
+ }
+
+ public void SetOriginalKeys(List keys)
+ {
+ OriginalKeys.ItemsSource = keys;
+ }
+
+ public void SetRemappedKeys(List keys)
+ {
+ RemappedKeys.ItemsSource = keys;
+ }
+
+ private void OriginalToggleBtn_Checked(object sender, RoutedEventArgs e)
+ {
+ RemappedToggleBtn.IsChecked = false;
+ }
+
+ private void RemappedToggleBtn_Checked(object sender, RoutedEventArgs e)
+ {
+ OriginalToggleBtn.IsChecked = false;
+ }
+
+ public void SetApp(bool isSpecificApp, string appName)
+ {
+ if (isSpecificApp)
+ {
+ AllAppsCheckBox.IsChecked = true;
+ AppNameTextBox.Text = appName;
+ AppNameTextBox.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ AllAppsCheckBox.IsChecked = false;
+ AppNameTextBox.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ private void AllAppsCheckBox_Checked(object sender, RoutedEventArgs e)
+ {
+ AppNameTextBox.Visibility = Visibility.Visible;
+ }
+
+ private void AllAppsCheckBox_Unchecked(object sender, RoutedEventArgs e)
+ {
+ AppNameTextBox.Visibility = Visibility.Collapsed;
+ }
+
+ private void UserControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ AllAppsCheckBox.Checked += AllAppsCheckBox_Checked;
+ AllAppsCheckBox.Unchecked += AllAppsCheckBox_Unchecked;
+ }
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.cs b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.cs
new file mode 100644
index 0000000000..058377d1ce
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.cs
@@ -0,0 +1,198 @@
+// 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.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.UI.Xaml;
+using Microsoft.UI.Xaml.Controls;
+using Microsoft.UI.Xaml.Data;
+using Microsoft.UI.Xaml.Markup;
+using Microsoft.UI.Xaml.Media;
+using Windows.System;
+
+namespace KeyboardManagerEditorUI.Styles
+{
+ [TemplatePart(Name = KeyPresenter, Type = typeof(ContentPresenter))]
+ [TemplateVisualState(Name = "Normal", GroupName = "CommonStates")]
+ [TemplateVisualState(Name = "Disabled", GroupName = "CommonStates")]
+ [TemplateVisualState(Name = "Default", GroupName = "StateStates")]
+ [TemplateVisualState(Name = "Error", GroupName = "StateStates")]
+ public sealed partial class KeyVisual : Control
+ {
+ private const string KeyPresenter = "KeyPresenter";
+ private KeyVisual? _keyVisual;
+ private ContentPresenter? _keyPresenter;
+
+ public object Content
+ {
+ get => (object)GetValue(ContentProperty);
+ set => SetValue(ContentProperty, value);
+ }
+
+ public static readonly DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(object), typeof(KeyVisual), new PropertyMetadata(default(string), OnContentChanged));
+
+ public VisualType VisualType
+ {
+ get => (VisualType)GetValue(VisualTypeProperty);
+ set => SetValue(VisualTypeProperty, value);
+ }
+
+ public static readonly DependencyProperty VisualTypeProperty = DependencyProperty.Register("VisualType", typeof(VisualType), typeof(KeyVisual), new PropertyMetadata(default(VisualType), OnSizeChanged));
+
+ public bool IsError
+ {
+ get => (bool)GetValue(IsErrorProperty);
+ set => SetValue(IsErrorProperty, value);
+ }
+
+ public static readonly DependencyProperty IsErrorProperty = DependencyProperty.Register("IsError", typeof(bool), typeof(KeyVisual), new PropertyMetadata(false, OnIsErrorChanged));
+
+ public KeyVisual()
+ {
+ this.DefaultStyleKey = typeof(KeyVisual);
+ this.Style = GetStyleSize("TextKeyVisualStyle");
+ }
+
+ protected override void OnApplyTemplate()
+ {
+ IsEnabledChanged -= KeyVisual_IsEnabledChanged;
+ _keyVisual = (KeyVisual)this;
+ _keyPresenter = (ContentPresenter)_keyVisual.GetTemplateChild(KeyPresenter);
+ Update();
+ SetEnabledState();
+ SetErrorState();
+ IsEnabledChanged += KeyVisual_IsEnabledChanged;
+ base.OnApplyTemplate();
+ }
+
+ private static void OnContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ((KeyVisual)d).Update();
+ }
+
+ private static void OnSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ((KeyVisual)d).Update();
+ }
+
+ private static void OnIsErrorChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ ((KeyVisual)d).SetErrorState();
+ }
+
+ private void Update()
+ {
+ if (_keyVisual == null || _keyVisual._keyPresenter == null)
+ {
+ return;
+ }
+
+ if (_keyVisual.Content != null)
+ {
+ if (_keyVisual.Content.GetType() == typeof(string))
+ {
+ _keyVisual.Style = GetStyleSize("TextKeyVisualStyle");
+ _keyVisual._keyPresenter.Content = _keyVisual.Content;
+ }
+ else
+ {
+ _keyVisual.Style = GetStyleSize("IconKeyVisualStyle");
+
+ switch ((int)_keyVisual.Content)
+ {
+ /* We can enable other glyphs in the future
+ case 13: // The Enter key or button.
+ _keyVisual._keyPresenter.Content = "\uE751"; break;
+
+ case 8: // The Back key or button.
+ _keyVisual._keyPresenter.Content = "\uE750"; break;
+
+ case 16: // The right Shift key or button.
+ case 160: // The left Shift key or button.
+ case 161: // The Shift key or button.
+ _keyVisual._keyPresenter.Content = "\uE752"; break; */
+
+ case 38: _keyVisual._keyPresenter.Content = "\uE0E4"; break; // The Up Arrow key or button.
+ case 40: _keyVisual._keyPresenter.Content = "\uE0E5"; break; // The Down Arrow key or button.
+ case 37: _keyVisual._keyPresenter.Content = "\uE0E2"; break; // The Left Arrow key or button.
+ case 39: _keyVisual._keyPresenter.Content = "\uE0E3"; break; // The Right Arrow key or button.
+
+ case 91: // The left Windows key
+ case 92: // The right Windows key
+ PathIcon winIcon = (PathIcon)XamlReader.Load(@"") as PathIcon;
+ Viewbox winIconContainer = new Viewbox();
+ winIconContainer.Child = winIcon;
+ winIconContainer.HorizontalAlignment = HorizontalAlignment.Center;
+ winIconContainer.VerticalAlignment = VerticalAlignment.Center;
+
+ double iconDimensions = GetIconSize();
+ winIconContainer.Height = iconDimensions;
+ winIconContainer.Width = iconDimensions;
+ _keyVisual._keyPresenter.Content = winIconContainer;
+ break;
+ default: _keyVisual._keyPresenter.Content = ((VirtualKey)_keyVisual.Content).ToString(); break;
+ }
+ }
+ }
+ }
+
+ public Style GetStyleSize(string styleName)
+ {
+ if (VisualType == VisualType.Small)
+ {
+ return (Style)App.Current.Resources["Small" + styleName];
+ }
+ else if (VisualType == VisualType.SmallOutline)
+ {
+ return (Style)App.Current.Resources["SmallOutline" + styleName];
+ }
+ else if (VisualType == VisualType.LargeOutline)
+ {
+ return (Style)App.Current.Resources["LargeOutline" + styleName];
+ }
+ else
+ {
+ return (Style)App.Current.Resources["Default" + styleName];
+ }
+ }
+
+ public double GetIconSize()
+ {
+ if (VisualType == VisualType.Small || VisualType == VisualType.SmallOutline)
+ {
+ return (double)App.Current.Resources["SmallIconSize"];
+ }
+ else
+ {
+ return (double)App.Current.Resources["DefaultIconSize"];
+ }
+ }
+
+ private void KeyVisual_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
+ {
+ SetEnabledState();
+ }
+
+ private void SetErrorState()
+ {
+ VisualStateManager.GoToState(this, IsError ? "Error" : "Default", true);
+ }
+
+ private void SetEnabledState()
+ {
+ VisualStateManager.GoToState(this, IsEnabled ? "Normal" : "Disabled", true);
+ }
+ }
+
+ public enum VisualType
+ {
+ Small,
+ SmallOutline,
+ Large,
+ LargeOutline,
+ }
+}
diff --git a/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.xaml b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.xaml
new file mode 100644
index 0000000000..5bb67875cc
--- /dev/null
+++ b/src/modules/keyboardmanager/KeyboardManagerEditorUI/Styles/KeyVisual.xaml
@@ -0,0 +1,156 @@
+
+
+
+ 16
+ 12
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+