diff --git a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/RelayCommand`1.cs b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/RelayCommand`1.cs index 41f7f3e64..22e2fed20 100644 --- a/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/RelayCommand`1.cs +++ b/src/core/Microsoft.PowerToys.Settings.UI.Lib/ViewModels/Commands/RelayCommand`1.cs @@ -7,7 +7,6 @@ using System.Windows.Input; namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands { - public class RelayCommand : ICommand { private readonly Action execute; diff --git a/src/modules/launcher/PowerLauncher/ActionKeywords.xaml.cs b/src/modules/launcher/PowerLauncher/ActionKeywords.xaml.cs index acf6b5d8f..ac9fdbd0b 100644 --- a/src/modules/launcher/PowerLauncher/ActionKeywords.xaml.cs +++ b/src/modules/launcher/PowerLauncher/ActionKeywords.xaml.cs @@ -12,9 +12,10 @@ namespace Wox { public partial class ActionKeywords : Window { + private readonly Internationalization _translater = InternationalizationManager.Instance; + private PluginPair _plugin; private Settings _settings; - private readonly Internationalization _translater = InternationalizationManager.Instance; public ActionKeywords(string pluginId, Settings settings) { diff --git a/src/modules/launcher/PowerLauncher/App.xaml.cs b/src/modules/launcher/PowerLauncher/App.xaml.cs index 36913517f..245e2506f 100644 --- a/src/modules/launcher/PowerLauncher/App.xaml.cs +++ b/src/modules/launcher/PowerLauncher/App.xaml.cs @@ -27,6 +27,8 @@ namespace PowerLauncher { public static PublicAPIInstance API { get; private set; } + private readonly Alphabet _alphabet = new Alphabet(); + private const string Unique = "PowerLauncher_Unique_Application_Mutex"; private static bool _disposed = false; private static int _powerToysPid; @@ -35,7 +37,6 @@ namespace PowerLauncher private MainWindow _mainWindow; private ThemeManager _themeManager; private SettingWindowViewModel _settingsVM; - private readonly Alphabet _alphabet = new Alphabet(); private StringMatcher _stringMatcher; private SettingsWatcher _settingsWatcher; diff --git a/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs b/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs index e8dab70cc..b96598e4c 100644 --- a/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs +++ b/src/modules/launcher/PowerLauncher/Helper/DataWebRequestFactory.cs @@ -10,7 +10,7 @@ namespace PowerLauncher.Helper { public class DataWebRequestFactory : IWebRequestCreate { - class DataWebRequest : WebRequest + private class DataWebRequest : WebRequest { private readonly Uri m_uri; @@ -25,7 +25,7 @@ namespace PowerLauncher.Helper } } - class DataWebResponse : WebResponse + private class DataWebResponse : WebResponse { private readonly string m_contentType; private readonly byte[] m_data; diff --git a/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs b/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs index b24e1b4be..6cfdd2fde 100644 --- a/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs +++ b/src/modules/launcher/PowerLauncher/Helper/KeyboardHelper.cs @@ -7,7 +7,7 @@ using Wox.Plugin; namespace PowerLauncher.Helper { - class KeyboardHelper + internal class KeyboardHelper { public static SpecialKeyState CheckModifiers() { diff --git a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs index 945a6f4ab..757834b07 100644 --- a/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs +++ b/src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs @@ -223,7 +223,6 @@ namespace PowerLauncher.Helper /// public static class SingleInstance where TApplication : Application, ISingleInstanceApp - { /// /// String delimiter used in channel names. @@ -369,7 +368,7 @@ namespace PowerLauncher.Helper /// /// Callback for activating first instance of the application. /// - /// Callback argument. + /// Callback argument. /// Always null. private static object ActivateFirstInstanceCallback(object _) { diff --git a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs index cecce0257..613079257 100644 --- a/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs +++ b/src/modules/launcher/PowerLauncher/Helper/WindowsInteropHelper.cs @@ -98,10 +98,10 @@ namespace PowerLauncher.Helper INPUTHARDWARE = 2, } - const string WINDOW_CLASS_CONSOLE = "ConsoleWindowClass"; - const string WINDOW_CLASS_WINTAB = "Flip3D"; - const string WINDOW_CLASS_PROGMAN = "Progman"; - const string WINDOW_CLASS_WORKERW = "WorkerW"; + private const string WINDOW_CLASS_CONSOLE = "ConsoleWindowClass"; + private const string WINDOW_CLASS_WINTAB = "Flip3D"; + private const string WINDOW_CLASS_PROGMAN = "Progman"; + private const string WINDOW_CLASS_WORKERW = "WorkerW"; public static bool IsWindowFullscreen() { @@ -181,7 +181,7 @@ namespace PowerLauncher.Helper } else { - using (var src = new HwndSource(new HwndSourceParameters())) + using (var src = new HwndSource(default(HwndSourceParameters))) { matrix = src.CompositionTarget.TransformFromDevice; } diff --git a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs index 7864d7ca5..d87807da1 100644 --- a/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/MainWindow.xaml.cs @@ -23,9 +23,9 @@ namespace PowerLauncher private Settings _settings; private MainViewModel _viewModel; private bool _isTextSetProgrammatically; - bool _deletePressed = false; - Timer _firstDeleteTimer = new Timer(); - bool _coldStateHotkeyPressed = false; + private bool _deletePressed = false; + private Timer _firstDeleteTimer = new Timer(); + private bool _coldStateHotkeyPressed = false; public MainWindow(Settings settings, MainViewModel mainVM) : this() @@ -133,7 +133,7 @@ namespace PowerLauncher } else if (e.PropertyName == nameof(MainViewModel.SystemQueryText)) { - this._isTextSetProgrammatically = true; + _isTextSetProgrammatically = true; if (_viewModel.Results != null) { SearchBox.QueryTextBox.Text = MainViewModel.GetSearchText( @@ -209,7 +209,7 @@ namespace PowerLauncher var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0); var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0); - var left = (dip2.X - ActualWidth) / 2 + dip1.X; + var left = ((dip2.X - ActualWidth) / 2) + dip1.X; return left; } @@ -218,7 +218,7 @@ namespace PowerLauncher var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height); - var top = (dip2.Y - this.SearchBox.ActualHeight) / 4 + dip1.Y; + var top = ((dip2.Y - SearchBox.ActualHeight) / 4) + dip1.Y; return top; } @@ -322,7 +322,7 @@ namespace PowerLauncher { if (_isTextSetProgrammatically) { - var textBox = ((TextBox)sender); + var textBox = (TextBox)sender; textBox.SelectionStart = textBox.Text.Length; _isTextSetProgrammatically = false; } diff --git a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs b/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs index f5e73617c..a22c07e16 100644 --- a/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs +++ b/src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs @@ -27,7 +27,7 @@ namespace PowerLauncher BitmapImage image = GetImageFromPath(ImageLoader.ErrorIconPath); if (image != null) { - this.Icon = image; + Icon = image; } ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); diff --git a/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs b/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs index fec24cc5c..9c6609624 100644 --- a/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs +++ b/src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs @@ -22,7 +22,7 @@ namespace PowerLauncher.Storage var span = DateTime.Now - dt; if (span.Days > 365) { - int years = (span.Days / 365); + int years = span.Days / 365; if (span.Days % 365 != 0) { years += 1; @@ -33,7 +33,7 @@ namespace PowerLauncher.Storage if (span.Days > 30) { - int months = (span.Days / 30); + int months = span.Days / 30; if (span.Days % 31 != 0) { months += 1; diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs index 0af2b1ead..036d0d3f2 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ContextMenuItemViewModel.cs @@ -25,15 +25,15 @@ namespace PowerLauncher.ViewModel { get { - return this._command; + return _command; } set { // ICommand does not implement the INotifyPropertyChanged interface and must call OnPropertyChanged() to prevent memory leaks - if (value != this._command) + if (value != _command) { - this._command = value; + _command = value; OnPropertyChanged(); } } diff --git a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs index 108351567..baeb4d458 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs @@ -29,10 +29,8 @@ namespace PowerLauncher.ViewModel { public class MainViewModel : BaseModel, ISavable, IDisposable { - private Query _currentQuery; private static Query _emptyQuery = new Query(); private static bool _disposed; - private string _queryTextBeforeLeaveResults; private readonly WoxJsonStorage _historyItemsStorage; private readonly WoxJsonStorage _userSelectedRecordStorage; @@ -41,6 +39,11 @@ namespace PowerLauncher.ViewModel private readonly QueryHistory _history; private readonly UserSelectedRecord _userSelectedRecord; private readonly TopMostRecord _topMostRecord; + private readonly object _addResultsLock = new object(); + private readonly Internationalization _translator = InternationalizationManager.Instance; + + private Query _currentQuery; + private string _queryTextBeforeLeaveResults; private CancellationTokenSource _updateSource { get; set; } @@ -50,11 +53,8 @@ namespace PowerLauncher.ViewModel private HotkeyManager _hotkeyManager { get; set; } private ushort _hotkeyHandle; - private readonly Internationalization _translator = InternationalizationManager.Instance; private System.Diagnostics.Stopwatch hotkeyTimer = new System.Diagnostics.Stopwatch(); - private readonly object _addResultsLock = new object(); - public MainViewModel(Settings settings) { _hotkeyManager = new HotkeyManager(); @@ -110,7 +110,8 @@ namespace PowerLauncher.ViewModel var plugin = (IResultUpdated)pair.Plugin; plugin.ResultsUpdated += (s, e) => { - Task.Run(() => + Task.Run( + () => { PluginManager.UpdatePluginMetadata(e.Results, pair.Metadata, e.Query); UpdateResultView(e.Results, e.Query, _updateToken); @@ -257,6 +258,7 @@ namespace PowerLauncher.ViewModel if (!string.IsNullOrEmpty(QueryText)) { ChangeQueryText(string.Empty, true); + // Push Event to UI SystemQuery has changed OnPropertyChanged(nameof(SystemQueryText)); } @@ -465,7 +467,8 @@ namespace PowerLauncher.ViewModel if (query != null) { _currentQuery = query; - Task.Run(() => + Task.Run( + () => { Thread.Sleep(20); var plugins = PluginManager.ValidPluginsForQuery(query); diff --git a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs index 4596dcd26..b58117224 100644 --- a/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs +++ b/src/modules/launcher/PowerLauncher/ViewModel/ResultViewModel.cs @@ -231,7 +231,7 @@ namespace PowerLauncher.ViewModel public bool HasSelectedContextButton() { - var isContextSelected = (ContextMenuSelectedIndex != NoSelectionIndex); + var isContextSelected = ContextMenuSelectedIndex != NoSelectionIndex; return isContextSelected; }