mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-22 01:58:04 +00:00
Add support for multiple shortcuts
This commit is contained in:
parent
6b8a3e65f7
commit
44d12c6e63
@ -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);
|
||||
}
|
||||
|
@ -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(@"<PathIcon xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Data=""M683 1229H0V546h683v683zm819 0H819V546h683v683zm-819 819H0v-683h683v683zm819 0H819v-683h683v683z"" />") 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 "<Copilot>":
|
||||
shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/CopilotKey.png") });
|
||||
break;
|
||||
case "<Office>":
|
||||
shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/OfficeKey.png"), Height = 20, Width = 20 });
|
||||
break;
|
||||
case "<Left>":
|
||||
AddNewTextToStackPanel("←");
|
||||
break;
|
||||
case "<Right>":
|
||||
AddNewTextToStackPanel("→");
|
||||
break;
|
||||
case "<Up>":
|
||||
AddNewTextToStackPanel("↑");
|
||||
break;
|
||||
case "<Down>":
|
||||
AddNewTextToStackPanel("↓");
|
||||
break;
|
||||
case "<Underlined letter>":
|
||||
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 "<Arrow>":
|
||||
TextBlock arrowTextBlock = new()
|
||||
{
|
||||
Text = "→",
|
||||
Margin = new Thickness(3),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
|
||||
shortcutStackPanel.Children.Add(arrowTextBlock);
|
||||
|
||||
AnimateTextBlock(arrowTextBlock, "→↓←↑", 1000);
|
||||
break;
|
||||
case "<ArrowLR>":
|
||||
TextBlock arrowLRTextBlock = new()
|
||||
{
|
||||
Text = "→",
|
||||
Margin = new Thickness(3),
|
||||
FontFamily = new("Courier New"),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
shortcutStackPanel.Children.Add(arrowLRTextBlock);
|
||||
AnimateTextBlock(arrowLRTextBlock, "→←", 1000);
|
||||
break;
|
||||
case "<ArrowUD>":
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -8,6 +8,6 @@ namespace ShortcutGuide.Models
|
||||
{
|
||||
public string SectionName { get; set; }
|
||||
|
||||
public Shortcut[] Properties { get; set; }
|
||||
public ShortcutEntry[] Properties { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -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<StackPanel> 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(@"<PathIcon xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" Data=""M683 1229H0V546h683v683zm819 0H819V546h683v683zm-819 819H0v-683h683v683zm819 0H819v-683h683v683z"" />") 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 "<Copilot>":
|
||||
shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/CopilotKey.png") });
|
||||
break;
|
||||
case "<Office>":
|
||||
shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/OfficeKey.png"), Height = 20, Width = 20 });
|
||||
break;
|
||||
case "<Left>":
|
||||
AddNewTextToStackPanel("←");
|
||||
break;
|
||||
case "<Right>":
|
||||
AddNewTextToStackPanel("→");
|
||||
break;
|
||||
case "<Up>":
|
||||
AddNewTextToStackPanel("↑");
|
||||
break;
|
||||
case "<Down>":
|
||||
AddNewTextToStackPanel("↓");
|
||||
break;
|
||||
case "<Underlined letter>":
|
||||
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 "<Arrow>":
|
||||
TextBlock arrowTextBlock = new()
|
||||
{
|
||||
Text = "→",
|
||||
Margin = new Thickness(3),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
|
||||
shortcutStackPanel.Children.Add(arrowTextBlock);
|
||||
|
||||
AnimateTextBlock(arrowTextBlock, "→↓←↑", 1000);
|
||||
break;
|
||||
case "<ArrowLR>":
|
||||
TextBlock arrowLRTextBlock = new()
|
||||
{
|
||||
Text = "→",
|
||||
Margin = new Thickness(3),
|
||||
FontFamily = new("Courier New"),
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
shortcutStackPanel.Children.Add(arrowLRTextBlock);
|
||||
AnimateTextBlock(arrowLRTextBlock, "→←", 1000);
|
||||
break;
|
||||
case "<ArrowUD>":
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ namespace ShortcutGuide.Models
|
||||
{
|
||||
public static SeachFilterObservable SearchFilter = new();
|
||||
|
||||
public static Dictionary<string, List<Shortcut>> PinnedShortcuts = [];
|
||||
public static Dictionary<string, List<ShortcutEntry>> PinnedShortcuts = [];
|
||||
|
||||
public static string CurrentPageName = string.Empty;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,11 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\Hosts\AppList.scale-100.png" />
|
||||
<None Remove="Assets\Hosts\AppList.scale-125.png" />
|
||||
<None Remove="Assets\Hosts\AppList.scale-150.png" />
|
||||
<None Remove="Assets\Hosts\AppList.scale-200.png" />
|
||||
<None Remove="Assets\Hosts\AppList.scale-400.png" />
|
||||
<None Remove="Assets\ShortcutGuide\AppList.scale-100.png" />
|
||||
<None Remove="Assets\ShortcutGuide\AppList.scale-125.png" />
|
||||
<None Remove="Assets\ShortcutGuide\AppList.scale-150.png" />
|
||||
<None Remove="Assets\ShortcutGuide\AppList.scale-200.png" />
|
||||
<None Remove="Assets\ShortcutGuide\AppList.scale-400.png" />
|
||||
<None Remove="ShortcutGuideXAML\ShortcutView.xaml" />
|
||||
<None Include="Assets\ShortcutGuide\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
@ -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<Dictionary<string, List<Shortcut>>>(File.ReadAllText(pinnedPath))!;
|
||||
ShortcutPageParameters.PinnedShortcuts = JsonSerializer.Deserialize<Dictionary<string, List<ShortcutEntry>>>(File.ReadAllText(pinnedPath))!;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -11,27 +11,27 @@
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<Page.Resources>
|
||||
<DataTemplate x:Key="ShortcutTemplate" x:DataType="local:ShortcutTemplateDataObject">
|
||||
<Grid MinWidth="300">
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout Opening="MenuFlyout_Opening">
|
||||
<MenuFlyoutItem Text="Pin" Click="PinShortcut"/>
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Padding="6,0,6,0" Margin="6,0,6,0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="0" Text="{x:Bind Name}" />
|
||||
<Border CornerRadius="{StaticResource ControlCornerRadius}" BorderThickness="{StaticResource ButtonBorderThemeThickness}" Grid.Row="1" Grid.Column="1" Margin="20,6,6,6" HorizontalAlignment="Right" Background="White" >
|
||||
<ContentPresenter Content="{x:Bind Shortcut}" Padding="6,6,6,6" HorizontalAlignment="Right" />
|
||||
</Border>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="6,0,6,0" Padding="6,0,6,0" Text="{x:Bind Description}" />
|
||||
</Grid>
|
||||
<Grid HorizontalAlignment="Left" MinWidth="400">
|
||||
<Grid.ContextFlyout>
|
||||
<MenuFlyout Opening="MenuFlyout_Opening">
|
||||
<MenuFlyoutItem Text="Pin" Click="PinShortcut"/>
|
||||
</MenuFlyout>
|
||||
</Grid.ContextFlyout>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Padding="6,0,6,0" Margin="6,0,6,0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="0" Text="{x:Bind Name}" />
|
||||
<Border CornerRadius="{StaticResource ControlCornerRadius}" BorderThickness="{StaticResource ButtonBorderThemeThickness}" Grid.Row="1" Grid.Column="1" Margin="20,6,6,6" HorizontalAlignment="Right" Background="White" >
|
||||
<ContentPresenter Content="{x:Bind Shortcut}" Padding="6,6,6,6" HorizontalAlignment="Stretch" />
|
||||
</Border>
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Margin="6,0,6,0" Padding="6,0,6,0" Text="{x:Bind Description}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
<Grid>
|
||||
@ -69,10 +69,10 @@
|
||||
</GridView>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<GridView Height="{Binding ContentHeight}" SelectionMode="None" x:Name="ShortcutListElement" Grid.Row="1" ItemTemplate="{StaticResource ShortcutTemplate}">
|
||||
<GridView HorizontalContentAlignment="Left" HorizontalAlignment="Left" Height="{Binding ContentHeight}" SelectionMode="None" x:Name="ShortcutListElement" Grid.Row="1" ItemTemplate="{StaticResource ShortcutTemplate}">
|
||||
<GridView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ItemsWrapGrid x:Name="MaxItemsWrapGrid" Orientation="Vertical"/>
|
||||
<ItemsWrapGrid HorizontalAlignment="Left" x:Name="MaxItemsWrapGrid" Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</GridView.ItemsPanel>
|
||||
</GridView>
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user