From ac62fd620446ff13c97f667a339d9f2d1177f884 Mon Sep 17 00:00:00 2001 From: Lavius Motileng <58791731+laviusmotileng-ms@users.noreply.github.com> Date: Thu, 4 Jun 2020 14:52:04 -0700 Subject: [PATCH] added error handling for FZ Hotkeys (#4057) * added error handling for FZ Hotkeys * moved hint to hot key control text * updated icon size 16px * updated styling and fixed typos * fixed typo * moved text to string resource Co-authored-by: Lavius Motileng --- .../Strings/en-us/Resources.resw | 13 +++++++-- .../ViewModels/FancyZonesViewModel.cs | 16 ++++++++--- .../Views/FancyZonesPage.xaml | 27 +++++++++++++------ 3 files changed, 42 insertions(+), 14 deletions(-) diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index 276b345dde..00e1744b6a 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -281,8 +281,8 @@ Zone highlight opacity - - Edit hot key / shortcut + + Edit hotkey / shortcut Launch zones editor @@ -590,4 +590,13 @@ You need to run as administrator to use this setting + + Only shortcuts with the following hotkeys are valid: Win, Ctrl, Alt, Shift. + + + Only shortcuts with the following hotkeys are valid: Win, Ctrl, Alt, Shift. + + + Only shortcuts with the following hotkeys are valid: Win, Ctrl, Alt, Shift. + \ No newline at end of file diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs index 6de0e3fdaa..5af5e21059 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs @@ -49,13 +49,13 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels this._makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value; this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value; this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value; - this._editorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; + this.EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value; string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value; this._zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor.ToColor() : "#F5FCFF".ToColor(); string borderColor = Settings.Properties.FancyzonesBorderColor.Value; - this._zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor(); + this._zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor(); string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value; this._zoneHighlightColor = highlightColor != string.Empty ? highlightColor.ToColor() : "#0078D7".ToColor(); @@ -378,8 +378,16 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels { if (value != _editorHotkey) { - _editorHotkey = value; - Settings.Properties.FancyzonesEditorHotkey.Value = value; + if (value.IsEmpty()) + { + _editorHotkey = new HotkeySettings(true, false, false, false, "'", 192); + } + else + { + _editorHotkey = value; + } + + Settings.Properties.FancyzonesEditorHotkey.Value = _editorHotkey; RaisePropertyChanged(); } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml index 96088f1fb6..b6fcf13cf3 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml +++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml @@ -70,19 +70,30 @@ - + + + + + + + + + x:Uid="FancyZones_HotkeyEditorControl_TextBox" + Width="240" + HorizontalAlignment="Left" + Margin="0,5,0,0" + HotkeySettings="{x:Bind Path=ViewModel.EditorHotkey, Mode=TwoWay}" + IsEnabled="{ Binding Mode=TwoWay, Path=IsEnabled}" + />