mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-15 11:17:53 +01:00
[fxcop] Settings UI library (part 1) (#7187)
* Mark methods static and replace Count() with Length * Use IsNullOrEmpty for null string checks * Remove redundant initializations to default values * Use nameof(property name) in place of string literals * Add NativeMethods class * Rename property getters in KeysDataModel & AppSpecificKeysDataModel * Remove underscores from method names * Mark Helper class static * Address comments & typo fixes * Add EncoderGuid property and fix failing build * Update binding in GeneralPages.xaml
This commit is contained in:
@@ -12,14 +12,14 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
[JsonPropertyName("targetApp")]
|
||||
public string TargetApp { get; set; }
|
||||
|
||||
public new List<string> GetOriginalKeys()
|
||||
public new List<string> GetMappedOriginalKeys()
|
||||
{
|
||||
return base.GetOriginalKeys();
|
||||
return base.GetMappedOriginalKeys();
|
||||
}
|
||||
|
||||
public new List<string> GetNewRemapKeys()
|
||||
public new List<string> GetMappedNewRemapKeys()
|
||||
{
|
||||
return base.GetNewRemapKeys();
|
||||
return base.GetMappedNewRemapKeys();
|
||||
}
|
||||
|
||||
public bool Compare(AppSpecificKeysDataModel arg)
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
|
||||
private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
|
||||
private static void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
|
||||
{
|
||||
var dataEvent = new SettingsEnabledEvent()
|
||||
{
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
|
||||
private string DefaultPowertoysVersion()
|
||||
private static string DefaultPowertoysVersion()
|
||||
{
|
||||
return interop.CommonManaged.GetProductVersion();
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
{
|
||||
_unit = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged("ExtraBoxOpacity");
|
||||
OnPropertyChanged("EnableEtraBoxes");
|
||||
OnPropertyChanged(nameof(ExtraBoxOpacity));
|
||||
OnPropertyChanged(nameof(EnableEtraBoxes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
[JsonPropertyName("newRemapKeys")]
|
||||
public string NewRemapKeys { get; set; }
|
||||
|
||||
private List<string> MapKeys(string stringOfKeys)
|
||||
private static List<string> MapKeys(string stringOfKeys)
|
||||
{
|
||||
return stringOfKeys
|
||||
.Split(';')
|
||||
@@ -27,12 +27,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<string> GetOriginalKeys()
|
||||
public List<string> GetMappedOriginalKeys()
|
||||
{
|
||||
return MapKeys(OriginalKeys);
|
||||
}
|
||||
|
||||
public List<string> GetNewRemapKeys()
|
||||
public List<string> GetMappedNewRemapKeys()
|
||||
{
|
||||
return MapKeys(NewRemapKeys);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||
return JsonSerializer.Serialize(this);
|
||||
}
|
||||
|
||||
private void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
|
||||
private static void LogTelemetryEvent(bool value, [CallerMemberName] string propertyName = null)
|
||||
{
|
||||
var dataEvent = new SettingsEnabledEvent()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.PowerToys.Settings.UI.Lib.CustomAction;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
|
||||
{
|
||||
public class Helper
|
||||
public static class Helper
|
||||
{
|
||||
public static bool AllowRunnerToForeground()
|
||||
{
|
||||
@@ -20,7 +20,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
|
||||
if (processes.Length > 0)
|
||||
{
|
||||
var pid = processes[0].Id;
|
||||
result = AllowSetForegroundWindow(pid);
|
||||
result = NativeMethods.AllowSetForegroundWindow(pid);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -74,9 +74,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
|
||||
return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
|
||||
private static readonly interop.LayoutMapManaged LayoutMap = new interop.LayoutMapManaged();
|
||||
|
||||
public static string GetKeyName(uint key)
|
||||
@@ -98,7 +95,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
|
||||
var v1 = version1.Substring(1).Split('.').Select(int.Parse).ToArray();
|
||||
var v2 = version2.Substring(1).Split('.').Select(int.Parse).ToArray();
|
||||
|
||||
if (v1.Count() != 3 || v2.Count() != 3)
|
||||
if (v1.Length != 3 || v2.Length != 3)
|
||||
{
|
||||
throw new FormatException();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright (c) Microsoft Corporation
|
||||
// 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.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Microsoft.PowerToys.Settings.UI.Lib.Utilities
|
||||
{
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool AllowSetForegroundWindow(int dwProcessId);
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,13 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
SendConfigMSG = ipcMSGCallBackFunc;
|
||||
|
||||
string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
|
||||
_zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor : "#F5FCFF";
|
||||
_zoneInActiveColor = !string.IsNullOrEmpty(inactiveColor) ? inactiveColor : "#F5FCFF";
|
||||
|
||||
string borderColor = Settings.Properties.FancyzonesBorderColor.Value;
|
||||
_zoneBorderColor = borderColor != string.Empty ? borderColor : "#FFFFFF";
|
||||
_zoneBorderColor = !string.IsNullOrEmpty(borderColor) ? borderColor : "#FFFFFF";
|
||||
|
||||
string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value;
|
||||
_zoneHighlightColor = highlightColor != string.Empty ? highlightColor : "#0078D7";
|
||||
_zoneHighlightColor = !string.IsNullOrEmpty(highlightColor) ? highlightColor : "#0078D7";
|
||||
|
||||
_isEnabled = GeneralSettingsConfig.Enabled.FancyZones;
|
||||
}
|
||||
@@ -110,8 +110,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
|
||||
SendConfigMSG(snd.ToString());
|
||||
OnPropertyChanged("IsEnabled");
|
||||
OnPropertyChanged("SnapHotkeysCategoryEnabled");
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_overrideSnapHotkeys = value;
|
||||
Settings.Properties.FancyzonesOverrideSnapHotkeys.Value = value;
|
||||
RaisePropertyChanged();
|
||||
OnPropertyChanged("SnapHotkeysCategoryEnabled");
|
||||
OnPropertyChanged(nameof(SnapHotkeysCategoryEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -518,7 +518,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private string ToRGBHex(string color)
|
||||
private static string ToRGBHex(string color)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
{
|
||||
private GeneralSettings GeneralSettingsConfig { get; set; }
|
||||
|
||||
public ButtonClickCommand CheckFoUpdatesEventHandler { get; set; }
|
||||
public ButtonClickCommand CheckForUpdatesEventHandler { get; set; }
|
||||
|
||||
public ButtonClickCommand RestartElevatedButtonEventHandler { get; set; }
|
||||
|
||||
@@ -35,8 +35,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
|
||||
public GeneralViewModel(ISettingsRepository<GeneralSettings> settingsRepository, string runAsAdminText, string runAsUserText, bool isElevated, bool isAdmin, Func<string, int> updateTheme, Func<string, int> ipcMSGCallBackFunc, Func<string, int> ipcMSGRestartAsAdminMSGCallBackFunc, Func<string, int> ipcMSGCheckForUpdatesCallBackFunc, string configFileSubfolder = "")
|
||||
{
|
||||
CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
|
||||
RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
|
||||
CheckForUpdatesEventHandler = new ButtonClickCommand(CheckForUpdatesClick);
|
||||
RestartElevatedButtonEventHandler = new ButtonClickCommand(RestartElevated);
|
||||
|
||||
// To obtain the general settings configuration of PowerToys if it exists, else to create a new file and return the default configurations.
|
||||
GeneralSettingsConfig = settingsRepository.SettingsConfig;
|
||||
@@ -77,15 +77,15 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_isAdmin = isAdmin;
|
||||
}
|
||||
|
||||
private bool _packaged = false;
|
||||
private bool _startup = false;
|
||||
private bool _isElevated = false;
|
||||
private bool _runElevated = false;
|
||||
private bool _isAdmin = false;
|
||||
private bool _isDarkThemeRadioButtonChecked = false;
|
||||
private bool _isLightThemeRadioButtonChecked = false;
|
||||
private bool _isSystemThemeRadioButtonChecked = false;
|
||||
private bool _autoDownloadUpdates = false;
|
||||
private bool _packaged;
|
||||
private bool _startup;
|
||||
private bool _isElevated;
|
||||
private bool _runElevated;
|
||||
private bool _isAdmin;
|
||||
private bool _isDarkThemeRadioButtonChecked;
|
||||
private bool _isLightThemeRadioButtonChecked;
|
||||
private bool _isSystemThemeRadioButtonChecked;
|
||||
private bool _autoDownloadUpdates;
|
||||
|
||||
private string _latestAvailableVersion = string.Empty;
|
||||
|
||||
@@ -159,8 +159,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
if (_isElevated != value)
|
||||
{
|
||||
_isElevated = value;
|
||||
OnPropertyChanged("IsElevated");
|
||||
OnPropertyChanged("IsAdminButtonEnabled");
|
||||
OnPropertyChanged(nameof(IsElevated));
|
||||
OnPropertyChanged(nameof(IsAdminButtonEnabled));
|
||||
OnPropertyChanged("RunningAsAdminText");
|
||||
}
|
||||
}
|
||||
@@ -175,7 +175,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
|
||||
set
|
||||
{
|
||||
OnPropertyChanged("IsAdminButtonEnabled");
|
||||
OnPropertyChanged(nameof(IsAdminButtonEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -303,7 +303,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
// FxCop suggests marking this member static, but it is accessed through
|
||||
// an instance in autogenerated files (GeneralPage.g.cs) and will break
|
||||
// the file if modified
|
||||
#pragma warning disable CA1822 // Mark members as static
|
||||
public string PowerToysVersion
|
||||
#pragma warning restore CA1822 // Mark members as static
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -339,7 +344,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
|
||||
// callback function to launch the URL to check for updates.
|
||||
private void CheckForUpdates_Click()
|
||||
private void CheckForUpdatesClick()
|
||||
{
|
||||
GeneralSettingsConfig.CustomActionName = "check_for_updates";
|
||||
|
||||
@@ -349,7 +354,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
SendCheckForUpdatesConfigMSG(customaction.ToString());
|
||||
}
|
||||
|
||||
public void Restart_Elevated()
|
||||
public void RestartElevated()
|
||||
{
|
||||
GeneralSettingsConfig.CustomActionName = "restart_elevation";
|
||||
|
||||
|
||||
@@ -57,18 +57,18 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
{
|
||||
size.Id = i;
|
||||
i++;
|
||||
size.PropertyChanged += Size_PropertyChanged;
|
||||
size.PropertyChanged += SizePropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = false;
|
||||
private bool _isEnabled;
|
||||
private ObservableCollection<ImageSize> _advancedSizes = new ObservableCollection<ImageSize>();
|
||||
private int _jpegQualityLevel = 0;
|
||||
private int _jpegQualityLevel;
|
||||
private int _pngInterlaceOption;
|
||||
private int _tiffCompressOption;
|
||||
private string _fileName;
|
||||
private bool _keepDateModified;
|
||||
private int _encoderGuidId = 0;
|
||||
private int _encoderGuidId;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
@@ -87,7 +87,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
|
||||
SendConfigMSG(snd.ToString());
|
||||
OnPropertyChanged("IsEnabled");
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
{
|
||||
SavesImageSizes(value);
|
||||
_advancedSizes = value;
|
||||
OnPropertyChanged("Sizes");
|
||||
OnPropertyChanged(nameof(Sizes));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_jpegQualityLevel = value;
|
||||
Settings.Properties.ImageresizerJpegQualityLevel.Value = value;
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("JPEGQualityLevel");
|
||||
OnPropertyChanged(nameof(JPEGQualityLevel));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_pngInterlaceOption = value;
|
||||
Settings.Properties.ImageresizerPngInterlaceOption.Value = value;
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("PngInterlaceOption");
|
||||
OnPropertyChanged(nameof(PngInterlaceOption));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_tiffCompressOption = value;
|
||||
Settings.Properties.ImageresizerTiffCompressOption.Value = value;
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("TiffCompressOption");
|
||||
OnPropertyChanged(nameof(TiffCompressOption));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_fileName = value;
|
||||
Settings.Properties.ImageresizerFileName.Value = value;
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("FileName");
|
||||
OnPropertyChanged(nameof(FileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,7 +195,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_keepDateModified = value;
|
||||
Settings.Properties.ImageresizerKeepDateModified.Value = value;
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("KeepDateModified");
|
||||
OnPropertyChanged(nameof(KeepDateModified));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,17 +214,25 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_settingsUtils.SaveSettings(Settings.Properties.ImageresizerSizes.ToJsonString(), ModuleName, "sizes.json");
|
||||
Settings.Properties.ImageresizerFallbackEncoder.Value = GetEncoderGuid(value);
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
OnPropertyChanged("Encoder");
|
||||
OnPropertyChanged(nameof(Encoder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string EncoderGuid
|
||||
{
|
||||
get
|
||||
{
|
||||
return ImageResizerViewModel.GetEncoderGuid(_encoderGuidId);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddRow()
|
||||
{
|
||||
ObservableCollection<ImageSize> imageSizes = Sizes;
|
||||
int maxId = imageSizes.Count > 0 ? imageSizes.OrderBy(x => x.Id).Last().Id : -1;
|
||||
ImageSize newSize = new ImageSize(maxId + 1);
|
||||
newSize.PropertyChanged += Size_PropertyChanged;
|
||||
newSize.PropertyChanged += SizePropertyChanged;
|
||||
imageSizes.Add(newSize);
|
||||
_advancedSizes = imageSizes;
|
||||
SavesImageSizes(imageSizes);
|
||||
@@ -247,7 +255,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
|
||||
}
|
||||
|
||||
public string GetEncoderGuid(int value)
|
||||
public static string GetEncoderGuid(int value)
|
||||
{
|
||||
// PNG Encoder guid
|
||||
if (value == 0)
|
||||
@@ -288,40 +296,40 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
return null;
|
||||
}
|
||||
|
||||
public int GetEncoderIndex(string guid)
|
||||
public static int GetEncoderIndex(string value)
|
||||
{
|
||||
// PNG Encoder guid
|
||||
if (guid == "1b7cfaf4-713f-473c-bbcd-6137425faeaf")
|
||||
if (value == "1b7cfaf4-713f-473c-bbcd-6137425faeaf")
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Bitmap Encoder guid
|
||||
else if (guid == "0af1d87e-fcfe-4188-bdeb-a7906471cbe3")
|
||||
else if (value == "0af1d87e-fcfe-4188-bdeb-a7906471cbe3")
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
// JPEG Encoder guid
|
||||
else if (guid == "19e4a5aa-5662-4fc5-a0c0-1758028e1057")
|
||||
else if (value == "19e4a5aa-5662-4fc5-a0c0-1758028e1057")
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Tiff encoder guid.
|
||||
else if (guid == "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3")
|
||||
else if (value == "163bcc30-e2e9-4f0b-961d-a3e9fdb788a3")
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
|
||||
// Tiff encoder guid.
|
||||
else if (guid == "57a37caa-367a-4540-916b-f183c5093a4b")
|
||||
else if (value == "57a37caa-367a-4540-916b-f183c5093a4b")
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Gif encoder guid.
|
||||
else if (guid == "1f8a5601-7d4d-4cbd-9c82-1bc8d4eeb9a5")
|
||||
else if (value == "1f8a5601-7d4d-4cbd-9c82-1bc8d4eeb9a5")
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
@@ -329,7 +337,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void Size_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
public void SizePropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
ImageSize modifiedSize = (ImageSize)sender;
|
||||
ObservableCollection<ImageSize> imageSizes = Sizes;
|
||||
|
||||
@@ -41,9 +41,9 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
|
||||
}
|
||||
|
||||
private bool _svgRenderIsEnabled = false;
|
||||
private bool _mdRenderIsEnabled = false;
|
||||
private bool _svgThumbnailIsEnabled = false;
|
||||
private bool _svgRenderIsEnabled;
|
||||
private bool _mdRenderIsEnabled;
|
||||
private bool _svgThumbnailIsEnabled;
|
||||
|
||||
public bool SVGRenderIsEnabled
|
||||
{
|
||||
|
||||
@@ -54,12 +54,12 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_powerRenameEnabled = GeneralSettingsConfig.Enabled.PowerRename;
|
||||
}
|
||||
|
||||
private bool _powerRenameEnabled = false;
|
||||
private bool _powerRenameEnabledOnContextMenu = false;
|
||||
private bool _powerRenameEnabledOnContextExtendedMenu = false;
|
||||
private bool _powerRenameRestoreFlagsOnLaunch = false;
|
||||
private int _powerRenameMaxDispListNumValue = 0;
|
||||
private bool _autoComplete = false;
|
||||
private bool _powerRenameEnabled;
|
||||
private bool _powerRenameEnabledOnContextMenu;
|
||||
private bool _powerRenameEnabledOnContextExtendedMenu;
|
||||
private bool _powerRenameRestoreFlagsOnLaunch;
|
||||
private int _powerRenameMaxDispListNumValue;
|
||||
private bool _autoComplete;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
@@ -78,8 +78,8 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
SendConfigMSG(snd.ToString());
|
||||
|
||||
_powerRenameEnabled = value;
|
||||
OnPropertyChanged("IsEnabled");
|
||||
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
RaisePropertyChanged(nameof(GlobalAndMruEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
_autoComplete = value;
|
||||
Settings.Properties.MRUEnabled.Value = value;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("GlobalAndMruEnabled");
|
||||
RaisePropertyChanged(nameof(GlobalAndMruEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,10 +58,10 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isEnabled = false;
|
||||
private int _themeIndex = 0;
|
||||
private int _pressTime = 0;
|
||||
private int _opacity = 0;
|
||||
private bool _isEnabled;
|
||||
private int _themeIndex;
|
||||
private int _pressTime;
|
||||
private int _opacity;
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
@@ -81,7 +81,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels
|
||||
OutGoingGeneralSettings snd = new OutGoingGeneralSettings(GeneralSettingsConfig);
|
||||
|
||||
SendConfigMSG(snd.ToString());
|
||||
OnPropertyChanged("IsEnabled");
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace ViewModelTests
|
||||
|
||||
// Verifiy that the old settings persisted
|
||||
Assert.AreEqual(originalGeneralSettings.Enabled.ImageResizer, viewModel.IsEnabled);
|
||||
Assert.AreEqual(viewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder);
|
||||
Assert.AreEqual(ImageResizerViewModel.GetEncoderIndex(originalSettings.Properties.ImageresizerFallbackEncoder.Value), viewModel.Encoder);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerFileName.Value, viewModel.FileName);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerJpegQualityLevel.Value, viewModel.JPEGQualityLevel);
|
||||
Assert.AreEqual(originalSettings.Properties.ImageresizerKeepDateModified.Value, viewModel.KeepDateModified);
|
||||
@@ -197,7 +197,7 @@ namespace ViewModelTests
|
||||
|
||||
// Assert
|
||||
viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository<GeneralSettings>.GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
|
||||
Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.GetEncoderGuid(viewModel.Encoder));
|
||||
Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
|
||||
Assert.AreEqual(3, viewModel.Encoder);
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
<Button x:Uid="GeneralPage_CheckForUpdates"
|
||||
Style="{StaticResource AccentButtonStyle}"
|
||||
Foreground="White"
|
||||
Command="{Binding CheckFoUpdatesEventHandler}"
|
||||
Command="{Binding CheckForUpdatesEventHandler}"
|
||||
/>
|
||||
|
||||
<ToggleSwitch x:Uid="GeneralPage_ToggleSwitch_AutoDownloadUpdates"
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
Orientation="Horizontal"
|
||||
Height="56">
|
||||
<ItemsControl
|
||||
ItemsSource="{x:Bind GetOriginalKeys()}"
|
||||
ItemsSource="{x:Bind GetMappedOriginalKeys()}"
|
||||
IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -59,7 +59,7 @@
|
||||
<ItemsControl
|
||||
Name="KeyboardManager_RemappedTo"
|
||||
x:Uid="KeyboardManager_RemappedTo"
|
||||
ItemsSource="{x:Bind GetNewRemapKeys()}"
|
||||
ItemsSource="{x:Bind GetMappedNewRemapKeys()}"
|
||||
Grid.Column="2"
|
||||
IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
@@ -97,7 +97,7 @@
|
||||
Orientation="Horizontal"
|
||||
Height="56">
|
||||
<ItemsControl
|
||||
ItemsSource="{x:Bind GetOriginalKeys()}"
|
||||
ItemsSource="{x:Bind GetMappedOriginalKeys()}"
|
||||
IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
@@ -131,7 +131,7 @@
|
||||
Margin="5,0,5,0"/>
|
||||
<ItemsControl Name="KeyboardManager_ShortcutRemappedTo"
|
||||
x:Uid="KeyboardManager_ShortcutRemappedTo"
|
||||
ItemsSource="{x:Bind GetNewRemapKeys()}"
|
||||
ItemsSource="{x:Bind GetMappedNewRemapKeys()}"
|
||||
Grid.Column="2"
|
||||
IsTabStop="False">
|
||||
<ItemsControl.ItemsPanel>
|
||||
|
||||
Reference in New Issue
Block a user