From 32d164a786fc1691505c1e00afc9a9b95ae2f5e2 Mon Sep 17 00:00:00 2001 From: Seraphima Zykova Date: Wed, 3 Feb 2021 14:12:53 +0300 Subject: [PATCH] [FZ Settings] replaced checkbox with radiobuttons (#9438) --- .../ViewModels/FancyZonesViewModel.cs | 36 ++++++++++++++++--- .../Strings/en-us/Resources.resw | 6 ++++ .../Views/FancyZonesPage.xaml | 15 +++++--- 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/FancyZonesViewModel.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/FancyZonesViewModel.cs index 5b13543a58..1894738f2b 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/FancyZonesViewModel.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/ViewModels/FancyZonesViewModel.cs @@ -26,6 +26,12 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels private string settingsConfigFileFolder = string.Empty; + private enum MoveWindowBehaviour + { + MoveWindowBasedOnZoneIndex = 0, + MoveWindowBasedOnPosition, + } + public FancyZonesViewModel(ISettingsRepository settingsRepository, ISettingsRepository moduleSettingsRepository, Func ipcMSGCallBackFunc, string configFileSubfolder = "") { // To obtain the general settings configurations of PowerToys Settings. @@ -51,7 +57,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels _mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value; _overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value; _moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value; - _moveWindowsBasedOnPosition = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value; + _moveWindowBehaviour = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value ? MoveWindowBehaviour.MoveWindowBasedOnPosition : MoveWindowBehaviour.MoveWindowBasedOnZoneIndex; _displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value; _zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value; _appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value; @@ -85,7 +91,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels private bool _mouseSwitch; private bool _overrideSnapHotkeys; private bool _moveWindowsAcrossMonitors; - private bool _moveWindowsBasedOnPosition; + private MoveWindowBehaviour _moveWindowBehaviour; private bool _displayChangemoveWindows; private bool _zoneSetChangeMoveWindows; private bool _appLastZoneMoveWindows; @@ -217,20 +223,40 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels { get { - return _moveWindowsBasedOnPosition; + return _moveWindowBehaviour == MoveWindowBehaviour.MoveWindowBasedOnPosition; } set { - if (value != _moveWindowsBasedOnPosition) + var settingsValue = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value; + if (value != settingsValue) { - _moveWindowsBasedOnPosition = value; + _moveWindowBehaviour = value ? MoveWindowBehaviour.MoveWindowBasedOnPosition : MoveWindowBehaviour.MoveWindowBasedOnZoneIndex; Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = value; NotifyPropertyChanged(); } } } + public bool MoveWindowsBasedOnZoneIndex + { + get + { + return _moveWindowBehaviour == MoveWindowBehaviour.MoveWindowBasedOnZoneIndex; + } + + set + { + var settingsValue = Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value; + if (value == settingsValue) + { + _moveWindowBehaviour = value ? MoveWindowBehaviour.MoveWindowBasedOnZoneIndex : MoveWindowBehaviour.MoveWindowBasedOnPosition; + Settings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value = !value; + NotifyPropertyChanged(); + } + } + } + public bool DisplayChangeMoveWindows { get diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index f9faea3bad..b84d6d35aa 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -928,6 +928,12 @@ https://aka.ms/PowerToysOverview_ShortcutGuide URL. Do not loc + + Win + Up/Down/Left/Right to move windows based on relative position + + + Win + Left/Right to move windows based on zone index + Editor diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml index f304bffb69..b8195f0b86 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/FancyZonesPage.xaml @@ -135,10 +135,17 @@ Margin="{StaticResource XSmallTopMargin}" IsEnabled="{x:Bind Mode=OneWay, Path=ViewModel.IsEnabled}"/> - + + +