Skip to content

Commit f7ed043

Browse files
authored
[FHL] New static UX for Keyboard Manager Editor (#37747)
* Set up static new UX for Keyboard Manager Editor * Improve the formatting and performance * fix spelling
1 parent d90215e commit f7ed043

24 files changed

+2135
-149
lines changed

src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
<ResourceDictionary>
99
<ResourceDictionary.MergedDictionaries>
1010
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11-
<!-- Other merged dictionaries here -->
11+
<ResourceDictionary Source="/Styles/KeyVisual.xaml" />
12+
<ResourceDictionary Source="/Styles/CommonStyle.xaml" />
1213
</ResourceDictionary.MergedDictionaries>
1314
<!-- Other app resources here -->
1415
</ResourceDictionary>

src/modules/keyboardmanager/KeyboardManagerEditorUI/App.xaml.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
using System.IO;
88
using System.Linq;
99
using System.Runtime.InteropServices.WindowsRuntime;
10+
using System.Threading.Tasks;
1011
using ManagedCommon;
12+
using Microsoft.UI;
13+
using Microsoft.UI.Dispatching;
1114
using Microsoft.UI.Xaml;
1215
using Microsoft.UI.Xaml.Controls;
1316
using Microsoft.UI.Xaml.Controls.Primitives;
@@ -35,8 +38,14 @@ public partial class App : Application
3538
public App()
3639
{
3740
this.InitializeComponent();
38-
Logger.InitializeLogger("\\Keyboard Manager\\WinUI3Editor\\Logs");
39-
Logger.LogInfo("keyboard-manager WinUI3 editor logger is initialized");
41+
42+
Task.Run(() =>
43+
{
44+
Logger.InitializeLogger("\\Keyboard Manager\\WinUI3Editor\\Logs");
45+
Logger.LogInfo("keyboard-manager WinUI3 editor logger is initialized");
46+
});
47+
48+
UnhandledException += App_UnhandledException;
4049
}
4150

4251
/// <summary>
@@ -46,10 +55,42 @@ public App()
4655
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
4756
{
4857
window = new MainWindow();
49-
window.Activate();
58+
59+
var appWindow = window.AppWindow;
60+
var titleBar = appWindow.TitleBar;
61+
62+
titleBar.ExtendsContentIntoTitleBar = true;
63+
titleBar.BackgroundColor = Colors.Transparent;
64+
65+
var windowSize = new Windows.Graphics.SizeInt32(960, 600);
66+
appWindow.Resize(windowSize);
67+
68+
Task.Run(() =>
69+
{
70+
App.Current.Resources.MergedDictionaries.Add(new ResourceDictionary()
71+
{
72+
Source = new Uri("ms-appx:///Styles/CommonStyle.xaml"),
73+
});
74+
}).ContinueWith(_ =>
75+
{
76+
window.DispatcherQueue.TryEnqueue(() =>
77+
{
78+
window.Activate();
79+
window.DispatcherQueue.TryEnqueue(DispatcherQueuePriority.Low, () =>
80+
{
81+
(window.Content as FrameworkElement)?.UpdateLayout();
82+
});
83+
});
84+
});
85+
5086
Logger.LogInfo("keyboard-manager WinUI3 editor window is launched");
5187
}
5288

89+
private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
90+
{
91+
Logger.LogError("Unhandled exception", e.Exception);
92+
}
93+
5394
private Window? window;
5495
}
5596
}
Loading
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) Microsoft Corporation
2+
// The Microsoft Corporation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace KeyboardManagerEditorUI.Helpers
12+
{
13+
public class Remapping
14+
{
15+
public List<string> OriginalKeys { get; set; } = new List<string>();
16+
17+
public List<string> RemappedKeys { get; set; } = new List<string>();
18+
19+
public bool IsAllApps { get; set; } = true;
20+
21+
public string AppName { get; set; } = "All apps";
22+
23+
public bool IsEnabled { get; set; } = true;
24+
}
25+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) Microsoft Corporation
2+
// The Microsoft Corporation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace KeyboardManagerEditorUI.Helpers
12+
{
13+
public class URLShortcut
14+
{
15+
public List<string> Shortcut { get; set; } = new List<string>();
16+
17+
public string URL { get; set; } = string.Empty;
18+
}
19+
}

src/modules/keyboardmanager/KeyboardManagerEditorUI/KeyboardManagerEditorUI.csproj

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818
<OutputPath>..\..\..\..\$(Platform)\$(Configuration)\$(MSBuildProjectName)</OutputPath>
1919
</PropertyGroup>
2020

21+
<PropertyGroup>
22+
<EnableDefaultXamlItems>true</EnableDefaultXamlItems>
23+
<EnableXamlJitOptimization>true</EnableXamlJitOptimization>
24+
</PropertyGroup>
25+
26+
<ItemGroup>
27+
<None Remove="Pages\ExistingUI.xaml" />
28+
<None Remove="Pages\Programs.xaml" />
29+
<None Remove="Pages\Shortcuts.xaml" />
30+
<None Remove="Pages\Text.xaml" />
31+
<None Remove="Pages\URLs.xaml" />
32+
<None Remove="Styles\CommonStyle.xaml" />
33+
<None Remove="Styles\InputControl.xaml" />
34+
<None Remove="Styles\KeyVisual.xaml" />
35+
</ItemGroup>
36+
2137
<ItemGroup>
2238
<Manifest Include="$(ApplicationManifest)" />
2339
</ItemGroup>
@@ -42,6 +58,46 @@
4258
<ItemGroup>
4359
<Folder Include="Assets\" />
4460
</ItemGroup>
61+
<ItemGroup>
62+
<Page Update="Styles\CommonStyle.xaml">
63+
<Generator>MSBuild:Compile</Generator>
64+
</Page>
65+
</ItemGroup>
66+
<ItemGroup>
67+
<Page Update="Pages\URLs.xaml">
68+
<Generator>MSBuild:Compile</Generator>
69+
</Page>
70+
</ItemGroup>
71+
<ItemGroup>
72+
<Page Update="Pages\Text.xaml">
73+
<Generator>MSBuild:Compile</Generator>
74+
</Page>
75+
</ItemGroup>
76+
<ItemGroup>
77+
<Page Update="Pages\Programs.xaml">
78+
<Generator>MSBuild:Compile</Generator>
79+
</Page>
80+
</ItemGroup>
81+
<ItemGroup>
82+
<Page Update="Pages\Shortcuts.xaml">
83+
<Generator>MSBuild:Compile</Generator>
84+
</Page>
85+
</ItemGroup>
86+
<ItemGroup>
87+
<Page Update="Styles\InputControl.xaml">
88+
<Generator>MSBuild:Compile</Generator>
89+
</Page>
90+
</ItemGroup>
91+
<ItemGroup>
92+
<Page Update="Styles\KeyVisual.xaml">
93+
<Generator>MSBuild:Compile</Generator>
94+
</Page>
95+
</ItemGroup>
96+
<ItemGroup>
97+
<Page Update="Pages\ExistingUI.xaml">
98+
<Generator>MSBuild:Compile</Generator>
99+
</Page>
100+
</ItemGroup>
45101

46102
<!--
47103
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution

src/modules/keyboardmanager/KeyboardManagerEditorUI/MainWindow.xaml

Lines changed: 58 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,91 +6,70 @@
66
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
77
xmlns:local="using:KeyboardManagerEditorUI"
88
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
xmlns:pages="using:KeyboardManagerEditorUI.Pages"
910
Title="KeyboardManagerEditorUI"
1011
mc:Ignorable="d">
1112

12-
<Grid Padding="16">
13-
<StackPanel>
14-
<TextBlock
15-
Margin="10"
16-
FontSize="24"
17-
Foreground="{ThemeResource TextFillColorPrimaryBrush}"
18-
Text="Remap keys" />
19-
20-
<TextBlock
21-
Margin="10"
22-
FontSize="16"
23-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
24-
Text="Select the key you want to change and then configure the key, shortcut or text you want it to send."
25-
TextWrapping="Wrap" />
13+
<Grid
14+
x:Name="LayoutRoot"
15+
HorizontalAlignment="Stretch"
16+
VerticalAlignment="Stretch"
17+
CornerRadius="4"
18+
RowSpacing="6">
19+
<Grid.RowDefinitions>
20+
<RowDefinition Height="32" />
21+
<RowDefinition Height="*" />
22+
</Grid.RowDefinitions>
2623

24+
<StackPanel
25+
Grid.ColumnSpan="2"
26+
Margin="16,8,8,8"
27+
VerticalAlignment="Top"
28+
Orientation="Horizontal">
29+
<Image Width="16" Source="ms-appx:///Assets/FluentIconsKeyboardManager.png" />
2730
<TextBlock
28-
Margin="10"
29-
FontSize="16"
30-
FontStyle="Italic"
31-
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
32-
Text="Example of a remapping: Select A and send &quot;Ctrl+C&quot;, &quot;A&quot; would be your &quot;Select&quot; and &quot;Ctrl+C&quot; would be your &quot;To send&quot; command."
33-
TextWrapping="Wrap" />
34-
35-
<Grid Margin="10">
36-
<Grid.ColumnDefinitions>
37-
<ColumnDefinition Width="240" />
38-
<ColumnDefinition Width="Auto" />
39-
<ColumnDefinition Width="240" />
40-
</Grid.ColumnDefinitions>
41-
<Grid.RowDefinitions>
42-
<RowDefinition Height="Auto" />
43-
<RowDefinition Height="Auto" />
44-
</Grid.RowDefinitions>
45-
<TextBlock
46-
Margin="0,12,0,0"
47-
FontSize="16"
48-
FontWeight="Bold"
49-
Text="Selected:" />
50-
<Grid Grid.Row="1" Margin="0,8,0,0">
51-
<StackPanel>
52-
<ToggleButton Click="Button_Click" Content="Select" />
53-
<ComboBox
54-
x:Name="keyComboBox"
55-
Width="250"
56-
PlaceholderText="select keys please" />
57-
</StackPanel>
58-
</Grid>
59-
60-
<TextBlock
61-
Grid.Row="1"
62-
Grid.Column="1"
63-
Margin="24,0,24,0"
64-
HorizontalAlignment="Center"
65-
VerticalAlignment="Center"
66-
FontFamily="{ThemeResource SymbolThemeFontFamily}"
67-
Text="&#xE0AB;" />
68-
69-
<TextBlock
70-
Grid.Column="2"
71-
Margin="0,12,0,0"
72-
FontSize="16"
73-
FontWeight="Bold"
74-
Text="To Send:" />
75-
<Grid
76-
Grid.Row="1"
77-
Grid.Column="2"
78-
Margin="0,8,0,0">
79-
<StackPanel>
80-
<ToggleButton Click="Button_Click" Content="Click to select" />
81-
<ComboBox
82-
x:Name="newKeyComboBox"
83-
Width="250"
84-
PlaceholderText="select keys please" />
85-
</StackPanel>
86-
</Grid>
87-
</Grid>
88-
<Button
89-
Margin="10"
90-
Content="+ Add Key Remapping"
91-
Style="{StaticResource AccentButtonStyle}" />
92-
31+
Margin="12,0,0,0"
32+
Style="{StaticResource CaptionTextBlockStyle}"
33+
Text="Keyboard Manager" />
9334
</StackPanel>
9435

36+
<NavigationView
37+
x:Name="RootView"
38+
Grid.RowSpan="2"
39+
Margin="0,32,0,0"
40+
IsBackButtonVisible="Collapsed"
41+
IsBackEnabled="False"
42+
IsPaneToggleButtonVisible="False"
43+
IsTitleBarAutoPaddingEnabled="True"
44+
OpenPaneLength="240"
45+
PaneDisplayMode="Top"
46+
SelectionChanged="RootView_SelectionChanged">
47+
<NavigationView.MenuItems>
48+
<NavigationViewItem Content="Remappings" Tag="Remappings">
49+
<NavigationViewItem.Icon>
50+
<FontIcon Glyph="&#xEDA7;" />
51+
</NavigationViewItem.Icon>
52+
</NavigationViewItem>
53+
<NavigationViewItem Content="Programs" Tag="Programs">
54+
<NavigationViewItem.Icon>
55+
<FontIcon Glyph="&#xECAA;" />
56+
</NavigationViewItem.Icon>
57+
</NavigationViewItem>
58+
<NavigationViewItem Content="Text" Tag="Text">
59+
<NavigationViewItem.Icon>
60+
<FontIcon Glyph="&#xE8D2;" />
61+
</NavigationViewItem.Icon>
62+
</NavigationViewItem>
63+
<NavigationViewItem Content="URLs" Tag="URLs">
64+
<NavigationViewItem.Icon>
65+
<FontIcon Glyph="&#xE8A7;" />
66+
</NavigationViewItem.Icon>
67+
</NavigationViewItem>
68+
</NavigationView.MenuItems>
69+
<NavigationView.Content>
70+
<Frame x:Name="NavigationFrame" Margin="0,0,0,0" />
71+
</NavigationView.Content>
72+
</NavigationView>
9573
</Grid>
74+
9675
</Window>

0 commit comments

Comments
 (0)