mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-03 17:56:44 +02:00
Switch case
This commit is contained in:
@@ -265,65 +265,27 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
if (_themeIndex != value)
|
||||
{
|
||||
if (value == 0)
|
||||
switch (value)
|
||||
{
|
||||
// set theme to dark.
|
||||
GeneralSettingsConfig.Theme = "dark";
|
||||
_themeIndex = value;
|
||||
|
||||
try
|
||||
{
|
||||
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception e)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
Logger.LogError("Exception encountered when changing Settings theme", e);
|
||||
}
|
||||
|
||||
NotifyPropertyChanged();
|
||||
case 0: GeneralSettingsConfig.Theme = "dark"; break;
|
||||
case 1: GeneralSettingsConfig.Theme = "light"; break;
|
||||
case 2: GeneralSettingsConfig.Theme = "system"; break;
|
||||
}
|
||||
|
||||
if (value == 1)
|
||||
_themeIndex = value;
|
||||
|
||||
try
|
||||
{
|
||||
// set theme to light.
|
||||
GeneralSettingsConfig.Theme = "light";
|
||||
_themeIndex = value;
|
||||
|
||||
try
|
||||
{
|
||||
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
|
||||
}
|
||||
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception e)
|
||||
catch (Exception e)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
Logger.LogError("Exception encountered when changing Settings theme", e);
|
||||
}
|
||||
|
||||
NotifyPropertyChanged();
|
||||
{
|
||||
Logger.LogError("Exception encountered when changing Settings theme", e);
|
||||
}
|
||||
|
||||
if (value == 2)
|
||||
{
|
||||
// set theme to system default.
|
||||
GeneralSettingsConfig.Theme = "system";
|
||||
_themeIndex = value;
|
||||
|
||||
try
|
||||
{
|
||||
UpdateUIThemeCallBack(GeneralSettingsConfig.Theme);
|
||||
}
|
||||
#pragma warning disable CA1031 // Do not catch general exception types
|
||||
catch (Exception e)
|
||||
#pragma warning restore CA1031 // Do not catch general exception types
|
||||
{
|
||||
Logger.LogError("Exception encountered when changing Settings theme", e);
|
||||
}
|
||||
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,32 +197,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
|
||||
set
|
||||
{
|
||||
if (_themeIndex != value)
|
||||
switch (value)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
// set theme to dark.
|
||||
settings.Properties.Theme = Theme.Dark;
|
||||
_themeIndex = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
if (value == 1)
|
||||
{
|
||||
// set theme to light.
|
||||
settings.Properties.Theme = Theme.Light;
|
||||
_themeIndex = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
if (value == 2)
|
||||
{
|
||||
// set theme to system default.
|
||||
settings.Properties.Theme = Theme.System;
|
||||
_themeIndex = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
case 0: settings.Properties.Theme = Theme.Dark; break;
|
||||
case 1: settings.Properties.Theme = Theme.Light; break;
|
||||
case 2: settings.Properties.Theme = Theme.System; break;
|
||||
}
|
||||
|
||||
_themeIndex = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,23 +220,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
if (_monitorPositionIndex != value)
|
||||
{
|
||||
if (value == 0)
|
||||
switch (value)
|
||||
{
|
||||
settings.Properties.Position = StartupPosition.Cursor;
|
||||
UpdateSettings();
|
||||
case 0: settings.Properties.Position = StartupPosition.Cursor; break;
|
||||
case 1: settings.Properties.Position = StartupPosition.PrimaryMonitor; break;
|
||||
case 2: settings.Properties.Position = StartupPosition.Focus; break;
|
||||
}
|
||||
|
||||
if (value == 1)
|
||||
{
|
||||
settings.Properties.Position = StartupPosition.PrimaryMonitor;
|
||||
UpdateSettings();
|
||||
}
|
||||
|
||||
if (value == 2)
|
||||
{
|
||||
settings.Properties.Position = StartupPosition.Focus;
|
||||
UpdateSettings();
|
||||
}
|
||||
_monitorPositionIndex = value;
|
||||
UpdateSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,21 +56,11 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
_opacity = Settings.Properties.OverlayOpacity.Value;
|
||||
_disabledApps = Settings.Properties.DisabledApps.Value;
|
||||
|
||||
string theme = Settings.Properties.Theme.Value;
|
||||
|
||||
if (theme == "dark")
|
||||
switch (Settings.Properties.Theme.Value)
|
||||
{
|
||||
_themeIndex = 0;
|
||||
}
|
||||
|
||||
if (theme == "light")
|
||||
{
|
||||
_themeIndex = 1;
|
||||
}
|
||||
|
||||
if (theme == "system")
|
||||
{
|
||||
_themeIndex = 2;
|
||||
case "dark": _themeIndex = 0; break;
|
||||
case "light": _themeIndex = 1; break;
|
||||
case "system": _themeIndex = 2; break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,29 +120,15 @@ namespace Microsoft.PowerToys.Settings.UI.Library.ViewModels
|
||||
{
|
||||
if (_themeIndex != value)
|
||||
{
|
||||
if (value == 0)
|
||||
switch (value)
|
||||
{
|
||||
// set theme to dark.
|
||||
Settings.Properties.Theme.Value = "dark";
|
||||
_themeIndex = value;
|
||||
NotifyPropertyChanged();
|
||||
case 0: Settings.Properties.Theme.Value = "dark"; break;
|
||||
case 1: Settings.Properties.Theme.Value = "light"; break;
|
||||
case 2: Settings.Properties.Theme.Value = "system"; break;
|
||||
}
|
||||
|
||||
if (value == 1)
|
||||
{
|
||||
// set theme to light.
|
||||
Settings.Properties.Theme.Value = "light";
|
||||
_themeIndex = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
|
||||
if (value == 2)
|
||||
{
|
||||
// set theme to system default.
|
||||
Settings.Properties.Theme.Value = "system";
|
||||
_themeIndex = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
_themeIndex = value;
|
||||
NotifyPropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
|
||||
<value>Remap a key</value>
|
||||
<comment>Keyboard Manager remap keyboard button content</comment>
|
||||
</data>
|
||||
<data name="KeyboardManager_Keys.Header" xml:space="preserve">
|
||||
<data name="KeyboardManager_Keys.Header" xml:space="preserve">
|
||||
<value>Keys</value>
|
||||
<comment>Keyboard Manager remap keyboard header</comment>
|
||||
</data>
|
||||
@@ -280,7 +280,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
|
||||
<value>Remap a shortcut</value>
|
||||
<comment>Keyboard Manager remap shortcuts button</comment>
|
||||
</data>
|
||||
<data name="KeyboardManager_Shortcuts.Header" xml:space="preserve">
|
||||
<data name="KeyboardManager_Shortcuts.Header" xml:space="preserve">
|
||||
<value>Shortcuts</value>
|
||||
<comment>Keyboard Manager remap keyboard header</comment>
|
||||
</data>
|
||||
@@ -413,7 +413,7 @@ Disabling this module or closing PowerToys will unmute the microphone and camera
|
||||
<value>Excluded apps</value>
|
||||
</data>
|
||||
<data name="FancyZones_ExcludeApps.Description" xml:space="preserve">
|
||||
<value>Excludes an application from snappting to zones and will only react to Windows Snap. Add one application name per line.</value>
|
||||
<value>Excludes an application from snapping to zones and will only react to Windows Snap. Add one application name per line.</value>
|
||||
</data>
|
||||
<data name="FancyZones_HighlightOpacity.Header" xml:space="preserve">
|
||||
<value>Zone opacity</value>
|
||||
@@ -950,7 +950,7 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
|
||||
<data name="ColorFormats.Header" xml:space="preserve">
|
||||
<value>Picker behavior</value>
|
||||
</data>
|
||||
<data name="ColorPicker_CopiedColorRepresentation.Description" xml:space="preserve">
|
||||
<data name="ColorPicker_CopiedColorRepresentation.Description" xml:space="preserve">
|
||||
<value>This format will be copied to your clipboard</value>
|
||||
</data>
|
||||
<data name="KBM_KeysCannotBeRemapped.Text" xml:space="preserve">
|
||||
@@ -969,9 +969,8 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
|
||||
</data>
|
||||
<data name="FancyZones_Windows.Header" xml:space="preserve">
|
||||
<value>Windows</value>
|
||||
<comment>refers to a set of windows, not the product name</comment>
|
||||
<comment>refers to a set of windows, not the product name</comment>
|
||||
</data>
|
||||
|
||||
<data name="PowerRename_BehaviorHeader.Header" xml:space="preserve">
|
||||
<value>Behavior</value>
|
||||
</data>
|
||||
@@ -999,16 +998,16 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
|
||||
<data name="ColorPicker_ColorFormats.Header" xml:space="preserve">
|
||||
<value>Color formats</value>
|
||||
</data>
|
||||
<data name="ColorPicker_ColorFormats.Description" xml:space="preserve">
|
||||
<data name="ColorPicker_ColorFormats.Description" xml:space="preserve">
|
||||
<value>Select which color formats (and in what order) should show up in the editor</value>
|
||||
</data>
|
||||
<data name="MoveUp.Text" xml:space="preserve">
|
||||
<data name="MoveUp.Text" xml:space="preserve">
|
||||
<value>Move up</value>
|
||||
</data>
|
||||
<data name="MoveDown.Text" xml:space="preserve">
|
||||
<data name="MoveDown.Text" xml:space="preserve">
|
||||
<value>Move down</value>
|
||||
</data>
|
||||
<data name="ColorPicker_ShowColorName.Content" xml:space="preserve">
|
||||
<data name="ColorPicker_ShowColorName.Content" xml:space="preserve">
|
||||
<value>Show color name when color picking</value>
|
||||
</data>
|
||||
<data name="ImageResizer_DefaultSize_Large" xml:space="preserve">
|
||||
@@ -1129,7 +1128,6 @@ Made with 💗 by Microsoft and the PowerToys community.</value>
|
||||
<data name="FancyZones_QuickLayoutSwitch.Description" xml:space="preserve">
|
||||
<value>You can configure layout-specific shortcuts in the editor</value>
|
||||
</data>
|
||||
|
||||
<data name="FancyZones_QuickLayoutSwitch_GroupSettings.Text" xml:space="preserve">
|
||||
<value>Quick layout switch</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user