Skip to content

Commit 4070bc6

Browse files
vanzueniels9001
authored andcommitted
[ZoomIt] Show users full hotkey list in settings (#43073)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR enhances the ZoomIt settings UI by refactoring some of the XAML code and putting instructions as part of the settingsexpanders. Additionally, the alternate hotkey combinations are now shown too and will be updated based on the configured hotkey. so that **Users will now be able to see all the hotkeys**. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [x] Closes: #42236 - [ ] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed ### ZoomIt Extended (Derived) Hotkeys Feature | Base Key Property | Default Base Key | Derived Key Property | XOR Logic | Default Derived Key | Description -- | -- | -- | -- | -- | -- | -- LiveZoom | LiveZoomToggleKey | Ctrl+4 | LiveZoomToggleKeyDraw | XOR Shift | Ctrl+Shift+4 | Enter drawing mode in LiveZoom Record | RecordToggleKey | Ctrl+5 | RecordToggleKeyCrop | XOR Shift | Ctrl+Shift+5 | Record selected region (crop) Record | RecordToggleKey | Ctrl+5 | RecordToggleKeyWindow | XOR Alt | Ctrl+Alt+5 | Record specific window Snip | SnipToggleKey | Ctrl+6 | SnipToggleKeySave | XOR Shift | Ctrl+Shift+6 | Snip and save to file DemoType | DemoTypeToggleKey | Ctrl+7 | DemoTypeToggleKeyReset | XOR Shift | Ctrl+Shift+7 | Rewind to previous segment <img width="832" height="3679" alt="Frame 2018778631" src="https://github.com/user-attachments/assets/bebddcd8-d705-4582-ae8a-c847cb1c3e88" /> --------- Signed-off-by: check-spelling-bot <check-spelling-bot@users.noreply.github.com> Co-authored-by: Niels Laute <niels.laute@live.nl> Co-authored-by: Kai Tao <vanzue@users.noreply.github.com>
1 parent f5d0ae6 commit 4070bc6

File tree

9 files changed

+650
-313
lines changed

9 files changed

+650
-313
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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.Windows;
7+
using Microsoft.PowerToys.Settings.UI.Helpers;
8+
using Microsoft.PowerToys.Settings.UI.Library;
9+
using Microsoft.UI.Xaml.Data;
10+
using Microsoft.Windows.ApplicationModel.Resources;
11+
12+
namespace Microsoft.PowerToys.Settings.UI.Converters
13+
{
14+
public partial class HotkeySettingsToLocalizedStringConverter : IValueConverter
15+
{
16+
public object Convert(object value, Type targetType, object parameter, string language)
17+
{
18+
if (value is HotkeySettings keySettings && parameter is string resourceKey)
19+
{
20+
return string.Format(System.Globalization.CultureInfo.CurrentCulture, ResourceLoaderInstance.ResourceLoader.GetString(resourceKey), keySettings.ToString());
21+
}
22+
23+
return string.Empty;
24+
}
25+
26+
public object ConvertBack(object value, Type targetType, object parameter, string language)
27+
{
28+
throw new NotImplementedException();
29+
}
30+
}
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 Microsoft.UI.Xaml.Data;
7+
8+
namespace Microsoft.PowerToys.Settings.UI.Converters
9+
{
10+
public sealed partial class ZoomItOpacitySliderConverter : IValueConverter
11+
{
12+
public object Convert(object value, Type targetType, object parameter, string language)
13+
{
14+
// Slider value is 1-100, display as percentage
15+
int percentage = System.Convert.ToInt32((double)value);
16+
return $"{percentage}%";
17+
}
18+
19+
public object ConvertBack(object value, Type targetType, object parameter, string language)
20+
{
21+
throw new NotImplementedException();
22+
}
23+
}
24+
}

src/settings-ui/Settings.UI/PowerToys.Settings.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@
176176
<None Update="Assets\Settings\Scripts\DisableModule.ps1">
177177
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
178178
</None>
179+
<Page Update="SettingsXAML\Controls\ShortcutControl\ShortcutWithTextLabelControl.xaml">
180+
<Generator>MSBuild:Compile</Generator>
181+
</Page>
179182
<Page Update="SettingsXAML\Controls\TitleBar\TitleBar.xaml">
180183
<Generator>MSBuild:Compile</Generator>
181184
</Page>

src/settings-ui/Settings.UI/SettingsXAML/App.xaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
66
xmlns:converters="using:Microsoft.PowerToys.Settings.UI.Converters"
7+
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
78
xmlns:tkconverters="using:CommunityToolkit.WinUI.Converters">
89
<Application.Resources>
910
<ResourceDictionary>
@@ -18,7 +19,7 @@
1819
<ResourceDictionary Source="/SettingsXAML/Themes/Colors.xaml" />
1920
<ResourceDictionary Source="/SettingsXAML/Themes/Generic.xaml" />
2021
<ResourceDictionary Source="/SettingsXAML/Controls/Timeline/TimelineStyles.xaml" />
21-
22+
<ResourceDictionary Source="/SettingsXAML/Controls/ShortcutControl/ShortcutWithTextLabelControl.xaml" />
2223
<!-- Other merged dictionaries here -->
2324
</ResourceDictionary.MergedDictionaries>
2425

@@ -81,9 +82,6 @@
8182
<RepositionThemeTransition IsStaggeringEnabled="False" />
8283
<!-- Smoothly animates individual cards upon whenever Expanders are expanded/collapsed -->
8384
</TransitionCollection>
84-
85-
<!-- Additional resources or settings can be added here -->
86-
8785
</ResourceDictionary>
8886
</Application.Resources>
8987
</Application>
Lines changed: 64 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,67 @@
1-
<UserControl
2-
x:Class="Microsoft.PowerToys.Settings.UI.Controls.ShortcutWithTextLabelControl"
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<ResourceDictionary
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls"
6-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
7-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
8-
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls"
9-
d:DesignHeight="300"
10-
d:DesignWidth="400"
11-
mc:Ignorable="d">
5+
xmlns:local="using:Microsoft.PowerToys.Settings.UI.Controls"
6+
xmlns:tk="using:CommunityToolkit.WinUI"
7+
xmlns:tkcontrols="using:CommunityToolkit.WinUI.Controls">
128

13-
<Grid ColumnSpacing="8">
14-
<Grid.ColumnDefinitions>
15-
<ColumnDefinition Width="Auto" />
16-
<ColumnDefinition Width="*" />
17-
</Grid.ColumnDefinitions>
18-
<ItemsControl
19-
x:Name="ShortcutsControl"
20-
VerticalAlignment="Center"
21-
AutomationProperties.AccessibilityView="Raw"
22-
IsTabStop="False"
23-
ItemsSource="{x:Bind Keys}">
24-
<ItemsControl.ItemsPanel>
25-
<ItemsPanelTemplate>
26-
<StackPanel Orientation="Horizontal" Spacing="4" />
27-
</ItemsPanelTemplate>
28-
</ItemsControl.ItemsPanel>
29-
<ItemsControl.ItemTemplate>
30-
<DataTemplate>
31-
<controls:KeyVisual
32-
Padding="12,8,12,8"
33-
AutomationProperties.AccessibilityView="Raw"
34-
Content="{Binding}"
35-
FontSize="12"
36-
IsTabStop="False"
37-
Style="{StaticResource DefaultKeyVisualStyle}" />
38-
</DataTemplate>
39-
</ItemsControl.ItemTemplate>
40-
</ItemsControl>
41-
<tkcontrols:MarkdownTextBlock
42-
x:Name="LabelControl"
43-
Grid.Column="1"
44-
VerticalAlignment="Center"
45-
Text="{x:Bind Text}" />
46-
<VisualStateManager.VisualStateGroups>
47-
<VisualStateGroup x:Name="LabelPlacementStates">
48-
<VisualState x:Name="LabelAfter" />
49-
<VisualState x:Name="LabelBefore">
50-
<VisualState.Setters>
51-
<Setter Target="LabelControl.(Grid.Column)" Value="0" />
52-
<Setter Target="ShortcutsControl.(Grid.Column)" Value="1" />
53-
</VisualState.Setters>
54-
</VisualState>
55-
</VisualStateGroup>
56-
</VisualStateManager.VisualStateGroups>
57-
</Grid>
58-
</UserControl>
9+
<Style BasedOn="{StaticResource DefaultShortcutWithTextLabelControlStyle}" TargetType="local:ShortcutWithTextLabelControl" />
10+
11+
<Style x:Key="DefaultShortcutWithTextLabelControlStyle" TargetType="local:ShortcutWithTextLabelControl">
12+
<Setter Property="KeyVisualStyle" Value="{StaticResource DefaultKeyVisualStyle}" />
13+
<Setter Property="Template">
14+
<Setter.Value>
15+
<ControlTemplate TargetType="local:ShortcutWithTextLabelControl">
16+
<Grid ColumnSpacing="8">
17+
<Grid.ColumnDefinitions>
18+
<ColumnDefinition Width="Auto" />
19+
<ColumnDefinition Width="*" />
20+
</Grid.ColumnDefinitions>
21+
<ItemsControl
22+
x:Name="ShortcutsControl"
23+
VerticalAlignment="Bottom"
24+
AutomationProperties.AccessibilityView="Raw"
25+
IsTabStop="False"
26+
ItemsSource="{TemplateBinding Keys}">
27+
<ItemsControl.ItemsPanel>
28+
<ItemsPanelTemplate>
29+
<StackPanel Orientation="Horizontal" Spacing="4" />
30+
</ItemsPanelTemplate>
31+
</ItemsControl.ItemsPanel>
32+
<ItemsControl.ItemTemplate>
33+
<DataTemplate>
34+
<StackPanel Orientation="Vertical">
35+
<local:KeyVisual
36+
tk:FrameworkElementExtensions.AncestorType="local:ShortcutWithTextLabelControl"
37+
AutomationProperties.AccessibilityView="Raw"
38+
Content="{Binding}"
39+
IsTabStop="False"
40+
Style="{Binding (tk:FrameworkElementExtensions.Ancestor).KeyVisualStyle, RelativeSource={RelativeSource Self}}" />
41+
</StackPanel>
42+
</DataTemplate>
43+
</ItemsControl.ItemTemplate>
44+
</ItemsControl>
45+
<tkcontrols:MarkdownTextBlock
46+
x:Name="LabelControl"
47+
Grid.Column="1"
48+
VerticalAlignment="Center"
49+
Config="{TemplateBinding MarkdownConfig}"
50+
Text="{TemplateBinding Text}" />
51+
<VisualStateManager.VisualStateGroups>
52+
<VisualStateGroup x:Name="LabelPlacementStates">
53+
<VisualState x:Name="LabelAfter" />
54+
<VisualState x:Name="LabelBefore">
55+
<VisualState.Setters>
56+
<Setter Target="LabelControl.(Grid.Column)" Value="0" />
57+
<Setter Target="ShortcutsControl.(Grid.Column)" Value="1" />
58+
</VisualState.Setters>
59+
</VisualState>
60+
</VisualStateGroup>
61+
</VisualStateManager.VisualStateGroups>
62+
</Grid>
63+
</ControlTemplate>
64+
</Setter.Value>
65+
</Setter>
66+
</Style>
67+
</ResourceDictionary>
Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
// Copyright (c) Microsoft Corporation
1+
// Copyright (c) Microsoft Corporation
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

55
using System.Collections.Generic;
6-
6+
using CommunityToolkit.WinUI.Controls;
77
using Microsoft.UI.Xaml;
88
using Microsoft.UI.Xaml.Controls;
99

1010
namespace Microsoft.PowerToys.Settings.UI.Controls
1111
{
12-
public sealed partial class ShortcutWithTextLabelControl : UserControl
12+
public sealed partial class ShortcutWithTextLabelControl : Control
1313
{
1414
public string Text
1515
{
@@ -27,38 +27,59 @@ public List<object> Keys
2727

2828
public static readonly DependencyProperty KeysProperty = DependencyProperty.Register(nameof(Keys), typeof(List<object>), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(default(string)));
2929

30-
public LabelPlacement LabelPlacement
30+
public Placement LabelPlacement
3131
{
32-
get { return (LabelPlacement)GetValue(LabelPlacementProperty); }
32+
get { return (Placement)GetValue(LabelPlacementProperty); }
3333
set { SetValue(LabelPlacementProperty, value); }
3434
}
3535

36-
public static readonly DependencyProperty LabelPlacementProperty = DependencyProperty.Register(nameof(LabelPlacement), typeof(LabelPlacement), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(defaultValue: LabelPlacement.After, OnIsLabelPlacementChanged));
36+
public static readonly DependencyProperty LabelPlacementProperty = DependencyProperty.Register(nameof(LabelPlacement), typeof(Placement), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(defaultValue: Placement.After, OnIsLabelPlacementChanged));
37+
38+
public MarkdownConfig MarkdownConfig
39+
{
40+
get { return (MarkdownConfig)GetValue(MarkdownConfigProperty); }
41+
set { SetValue(MarkdownConfigProperty, value); }
42+
}
43+
44+
public static readonly DependencyProperty MarkdownConfigProperty = DependencyProperty.Register(nameof(MarkdownConfig), typeof(MarkdownConfig), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(new MarkdownConfig()));
45+
46+
public Style KeyVisualStyle
47+
{
48+
get { return (Style)GetValue(KeyVisualStyleProperty); }
49+
set { SetValue(KeyVisualStyleProperty, value); }
50+
}
51+
52+
public static readonly DependencyProperty KeyVisualStyleProperty = DependencyProperty.Register(nameof(KeyVisualStyle), typeof(Style), typeof(ShortcutWithTextLabelControl), new PropertyMetadata(default(Style)));
3753

3854
public ShortcutWithTextLabelControl()
3955
{
40-
this.InitializeComponent();
56+
DefaultStyleKey = typeof(ShortcutWithTextLabelControl);
57+
}
58+
59+
protected override void OnApplyTemplate()
60+
{
61+
base.OnApplyTemplate();
4162
}
4263

4364
private static void OnIsLabelPlacementChanged(DependencyObject d, DependencyPropertyChangedEventArgs newValue)
4465
{
4566
if (d is ShortcutWithTextLabelControl labelControl)
4667
{
47-
if (labelControl.LabelPlacement == LabelPlacement.Before)
68+
if (labelControl.LabelPlacement == Placement.Before)
4869
{
49-
VisualStateManager.GoToState(labelControl, "LabelBefore", true);
70+
VisualStateManager.GoToState(labelControl, "LabelBefore", true);
5071
}
5172
else
5273
{
5374
VisualStateManager.GoToState(labelControl, "LabelAfter", true);
5475
}
5576
}
5677
}
57-
}
5878

59-
public enum LabelPlacement
60-
{
61-
Before,
62-
After,
79+
public enum Placement
80+
{
81+
Before,
82+
After,
83+
}
6384
}
6485
}

0 commit comments

Comments
 (0)