From b6e5a5e655c538c071406e7f6d545dd0d9838752 Mon Sep 17 00:00:00 2001 From: Clint Rutkas Date: Thu, 23 Jul 2020 15:53:12 -0700 Subject: [PATCH] Color picker tweaks (#5194) * Adjustments on default keystroke and removing key string whihc really didn't do anything * moving color picker into alphabetical order * removing removed property * adjusting comment based on feedback from martin Co-authored-by: Clint Rutkas --- .../ColorPickerProperties.cs | 4 +- .../FZConfigProperties.cs | 50 ++++++++----------- .../HotkeySettings.cs | 27 +++++----- .../Controls/HotkeySettingsControl.xaml.cs | 1 - .../ViewModels/FancyZonesViewModel.cs | 3 +- .../Views/ColorPickerPage.xaml | 7 ++- .../Views/ShellPage.xaml | 13 +++-- 7 files changed, 51 insertions(+), 54 deletions(-) diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ColorPickerProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ColorPickerProperties.cs index c6fb57910f..a726465679 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ColorPickerProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ColorPickerProperties.cs @@ -17,8 +17,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public ColorPickerProperties() { - ActivationShortcut = new HotkeySettings(false, true, false, false, "Break", 3); - ChangeCursor = true; + ActivationShortcut = new HotkeySettings(true, false, false, true, 0x43); + ChangeCursor = false; } public HotkeySettings ActivationShortcut { get; set; } diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs index 509c2ddfcd..4c36136cf3 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/FZConfigProperties.cs @@ -2,9 +2,6 @@ // 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.Text; using System.Text.Json; using System.Text.Json.Serialization; @@ -12,35 +9,28 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public class FZConfigProperties { + public static readonly HotkeySettings DefaultHotkeyValue = new HotkeySettings(true, false, false, false, 0xc0); + public FZConfigProperties() { - this.FancyzonesShiftDrag = new BoolProperty(ConfigDefaults.DefaultFancyzonesShiftDrag); - this.FancyzonesOverrideSnapHotkeys = new BoolProperty(); - this.FancyzonesMouseSwitch = new BoolProperty(); - this.FancyzonesMoveWindowsAcrossMonitors = new BoolProperty(); - this.FancyzonesDisplayChangeMoveWindows = new BoolProperty(); - this.FancyzonesZoneSetChangeMoveWindows = new BoolProperty(); - this.FancyzonesAppLastZoneMoveWindows = new BoolProperty(); - this.FancyzonesOpenWindowOnActiveMonitor = new BoolProperty(); - this.FancyzonesRestoreSize = new BoolProperty(); - this.UseCursorposEditorStartupscreen = new BoolProperty(ConfigDefaults.DefaultUseCursorposEditorStartupscreen); - this.FancyzonesShowOnAllMonitors = new BoolProperty(); - this.FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor); - this.FancyzonesHighlightOpacity = new IntProperty(50); - this.FancyzonesEditorHotkey = new KeyboardKeysProperty( - new HotkeySettings() - { - Win = true, - Ctrl = false, - Alt = false, - Shift = false, - Key = "`", - Code = 192, - }); - this.FancyzonesMakeDraggedWindowTransparent = new BoolProperty(); - this.FancyzonesExcludedApps = new StringProperty(); - this.FancyzonesInActiveColor = new StringProperty(ConfigDefaults.DefaultFancyZonesInActiveColor); - this.FancyzonesBorderColor = new StringProperty(ConfigDefaults.DefaultFancyzonesBorderColor); + FancyzonesShiftDrag = new BoolProperty(ConfigDefaults.DefaultFancyzonesShiftDrag); + FancyzonesOverrideSnapHotkeys = new BoolProperty(); + FancyzonesMouseSwitch = new BoolProperty(); + FancyzonesMoveWindowsAcrossMonitors = new BoolProperty(); + FancyzonesDisplayChangeMoveWindows = new BoolProperty(); + FancyzonesZoneSetChangeMoveWindows = new BoolProperty(); + FancyzonesAppLastZoneMoveWindows = new BoolProperty(); + FancyzonesOpenWindowOnActiveMonitor = new BoolProperty(); + FancyzonesRestoreSize = new BoolProperty(); + UseCursorposEditorStartupscreen = new BoolProperty(ConfigDefaults.DefaultUseCursorposEditorStartupscreen); + FancyzonesShowOnAllMonitors = new BoolProperty(); + FancyzonesZoneHighlightColor = new StringProperty(ConfigDefaults.DefaultFancyZonesZoneHighlightColor); + FancyzonesHighlightOpacity = new IntProperty(50); + FancyzonesEditorHotkey = new KeyboardKeysProperty(DefaultHotkeyValue); + FancyzonesMakeDraggedWindowTransparent = new BoolProperty(); + FancyzonesExcludedApps = new StringProperty(); + FancyzonesInActiveColor = new StringProperty(ConfigDefaults.DefaultFancyZonesInActiveColor); + FancyzonesBorderColor = new StringProperty(ConfigDefaults.DefaultFancyzonesBorderColor); } [JsonPropertyName("fancyzones_shiftDrag")] diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs index bebcc7f751..c76d52eb2d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/HotkeySettings.cs @@ -12,27 +12,33 @@ namespace Microsoft.PowerToys.Settings.UI.Lib { public HotkeySettings() { - this.Win = false; - this.Ctrl = false; - this.Alt = false; - this.Shift = false; - this.Key = string.Empty; - this.Code = 0; + Win = false; + Ctrl = false; + Alt = false; + Shift = false; + Code = 0; } - public HotkeySettings(bool win, bool ctrl, bool alt, bool shift, string key, int code) + /// + /// Initializes a new instance of the class. + /// + /// Should Windows key be used + /// Should Ctrl key be used + /// Should Alt key be used + /// Should Shift key be used + /// Go to https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes to see list of v-keys + public HotkeySettings(bool win, bool ctrl, bool alt, bool shift, int code) { Win = win; Ctrl = ctrl; Alt = alt; Shift = shift; - Key = key; Code = code; } public HotkeySettings Clone() { - return new HotkeySettings(Win, Ctrl, Alt, Shift, Key, Code); + return new HotkeySettings(Win, Ctrl, Alt, Shift, Code); } [JsonPropertyName("win")] @@ -47,9 +53,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib [JsonPropertyName("shift")] public bool Shift { get; set; } - [JsonPropertyName("key")] - public string Key { get; set; } - [JsonPropertyName("code")] public int Code { get; set; } diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Controls/HotkeySettingsControl.xaml.cs b/src/core/Microsoft.PowerToys.Settings.UI/Controls/HotkeySettingsControl.xaml.cs index 4749d24309..b1615e6130 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Controls/HotkeySettingsControl.xaml.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/Controls/HotkeySettingsControl.xaml.cs @@ -126,7 +126,6 @@ namespace Microsoft.PowerToys.Settings.UI.Controls return; default: internalSettings.Code = matchValueCode; - internalSettings.Key = matchValueText; break; } } diff --git a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs index 1c64d1b0b1..f191959857 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI/ViewModels/FancyZonesViewModel.cs @@ -420,7 +420,8 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels { if (value.IsEmpty()) { - _editorHotkey = new HotkeySettings(true, false, false, false, "'", 192); + + _editorHotkey = FZConfigProperties.DefaultHotkeyValue; } else { diff --git a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml index 750cf5ef1f..6aac1b867d 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml +++ b/src/core/Microsoft.PowerToys.Settings.UI/Views/ColorPickerPage.xaml @@ -69,10 +69,15 @@ + + + + + + + @@ -93,13 +99,6 @@ - - - - - - -