Skip to content

Commit c81a423

Browse files
committed
Push
1 parent 7a6189b commit c81a423

File tree

8 files changed

+127
-9
lines changed

8 files changed

+127
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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.Runtime.InteropServices;
8+
9+
namespace ShortcutGuide.Helpers
10+
{
11+
internal sealed class TaskListPositions
12+
{
13+
public static List<RECT> GetTaskbarIconPositions()
14+
{
15+
throw new NotImplementedException();
16+
}
17+
18+
[StructLayout(LayoutKind.Sequential)]
19+
public struct RECT
20+
{
21+
public int Left;
22+
public int Top;
23+
public int Right;
24+
public int Bottom;
25+
}
26+
}
27+
}

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/Models/Shortcut.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using Microsoft.UI.Xaml;
66
using Microsoft.UI.Xaml.Controls;
77
using Microsoft.UI.Xaml.Markup;
8+
using Windows.Security.Cryptography.Certificates;
9+
using YamlDotNet.Core.Tokens;
810

911
namespace ShortcutGuide.Models
1012
{
@@ -26,6 +28,11 @@ public static implicit operator ShortcutTemplateDataObject(Shortcut shortcut)
2628

2729
shortcutStackPanel.Orientation = Orientation.Horizontal;
2830

31+
if (shortcut.Ctrl == false && shortcut.Alt == false && shortcut.Shift == false && shortcut.Win == false && shortcut.Keys.Length == 0)
32+
{
33+
return new ShortcutTemplateDataObject(shortcut.Name, shortcut.Description ?? string.Empty, shortcutStackPanel);
34+
}
35+
2936
void AddNewTextToStackPanel(string text)
3037
{
3138
shortcutStackPanel.Children.Add(new TextBlock { Text = text, Margin = new Thickness(3), VerticalAlignment = VerticalAlignment.Center });
@@ -69,6 +76,21 @@ void AddNewTextToStackPanel(string text)
6976
case "<Office>":
7077
shortcutStackPanel.Children.Add(new BitmapIcon() { UriSource = new("ms-appx:///Assets/ShortcutGuide/OfficeKey.png"), Height = 20, Width = 20 });
7178
break;
79+
case "<Left>":
80+
AddNewTextToStackPanel("←");
81+
break;
82+
case "<Right>":
83+
AddNewTextToStackPanel("→");
84+
break;
85+
case "<Up>":
86+
AddNewTextToStackPanel("↑");
87+
break;
88+
case "<Down>":
89+
AddNewTextToStackPanel("↓");
90+
break;
91+
case string name when name.StartsWith('<'):
92+
AddNewTextToStackPanel(key.Replace("<", string.Empty).Replace(">", string.Empty));
93+
break;
7294
default:
7395
AddNewTextToStackPanel(key);
7496
break;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
7+
namespace ShortcutGuide.Models
8+
{
9+
internal struct ShortcutPageParameters
10+
{
11+
public static SeachFilterObservable SearchFilter = new();
12+
}
13+
14+
internal sealed class SeachFilterObservable
15+
{
16+
public event EventHandler<string>? FilterChanged;
17+
18+
public void OnFilterChanged(string filter)
19+
{
20+
FilterChanged?.Invoke(this, filter);
21+
}
22+
}
23+
}

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/NativeMethods.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ internal static class NativeMethods
2222
[DllImport("user32.dll")]
2323
internal static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
2424

25+
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
26+
internal static extern int FindWindowA(in string lpClassName, in string? lpWindowName);
27+
28+
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
29+
internal static extern int FindWindowExA(int hwndParent, int hwndChildAfter, in string lpClassName, in string? lpWindowName);
30+
2531
internal const int GWL_STYLE = -16;
2632
internal const int WS_CAPTION = 0x00C00000;
2733
}

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</SelectorBarItem.Icon>
3434
</SelectorBarItem>
3535
</SelectorBar>
36-
<TextBox Grid.Column="1" Grid.Row="0" Height="32" Width="300" HorizontalAlignment="Right" VerticalContentAlignment="Center" HorizontalContentAlignment="Right"></TextBox>
36+
<TextBox Grid.Column="1" Grid.Row="0" Height="32" Width="300" HorizontalAlignment="Right" VerticalContentAlignment="Center" x:Name="SearchBox" HorizontalContentAlignment="Right" TextChanged="SearchBox_TextChanged"></TextBox>
3737
<Button Grid.Column="2" Grid.Row="0" HorizontalContentAlignment="Center">
3838
<FontIcon FontFamily="Segoe MDL2 Assets" Glyph="&#xE713;" />
3939
</Button>

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/MainWindow.xaml.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66
using System.Globalization;
77
using System.Runtime.InteropServices;
88
using Microsoft.UI;
9-
using Microsoft.UI.Input;
109
using Microsoft.UI.Windowing;
1110
using Microsoft.UI.Xaml;
1211
using Microsoft.UI.Xaml.Controls;
1312
using ShortcutGuide.Models;
1413
using ShortcutGuide.Properties;
15-
using Windows.ApplicationModel.Chat;
16-
using Windows.Devices.Display;
1714
using Windows.Foundation;
1815
using Windows.Graphics;
19-
using Windows.System.UserProfile;
2016
using WinUIEx;
21-
2217
using static NativeMethods;
2318

2419
namespace ShortcutGuide
@@ -33,6 +28,7 @@ public sealed partial class MainWindow : WindowEx
3328
public MainWindow()
3429
{
3530
InitializeComponent();
31+
3632
Title = Resource.ResourceManager.GetString("Title", CultureInfo.InvariantCulture)!;
3733

3834
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
@@ -109,5 +105,10 @@ public void CloseButton_Clicked(object sender, RoutedEventArgs e)
109105
{
110106
Environment.Exit(0);
111107
}
108+
109+
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
110+
{
111+
ShortcutPageParameters.SearchFilter.OnFilterChanged(SearchBox.Text);
112+
}
112113
}
113114
}

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<RowDefinition Height="Auto" />
2121
<RowDefinition Height="*" />
2222
</Grid.RowDefinitions>
23-
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Padding="6,0,6,0" Margin="6,6,6,6" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" Text="{x:Bind Name}" />
23+
<TextBlock Style="{StaticResource BodyStrongTextBlockStyle}" Padding="6,0,6,0" Margin="6,0,6,0" VerticalAlignment="Center" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" Text="{x:Bind Name}" />
2424
<Border CornerRadius="{StaticResource ControlCornerRadius}" BorderThickness="{StaticResource ButtonBorderThemeThickness}" Grid.Row="0" Grid.Column="1" Margin="20,6,6,6" HorizontalAlignment="Right" Background="White" >
2525
<ContentPresenter Content="{x:Bind Shortcut}" Padding="6,6,6,6" HorizontalAlignment="Right" />
2626
</Border>
@@ -39,7 +39,7 @@
3939
<GridView.ItemsPanel>
4040
<ItemsPanelTemplate>
4141
<ItemsWrapGrid x:Name="MaxItemsWrapGrid"
42-
Orientation="Horizontal"/>
42+
Orientation="Vertical"/>
4343
</ItemsPanelTemplate>
4444
</GridView.ItemsPanel>
4545
</GridView>

src/modules/ShortcutGuideV2/ShortcutGuide.Ui/ShortcutGuideXAML/ShortcutView.xaml.cs

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
// The Microsoft Corporation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
56
using System.Globalization;
67
using Microsoft.UI.Xaml.Controls;
8+
using Microsoft.UI.Xaml.Navigation;
79
using ShortcutGuide.Models;
10+
using Windows.ApplicationModel.ConversationalAgent;
11+
using Windows.Storage;
812

913
namespace ShortcutGuide
1014
{
@@ -22,7 +26,18 @@ public ShortcutView()
2226
int i = 0;
2327
foreach (var category in shortcutList.Shortcuts)
2428
{
25-
CategorySelector.Items.Add(new SelectorBarItem() { Text = category.SectionName, Name = i.ToString(CultureInfo.InvariantCulture) });
29+
switch (category.SectionName)
30+
{
31+
case string name when name.StartsWith("<TASKBAR1-9>", System.StringComparison.Ordinal):
32+
// Todo: Implement GetTaskbarIconPositions
33+
break;
34+
case string name when name.StartsWith('<'):
35+
break;
36+
default:
37+
CategorySelector.Items.Add(new SelectorBarItem() { Text = category.SectionName, Name = i.ToString(CultureInfo.InvariantCulture) });
38+
break;
39+
}
40+
2641
i++;
2742
}
2843

@@ -33,6 +48,30 @@ public ShortcutView()
3348
{
3449
ShortcutListElement.Items.Add((ShortcutTemplateDataObject)shortcut);
3550
}
51+
52+
ShortcutPageParameters.SearchFilter.FilterChanged += SearchFilter_FilterChanged;
53+
}
54+
55+
private void SearchFilter_FilterChanged(object? sender, string e)
56+
{
57+
FilterBy(e);
58+
}
59+
60+
public void FilterBy(string filter)
61+
{
62+
ShortcutListElement.Items.Clear();
63+
foreach (var shortcut in shortcutList.Shortcuts[int.Parse(CategorySelector.SelectedItem.Name, CultureInfo.InvariantCulture)].Properties)
64+
{
65+
if (shortcut.Name.Contains(filter, System.StringComparison.OrdinalIgnoreCase))
66+
{
67+
ShortcutListElement.Items.Add((ShortcutTemplateDataObject)shortcut);
68+
}
69+
}
70+
71+
if (ShortcutListElement.Items.Count == 0)
72+
{
73+
ShortcutListElement.Items.Add(new ShortcutTemplateDataObject("No search results found", string.Empty, new StackPanel() { Visibility = Microsoft.UI.Xaml.Visibility.Collapsed }));
74+
}
3675
}
3776

3877
public void CategorySelector_SelectionChanged(SelectorBar sender, SelectorBarSelectionChangedEventArgs e)

0 commit comments

Comments
 (0)