getting stylecop undercontrol for UI warnings (#5630)

This commit is contained in:
Clint Rutkas 2020-08-06 11:16:25 -07:00 committed by GitHub
parent ed36447bdf
commit 7b767df0b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 70 additions and 119 deletions

View File

@ -1,6 +1,9 @@
using Microsoft.PowerToys.Settings.UI.Lib;
// 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 Windows.UI;
using Microsoft.PowerToys.Settings.UI.Lib;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;

View File

@ -26,6 +26,7 @@ namespace Microsoft.PowerToys.Settings.UI
[DllImport("user32.dll")]
public static extern bool ShowWindow(System.IntPtr hWnd, int nCmdShow);
[System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.NamingRules", "SA1310:Field names should not contain underscore", Justification = "Interop naming consistancy")]
public const int SW_HIDE = 0;
}
}

View File

@ -1,9 +1,6 @@
// 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.Linq;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Helpers;

View File

@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
public ButtonClickCommand(Action execute)
{
this._execute = execute;
_execute = execute;
}
// Occurs when changes occur that affect whether or not the command should execute.
@ -30,5 +30,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels.Commands
{
_execute();
}
public void OnCanExecuteChanged() => CanExecuteChanged?.Invoke(this, EventArgs.Empty);
}
}

View File

@ -2,16 +2,13 @@
// 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.Runtime.CompilerServices;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.Toolkit.Uwp.Helpers;
using Windows.UI;
using Windows.UI.Popups;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@ -35,32 +32,32 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
}
this.LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
LaunchEditorEventHandler = new ButtonClickCommand(LaunchEditor);
this._shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
this._mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value;
this._overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
this._moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
this._displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
this._zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
this._appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
this._openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
this._restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
this._useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
this._showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
this._makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value;
this._highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
this._excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
this.EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
_shiftDrag = Settings.Properties.FancyzonesShiftDrag.Value;
_mouseSwitch = Settings.Properties.FancyzonesMouseSwitch.Value;
_overrideSnapHotkeys = Settings.Properties.FancyzonesOverrideSnapHotkeys.Value;
_moveWindowsAcrossMonitors = Settings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value;
_displayChangemoveWindows = Settings.Properties.FancyzonesDisplayChangeMoveWindows.Value;
_zoneSetChangeMoveWindows = Settings.Properties.FancyzonesZoneSetChangeMoveWindows.Value;
_appLastZoneMoveWindows = Settings.Properties.FancyzonesAppLastZoneMoveWindows.Value;
_openWindowOnActiveMonitor = Settings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value;
_restoreSize = Settings.Properties.FancyzonesRestoreSize.Value;
_useCursorPosEditorStartupScreen = Settings.Properties.UseCursorposEditorStartupscreen.Value;
_showOnAllMonitors = Settings.Properties.FancyzonesShowOnAllMonitors.Value;
_makeDraggedWindowTransparent = Settings.Properties.FancyzonesMakeDraggedWindowTransparent.Value;
_highlightOpacity = Settings.Properties.FancyzonesHighlightOpacity.Value;
_excludedApps = Settings.Properties.FancyzonesExcludedApps.Value;
EditorHotkey = Settings.Properties.FancyzonesEditorHotkey.Value;
string inactiveColor = Settings.Properties.FancyzonesInActiveColor.Value;
this._zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor.ToColor() : "#F5FCFF".ToColor();
_zoneInActiveColor = inactiveColor != string.Empty ? inactiveColor.ToColor() : "#F5FCFF".ToColor();
string borderColor = Settings.Properties.FancyzonesBorderColor.Value;
this._zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor();
_zoneBorderColor = borderColor != string.Empty ? borderColor.ToColor() : "#FFFFFF".ToColor();
string highlightColor = Settings.Properties.FancyzonesZoneHighlightColor.Value;
this._zoneHighlightColor = highlightColor != string.Empty ? highlightColor.ToColor() : "#0078D7".ToColor();
_zoneHighlightColor = highlightColor != string.Empty ? highlightColor.ToColor() : "#0078D7".ToColor();
GeneralSettings generalSettings;
try
@ -73,7 +70,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
}
this._isEnabled = generalSettings.Enabled.FancyZones;
_isEnabled = generalSettings.Enabled.FancyZones;
}
private bool _isEnabled;

View File

@ -5,16 +5,12 @@
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Text.Json;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Microsoft.PowerToys.Settings.UI.ViewModels.Commands;
using Microsoft.PowerToys.Settings.UI.Views;
using Windows.ApplicationModel.Resources;
using Windows.Data.Html;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
@ -29,13 +25,24 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
private ResourceLoader loader = ResourceLoader.GetForViewIndependentUse();
public readonly string RunningAsUserDefaultText;
public readonly string RunningAsAdminDefaultText;
public string RunningAsUserDefaultText { get; private set; }
public string RunningAsAdminDefaultText { get; private set; }
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;
public GeneralViewModel()
{
this.CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
this.RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
CheckFoUpdatesEventHandler = new ButtonClickCommand(CheckForUpdates_Click);
RestartElevatedButtonEventHandler = new ButtonClickCommand(Restart_Elevated);
try
{
@ -107,16 +114,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
_isAdmin = ShellPage.IsUserAnAdmin;
}
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;
// Gets or sets a value indicating whether packaged.
public bool Packaged
{
@ -350,7 +347,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
// callback function to launch the URL to check for updates.
private async void CheckForUpdates_Click()
private void CheckForUpdates_Click()
{
GeneralSettings settings = SettingsUtils.GetSettings<GeneralSettings>(string.Empty);
settings.CustomActionName = "check_for_updates";
@ -358,10 +355,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
if (ShellPage.CheckForUpdatesMsgCallback != null)
{
ShellPage.CheckForUpdatesMsgCallback(customaction.ToString());
}
ShellPage.CheckForUpdatesMsgCallback?.Invoke(customaction.ToString());
}
public void Restart_Elevated()
@ -372,10 +366,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
OutGoingGeneralSettings outsettings = new OutGoingGeneralSettings(settings);
GeneralSettingsCustomAction customaction = new GeneralSettingsCustomAction(outsettings);
if (ShellPage.SndRestartAsAdminMsgCallback != null)
{
ShellPage.SndRestartAsAdminMsgCallback(customaction.ToString());
}
ShellPage.SndRestartAsAdminMsgCallback?.Invoke(customaction.ToString());
}
}
}

View File

@ -2,18 +2,13 @@
// 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.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Windows.Input;
using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Views;
using Windows.UI.Popups;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@ -47,14 +42,14 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
}
this._isEnabled = generalSettings.Enabled.ImageResizer;
this._advancedSizes = Settings.Properties.ImageresizerSizes.Value;
this._jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value;
this._pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value;
this._tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value;
this._fileName = Settings.Properties.ImageresizerFileName.Value;
this._keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value;
this._encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value);
_isEnabled = generalSettings.Enabled.ImageResizer;
_advancedSizes = Settings.Properties.ImageresizerSizes.Value;
_jpegQualityLevel = Settings.Properties.ImageresizerJpegQualityLevel.Value;
_pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value;
_tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value;
_fileName = Settings.Properties.ImageresizerFileName.Value;
_keepDateModified = Settings.Properties.ImageresizerKeepDateModified.Value;
_encoderGuidId = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value);
int i = 0;
foreach (ImageSize size in _advancedSizes)

View File

@ -13,7 +13,6 @@ using Microsoft.PowerToys.Settings.UI.Helpers;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.Lib.Utilities;
using Microsoft.PowerToys.Settings.UI.Views;
using Microsoft.Toolkit.Uwp.Helpers;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Xaml;

View File

@ -27,9 +27,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
}
this._svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
this._svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
this._mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
_svgRenderIsEnabled = Settings.Properties.EnableSvgPreview;
_svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
_mdRenderIsEnabled = Settings.Properties.EnableMdPreview;
}
private bool _svgRenderIsEnabled = false;

View File

@ -39,9 +39,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
}
this._isEnabled = generalSettings.Enabled.ShortcutGuide;
this._pressTime = Settings.Properties.PressTime.Value;
this._opacity = Settings.Properties.OverlayOpacity.Value;
_isEnabled = generalSettings.Enabled.ShortcutGuide;
_pressTime = Settings.Properties.PressTime.Value;
_opacity = Settings.Properties.OverlayOpacity.Value;
string theme = Settings.Properties.Theme.Value;

View File

@ -2,21 +2,8 @@
// 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.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.Views
{
@ -26,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public FancyZonesPage()
{
this.InitializeComponent();
InitializeComponent();
ViewModel = new FancyZonesViewModel();
MainView.DataContext = ViewModel;
}

View File

@ -2,15 +2,8 @@
// 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.IO;
using Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.System;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.Views
{
@ -30,10 +23,10 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public GeneralPage()
{
this.InitializeComponent();
InitializeComponent();
this.ViewModel = new GeneralViewModel();
this.GeneralSettingsView.DataContext = this.ViewModel;
ViewModel = new GeneralViewModel();
GeneralSettingsView.DataContext = ViewModel;
}
}
}

View File

@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.ObjectModel;
using System.Linq;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.UI.Xaml.Controls;

View File

@ -2,12 +2,8 @@
// 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 Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.Views
{
@ -16,13 +12,13 @@ namespace Microsoft.PowerToys.Settings.UI.Views
/// </summary>
public sealed partial class PowerPreviewPage : Page
{
public PowerPreviewViewModel viewModel { get; set; }
public PowerPreviewViewModel ViewModel { get; set; }
public PowerPreviewPage()
{
this.InitializeComponent();
viewModel = new PowerPreviewViewModel();
this.PowerPreviewSettingsView.DataContext = viewModel;
InitializeComponent();
ViewModel = new PowerPreviewViewModel();
PowerPreviewSettingsView.DataContext = ViewModel;
}
}
}

View File

@ -2,13 +2,8 @@
// 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 Microsoft.PowerToys.Settings.UI.Lib;
using Microsoft.PowerToys.Settings.UI.ViewModels;
using Microsoft.UI.Xaml.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace Microsoft.PowerToys.Settings.UI.Views
{
@ -18,7 +13,7 @@ namespace Microsoft.PowerToys.Settings.UI.Views
public PowerRenamePage()
{
this.InitializeComponent();
InitializeComponent();
ViewModel = new PowerRenameViewModel();
DataContext = ViewModel;

View File

@ -4,10 +4,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;