diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ManifestInterpreter.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ManifestInterpreter.cs index d5646884e1..a01204748c 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ManifestInterpreter.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ManifestInterpreter.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; +using System.Globalization; using System.IO; using System.Linq; using System.Text.RegularExpressions; @@ -50,6 +51,8 @@ namespace ShortcutGuide static bool IsMatch(string input, string filter) { + input = input.ToLower(CultureInfo.InvariantCulture); + filter = filter.ToLower(CultureInfo.InvariantCulture); string regexPattern = "^" + Regex.Escape(filter).Replace("\\*", ".*") + "$"; return Regex.IsMatch(input, regexPattern); } diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/Shortcut.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/Shortcut.cs deleted file mode 100644 index b70d6054cf..0000000000 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/Shortcut.cs +++ /dev/null @@ -1,201 +0,0 @@ -// 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 System.Threading.Tasks; -using Microsoft.PowerToys.Settings.UI.Library.Utilities; -using Microsoft.UI.Xaml; -using Microsoft.UI.Xaml.Controls; -using Microsoft.UI.Xaml.Markup; - -namespace ShortcutGuide.Models -{ - public class Shortcut(string name, string? description, bool recommended, bool ctrl, bool shift, bool alt, bool win, string[] keys) - { - public Shortcut() - : this(string.Empty, string.Empty, false, false, false, false, false, []) - { - } - - [JsonPropertyName(nameof(Name))] - public string Name { get; set; } = name; - - [JsonPropertyName(nameof(Description))] - public string? Description { get; set; } = description; - - [JsonPropertyName(nameof(Recommended))] - public bool Recommended { get; set; } = recommended; - - [JsonPropertyName(nameof(Ctrl))] - public bool Ctrl { get; set; } = ctrl; - - [JsonPropertyName(nameof(Shift))] - public bool Shift { get; set; } = shift; - - [JsonPropertyName(nameof(Alt))] - public bool Alt { get; set; } = alt; - - [JsonPropertyName(nameof(Win))] - public bool Win { get; set; } = win; - - [JsonPropertyName(nameof(Keys))] - public string[] Keys { get; set; } = keys; - - public static implicit operator ShortcutTemplateDataObject(Shortcut shortcut) - { - StackPanel shortcutStackPanel = new(); - - shortcutStackPanel.Orientation = Orientation.Horizontal; - - if (shortcut.Ctrl == false && shortcut.Alt == false && shortcut.Shift == false && shortcut.Win == false && shortcut.Keys.Length == 0) - { - return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, shortcutStackPanel, shortcut); - } - - void AddNewTextToStackPanel(string text) - { - shortcutStackPanel.Children.Add(new TextBlock { Text = text, Margin = new Thickness(3), VerticalAlignment = VerticalAlignment.Center }); - } - - async void AnimateTextBlock(TextBlock animatedTextBlock, string text, int delay = 500) - { - int index = 0; - - while (true) - { - animatedTextBlock.Text = text[index].ToString(); - index = (index + 1) % text.Length; - await Task.Delay(delay); - } - } - - if (shortcut.Win) - { - PathIcon winIcon = (XamlReader.Load(@"") as PathIcon)!; - Viewbox winIconContainer = new(); - winIconContainer.Child = winIcon; - winIconContainer.HorizontalAlignment = HorizontalAlignment.Center; - winIconContainer.VerticalAlignment = VerticalAlignment.Center; - winIconContainer.Height = 24; - winIconContainer.Width = 24; - winIconContainer.Margin = new Thickness(3); - shortcutStackPanel.Children.Add(winIconContainer); - } - - if (shortcut.Ctrl) - { - AddNewTextToStackPanel("Ctrl"); - } - - if (shortcut.Alt) - { - AddNewTextToStackPanel("Alt"); - } - - if (shortcut.Shift) - { - AddNewTextToStackPanel("Shift"); - } - - foreach (object key in shortcut.Keys) - { - switch (key) - { - case "": - shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/CopilotKey.png") }); - break; - case "": - shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/OfficeKey.png"), Height = 20, Width = 20 }); - break; - case "": - AddNewTextToStackPanel("←"); - break; - case "": - AddNewTextToStackPanel("→"); - break; - case "": - AddNewTextToStackPanel("↑"); - break; - case "": - AddNewTextToStackPanel("↓"); - break; - case "": - TextBlock animatedTextBlock = new() - { - Text = "A", - Margin = new Thickness(3), - VerticalAlignment = VerticalAlignment.Center, - - // Use monospaced font to ensure the text doesn't move - FontFamily = new("Courier New"), - TextDecorations = Windows.UI.Text.TextDecorations.Underline, - }; - - shortcutStackPanel.Children.Add(animatedTextBlock); - - AnimateTextBlock(animatedTextBlock, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); - break; - case "": - TextBlock arrowTextBlock = new() - { - Text = "→", - Margin = new Thickness(3), - VerticalAlignment = VerticalAlignment.Center, - }; - - shortcutStackPanel.Children.Add(arrowTextBlock); - - AnimateTextBlock(arrowTextBlock, "→↓←↑", 1000); - break; - case "": - TextBlock arrowLRTextBlock = new() - { - Text = "→", - Margin = new Thickness(3), - FontFamily = new("Courier New"), - VerticalAlignment = VerticalAlignment.Center, - }; - shortcutStackPanel.Children.Add(arrowLRTextBlock); - AnimateTextBlock(arrowLRTextBlock, "→←", 1000); - break; - case "": - TextBlock arrowUDTextBlock = new() - { - Text = "↑", - Margin = new Thickness(3), - FontFamily = new("Courier New"), - VerticalAlignment = VerticalAlignment.Center, - }; - shortcutStackPanel.Children.Add(arrowUDTextBlock); - AnimateTextBlock(arrowUDTextBlock, "↑↓", 1000); - break; - case string name when name.StartsWith('<') && name.EndsWith('>'): - AddNewTextToStackPanel(name[1..^1]); - break; - case int num: - if (num == 0) - { - break; - } - - AddNewTextToStackPanel(Helper.GetKeyName((uint)num)); - break; - case string num when int.TryParse(num, out int parsedNum): - if (parsedNum == 0) - { - break; - } - - AddNewTextToStackPanel(Helper.GetKeyName((uint)parsedNum)); - break; - default: - AddNewTextToStackPanel((string)key); - break; - } - } - - return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, shortcutStackPanel, shortcut); - } - } -} diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutCategory.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutCategory.cs index 553c4b5846..0dcd3d1323 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutCategory.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutCategory.cs @@ -8,6 +8,6 @@ namespace ShortcutGuide.Models { public string SectionName { get; set; } - public Shortcut[] Properties { get; set; } + public ShortcutEntry[] Properties { get; set; } } } diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs new file mode 100644 index 0000000000..4f14835143 --- /dev/null +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutEntry.cs @@ -0,0 +1,280 @@ +// 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.Runtime.CompilerServices; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using Microsoft.PowerToys.Settings.UI.Library.Utilities; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Markup; +using ShortcutGuide; +using Windows.UI.Text; +using static ShortcutGuide.Models.ShortcutEntry; + +namespace ShortcutGuide.Models +{ + public class ShortcutEntry(string name, string? description, bool recommended, ShortcutDescription[] shortcutDescriptions) + { + public ShortcutEntry() + : this(string.Empty, string.Empty, false, []) + { + } + + [JsonPropertyName(nameof(Name))] + public string Name { get; set; } = name; + + [JsonPropertyName(nameof(Description))] + public string? Description { get; set; } = description; + + [JsonPropertyName(nameof(Recommended))] + public bool Recommended { get; set; } = recommended; + + [JsonPropertyName(nameof(Shortcut))] + public ShortcutDescription[] Shortcut { get; set; } = shortcutDescriptions; + + public class ShortcutDescription(bool ctrl, bool shift, bool alt, bool win, string[] keys) + { + public ShortcutDescription() + : this(false, false, false, false, []) + { + } + + [JsonPropertyName(nameof(Ctrl))] + public bool Ctrl { get; set; } = ctrl; + + [JsonPropertyName(nameof(Shift))] + public bool Shift { get; set; } = shift; + + [JsonPropertyName(nameof(Alt))] + public bool Alt { get; set; } = alt; + + [JsonPropertyName(nameof(Win))] + public bool Win { get; set; } = win; + + [JsonPropertyName(nameof(Keys))] + public string[] Keys { get; set; } = keys; + } + + public static implicit operator ShortcutTemplateDataObject(ShortcutEntry shortcut) + { + List shortcutStackPanels = []; + + async void AnimateTextBlock(TextBlock animatedTextBlock, string text, int delay = 500) + { + int index = 0; + + while (true) + { + animatedTextBlock.Text = text[index].ToString(); + index = (index + 1) % text.Length; + await Task.Delay(delay); + } + } + + for (int i = 0; i < shortcut.Shortcut.Length; i++) + { + ShortcutDescription shortcutEntry = shortcut.Shortcut[i]; + StackPanel shortcutStackPanel = new(); + shortcutStackPanels.Add(shortcutStackPanel); + shortcutStackPanel.Orientation = Orientation.Horizontal; + + // If any entry is blank, we skip the whole shortcut + if (!shortcutEntry.Ctrl && !shortcutEntry.Alt && !shortcutEntry.Shift && !shortcutEntry.Win && shortcutEntry.Keys.Length == 0) + { + return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, shortcutStackPanel, shortcut); + } + + if (shortcut.Shortcut.Length > 1) + { + TextBlock shortcutIndexTextBlock = new() + { + Text = $"{i + 1}.", + Margin = new Thickness(3), + VerticalAlignment = VerticalAlignment.Center, + FontWeight = new FontWeight { Weight = 600 }, + }; + shortcutStackPanel.Children.Add(shortcutIndexTextBlock); + } + + void AddNewTextToStackPanel(string text) + { + shortcutStackPanel.Children.Add(new TextBlock { Text = text, Margin = new Thickness(3), VerticalAlignment = VerticalAlignment.Center }); + } + + if (shortcutEntry.Win) + { + PathIcon winIcon = (XamlReader.Load(@"") as PathIcon)!; + Viewbox winIconContainer = new(); + winIconContainer.Child = winIcon; + winIconContainer.HorizontalAlignment = HorizontalAlignment.Center; + winIconContainer.VerticalAlignment = VerticalAlignment.Center; + winIconContainer.Height = 24; + winIconContainer.Width = 24; + winIconContainer.Margin = new Thickness(3); + shortcutStackPanel.Children.Add(winIconContainer); + } + + if (shortcutEntry.Ctrl) + { + AddNewTextToStackPanel("Ctrl"); + } + + if (shortcutEntry.Alt) + { + AddNewTextToStackPanel("Alt"); + } + + if (shortcutEntry.Shift) + { + AddNewTextToStackPanel("Shift"); + } + + foreach (object key in shortcutEntry.Keys) + { + switch (key) + { + case "": + shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/CopilotKey.png") }); + break; + case "": + shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/OfficeKey.png"), Height = 20, Width = 20 }); + break; + case "": + AddNewTextToStackPanel("←"); + break; + case "": + AddNewTextToStackPanel("→"); + break; + case "": + AddNewTextToStackPanel("↑"); + break; + case "": + AddNewTextToStackPanel("↓"); + break; + case "": + TextBlock animatedTextBlock = new() + { + Text = "A", + Margin = new Thickness(3), + VerticalAlignment = VerticalAlignment.Center, + + // Use monospaced font to ensure the text doesn't move + FontFamily = new("Courier New"), + TextDecorations = Windows.UI.Text.TextDecorations.Underline, + }; + + shortcutStackPanel.Children.Add(animatedTextBlock); + + AnimateTextBlock(animatedTextBlock, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"); + break; + case "": + TextBlock arrowTextBlock = new() + { + Text = "→", + Margin = new Thickness(3), + VerticalAlignment = VerticalAlignment.Center, + }; + + shortcutStackPanel.Children.Add(arrowTextBlock); + + AnimateTextBlock(arrowTextBlock, "→↓←↑", 1000); + break; + case "": + TextBlock arrowLRTextBlock = new() + { + Text = "→", + Margin = new Thickness(3), + FontFamily = new("Courier New"), + VerticalAlignment = VerticalAlignment.Center, + }; + shortcutStackPanel.Children.Add(arrowLRTextBlock); + AnimateTextBlock(arrowLRTextBlock, "→←", 1000); + break; + case "": + TextBlock arrowUDTextBlock = new() + { + Text = "↑", + Margin = new Thickness(3), + FontFamily = new("Courier New"), + VerticalAlignment = VerticalAlignment.Center, + }; + shortcutStackPanel.Children.Add(arrowUDTextBlock); + AnimateTextBlock(arrowUDTextBlock, "↑↓", 1000); + break; + case string name when name.StartsWith('<') && name.EndsWith('>'): + AddNewTextToStackPanel(name[1..^1]); + break; + case int num: + if (num == 0) + { + break; + } + + AddNewTextToStackPanel(Helper.GetKeyName((uint)num)); + break; + case string num when int.TryParse(num, out int parsedNum): + if (parsedNum == 0) + { + break; + } + + AddNewTextToStackPanel(Helper.GetKeyName((uint)parsedNum)); + break; + default: + AddNewTextToStackPanel((string)key); + break; + } + } + } + + StackPanel stackPanelToReturn = shortcutStackPanels[0]; + + if (shortcutStackPanels.Count == 0) + { + return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, new StackPanel(), shortcut); + } + else if (shortcutStackPanels.Count > 1) + { + stackPanelToReturn = new StackPanel(); + + stackPanelToReturn.Orientation = Orientation.Vertical; + foreach (StackPanel panel in shortcutStackPanels) + { + panel.Visibility = Visibility.Collapsed; + stackPanelToReturn.Children.Add(panel); + } + + shortcutStackPanels[0].Visibility = Visibility.Visible; + for (int i = 1; i < shortcutStackPanels.Count; i++) + { + shortcutStackPanels[i].Visibility = Visibility.Collapsed; + } + + async void AnimateStackPanels(StackPanel[] panels, int delay = 2000) + { + int index = 0; + while (true) + { + foreach (StackPanel panel in panels) + { + panel.Visibility = Visibility.Collapsed; + } + + panels[index].Visibility = Visibility.Visible; + index = (index + 1) % panels.Length; + await Task.Delay(delay); + } + } + + AnimateStackPanels([.. shortcutStackPanels]); + } + + return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, stackPanelToReturn, shortcut); + } + } +} diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutPageParameters.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutPageParameters.cs index ad687fefcb..99b4cd8a1e 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutPageParameters.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/ShortcutPageParameters.cs @@ -11,7 +11,7 @@ namespace ShortcutGuide.Models { public static SeachFilterObservable SearchFilter = new(); - public static Dictionary> PinnedShortcuts = []; + public static Dictionary> PinnedShortcuts = []; public static string CurrentPageName = string.Empty; diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/PowerToysShortcutsPopulator.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/PowerToysShortcutsPopulator.cs index a2197039ea..770d4b4a8c 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/PowerToysShortcutsPopulator.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/PowerToysShortcutsPopulator.cs @@ -56,17 +56,18 @@ namespace ShortcutGuide public static string HotkeySettingsToYaml(HotkeySettings hotkeySettings, string moduleName, string content, string? description = null) { content += " - Name: " + moduleName + Environment.NewLine; - content += " Win: " + hotkeySettings.Win.ToString() + Environment.NewLine; - content += " Ctrl: " + hotkeySettings.Ctrl.ToString() + Environment.NewLine; - content += " Alt: " + hotkeySettings.Alt.ToString() + Environment.NewLine; - content += " Shift: " + hotkeySettings.Shift.ToString() + Environment.NewLine; + content += " Shortcut: " + Environment.NewLine; + content += " - Win: " + hotkeySettings.Win.ToString() + Environment.NewLine; + content += " Ctrl: " + hotkeySettings.Ctrl.ToString() + Environment.NewLine; + content += " Alt: " + hotkeySettings.Alt.ToString() + Environment.NewLine; + content += " Shift: " + hotkeySettings.Shift.ToString() + Environment.NewLine; + content += " Keys:" + Environment.NewLine; + content += " - " + hotkeySettings.Code.ToString(CultureInfo.InvariantCulture) + Environment.NewLine; if (description != null) { content += " Description: " + description + Environment.NewLine; } - content += " Keys:" + Environment.NewLine; - content += " - " + hotkeySettings.Code.ToString(CultureInfo.InvariantCulture) + Environment.NewLine; return content; } diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj index f3a96e7c01..63d4ab0a61 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuide.Ui.csproj @@ -28,11 +28,11 @@ - - - - - + + + + + PreserveNewest diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs index 6cd65cbe2a..dfe7909d85 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs @@ -65,7 +65,7 @@ namespace ShortcutGuide if (settingsUtils.SettingsExists(ShortcutGuideSettings.ModuleName, "Pinned.json")) { string pinnedPath = settingsUtils.GetSettingsFilePath(ShortcutGuideSettings.ModuleName, "Pinned.json"); - ShortcutPageParameters.PinnedShortcuts = JsonSerializer.Deserialize>>(File.ReadAllText(pinnedPath))!; + ShortcutPageParameters.PinnedShortcuts = JsonSerializer.Deserialize>>(File.ReadAllText(pinnedPath))!; } } diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutTemplateDataObject.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutTemplateDataObject.cs index 57a2f6f5db..6186b71727 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutTemplateDataObject.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutTemplateDataObject.cs @@ -16,11 +16,11 @@ namespace ShortcutGuide public StackPanel Shortcut { get; set; } - public Shortcut OriginalShortcutObject { get; set; } + public ShortcutEntry OriginalShortcutObject { get; set; } public Visibility DescriptionVisible { get; set; } - public ShortcutTemplateDataObject(string name, string description, StackPanel shortcut, Shortcut originalShortcutObject) + public ShortcutTemplateDataObject(string name, string description, StackPanel shortcut, ShortcutEntry originalShortcutObject) { Name = name; Description = description; diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml index e5c36e295d..803178f318 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml @@ -11,27 +11,27 @@ Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + @@ -69,10 +69,10 @@ - + - + diff --git a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs index f1b8d1e6ce..785097a038 100644 --- a/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs +++ b/src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.IO; @@ -11,7 +12,10 @@ using System.Text.Json; using Microsoft.PowerToys.Settings.UI.Library; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Media; +using ShortcutGuide; using ShortcutGuide.Models; +using Windows.Foundation; namespace ShortcutGuide { @@ -142,9 +146,12 @@ namespace ShortcutGuide } } + private string _searchFilter = string.Empty; + private void SearchFilter_FilterChanged(object? sender, string e) { FilterBy(e); + _searchFilter = e; } public void FilterBy(string filter) @@ -214,6 +221,7 @@ namespace ShortcutGuide if (int.Parse(sender.SelectedItem.Name, CultureInfo.InvariantCulture) == -1) { OpenOverview(); + FilterBy(_searchFilter); return; } @@ -227,6 +235,8 @@ namespace ShortcutGuide ErrorMessage.Visibility = Visibility.Visible; ErrorMessage.Text = "Error displaying category"; } + + FilterBy(_searchFilter); } private void PinShortcut(object sender, RoutedEventArgs e) @@ -262,7 +272,7 @@ namespace ShortcutGuide return; } - Shortcut originalObject = dataObject.OriginalShortcutObject; + ShortcutEntry originalObject = dataObject.OriginalShortcutObject; bool isItemPinned = ShortcutPageParameters.PinnedShortcuts[ShortcutPageParameters.CurrentPageName].Contains(originalObject);