diff --git a/src/modules/ShortcutGuide/ShortcutGuide.Ui/Converters/ShortcutDescriptionToKeysConverter.cs b/src/modules/ShortcutGuide/ShortcutGuide.Ui/Converters/ShortcutDescriptionToKeysConverter.cs index a90ee31c40..38824b30bc 100644 --- a/src/modules/ShortcutGuide/ShortcutGuide.Ui/Converters/ShortcutDescriptionToKeysConverter.cs +++ b/src/modules/ShortcutGuide/ShortcutGuide.Ui/Converters/ShortcutDescriptionToKeysConverter.cs @@ -84,6 +84,9 @@ namespace ShortcutGuide.Converters case "Back": shortcutList.Add(8); // The Back key or button. break; + case "": + shortcutList.Add("Num"); + break; default: shortcutList.Add(key); // Add other keys as strings. break; diff --git a/src/modules/ShortcutGuide/ShortcutGuide.Ui/Helpers/StringResourceExtension.cs b/src/modules/ShortcutGuide/ShortcutGuide.Ui/Helpers/StringResourceExtension.cs new file mode 100644 index 0000000000..c25c18b527 --- /dev/null +++ b/src/modules/ShortcutGuide/ShortcutGuide.Ui/Helpers/StringResourceExtension.cs @@ -0,0 +1,30 @@ +// 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 Microsoft.UI.Xaml.Markup; + +namespace ShortcutGuide.Helpers +{ + [MarkupExtensionReturnType(ReturnType = typeof(string))] + public partial class StringResourceExtension : MarkupExtension + { + public enum SpecialTreatment + { + None, + FirstCharOnly, + EverythingExceptFirstChar, + } + + public string Key { get; set; } = string.Empty; + + public SpecialTreatment Treatment { get; set; } = SpecialTreatment.None; + + protected override object ProvideValue() => Treatment switch + { + SpecialTreatment.FirstCharOnly => ResourceLoaderInstance.ResourceLoader.GetString(Key)[0].ToString(), + SpecialTreatment.EverythingExceptFirstChar => ResourceLoaderInstance.ResourceLoader.GetString(Key)[1..], + _ => ResourceLoaderInstance.ResourceLoader.GetString(Key), + }; + } +} diff --git a/src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/Controls/KeyCharPresenter.xaml b/src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/Controls/KeyCharPresenter.xaml index 228276544d..0d962c3be8 100644 --- a/src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/Controls/KeyCharPresenter.xaml +++ b/src/modules/ShortcutGuide/ShortcutGuide.Ui/ShortcutGuideXAML/Controls/KeyCharPresenter.xaml @@ -3,10 +3,12 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:ShortcutGuide.Controls" + xmlns:helpers="using:ShortcutGuide.Helpers" xmlns:ui="using:CommunityToolkit.WinUI"> +