Skip to content

Commit

Permalink
wrapping up everything minus var renaming (#5952)
Browse files Browse the repository at this point in the history
  • Loading branch information
crutkas authored Aug 14, 2020
1 parent 913615f commit 5c1713f
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Microsoft.PowerToys.Settings.UI.Lib.ViewModels.Commands
{

public class RelayCommand<T> : ICommand
{
private readonly Action<T> execute;
Expand Down
3 changes: 2 additions & 1 deletion src/modules/launcher/PowerLauncher/ActionKeywords.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/modules/launcher/PowerLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public partial class App : IDisposable, ISingleInstanceApp
{
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;
Expand All @@ -35,7 +37,6 @@ public partial class App : IDisposable, ISingleInstanceApp
private MainWindow _mainWindow;
private ThemeManager _themeManager;
private SettingWindowViewModel _settingsVM;
private readonly Alphabet _alphabet = new Alphabet();
private StringMatcher _stringMatcher;
private SettingsWatcher _settingsWatcher;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace PowerLauncher.Helper
{
public class DataWebRequestFactory : IWebRequestCreate
{
class DataWebRequest : WebRequest
private class DataWebRequest : WebRequest
{
private readonly Uri m_uri;

Expand All @@ -25,7 +25,7 @@ public override WebResponse GetResponse()
}
}

class DataWebResponse : WebResponse
private class DataWebResponse : WebResponse
{
private readonly string m_contentType;
private readonly byte[] m_data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace PowerLauncher.Helper
{
class KeyboardHelper
internal class KeyboardHelper
{
public static SpecialKeyState CheckModifiers()
{
Expand Down
3 changes: 1 addition & 2 deletions src/modules/launcher/PowerLauncher/Helper/SingleInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,6 @@ public interface ISingleInstanceApp
/// </remarks>
public static class SingleInstance<TApplication>
where TApplication : Application, ISingleInstanceApp

{
/// <summary>
/// String delimiter used in channel names.
Expand Down Expand Up @@ -369,7 +368,7 @@ private static async Task SignalFirstInstance(string channelName)
/// <summary>
/// Callback for activating first instance of the application.
/// </summary>
/// <param name="arg">Callback argument.</param>
/// <param name="args">Callback argument.</param>
/// <returns>Always null.</returns>
private static object ActivateFirstInstanceCallback(object _)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ internal enum INPUTTYPE : uint
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()
{
Expand Down Expand Up @@ -181,7 +181,7 @@ public static Point TransformPixelsToDIP(Visual visual, double unitX, double uni
}
else
{
using (var src = new HwndSource(new HwndSourceParameters()))
using (var src = new HwndSource(default(HwndSourceParameters)))
{
matrix = src.CompositionTarget.TransformFromDevice;
}
Expand Down
14 changes: 7 additions & 7 deletions src/modules/launcher/PowerLauncher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ public partial class MainWindow : IDisposable
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()
Expand Down Expand Up @@ -133,7 +133,7 @@ private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e
}
else if (e.PropertyName == nameof(MainViewModel.SystemQueryText))
{
this._isTextSetProgrammatically = true;
_isTextSetProgrammatically = true;
if (_viewModel.Results != null)
{
SearchBox.QueryTextBox.Text = MainViewModel.GetSearchText(
Expand Down Expand Up @@ -209,7 +209,7 @@ private double WindowLeft()
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;
}

Expand All @@ -218,7 +218,7 @@ private double WindowTop()
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;
}

Expand Down Expand Up @@ -322,7 +322,7 @@ private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
{
if (_isTextSetProgrammatically)
{
var textBox = ((TextBox)sender);
var textBox = (TextBox)sender;
textBox.SelectionStart = textBox.Text.Length;
_isTextSetProgrammatically = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/launcher/PowerLauncher/ReportWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public ReportWindow(Exception exception)
BitmapImage image = GetImageFromPath(ImageLoader.ErrorIconPath);
if (image != null)
{
this.Icon = image;
Icon = image;
}

ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0);
Expand Down
4 changes: 2 additions & 2 deletions src/modules/launcher/PowerLauncher/Storage/HistoryItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ private static string DateTimeAgo(DateTime dt)
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;
Expand All @@ -33,7 +33,7 @@ private static string DateTimeAgo(DateTime dt)

if (span.Days > 30)
{
int months = (span.Days / 30);
int months = span.Days / 30;
if (span.Days % 31 != 0)
{
months += 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ public ICommand Command
{
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();
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/modules/launcher/PowerLauncher/ViewModel/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<QueryHistory> _historyItemsStorage;
private readonly WoxJsonStorage<UserSelectedRecord> _userSelectedRecordStorage;
Expand All @@ -41,6 +39,11 @@ public class MainViewModel : BaseModel, ISavable, IDisposable
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; }

Expand All @@ -50,11 +53,8 @@ public class MainViewModel : BaseModel, ISavable, IDisposable
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();
Expand Down Expand Up @@ -110,7 +110,8 @@ private void RegisterResultsUpdatedEvent()
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);
Expand Down Expand Up @@ -257,6 +258,7 @@ private void InitializeKeyCommands()
if (!string.IsNullOrEmpty(QueryText))
{
ChangeQueryText(string.Empty, true);
// Push Event to UI SystemQuery has changed
OnPropertyChanged(nameof(SystemQueryText));
}
Expand Down Expand Up @@ -465,7 +467,8 @@ private void QueryResults()
if (query != null)
{
_currentQuery = query;
Task.Run(() =>
Task.Run(
() =>
{
Thread.Sleep(20);
var plugins = PluginManager.ValidPluginsForQuery(query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public void SelectLastContextButton()

public bool HasSelectedContextButton()
{
var isContextSelected = (ContextMenuSelectedIndex != NoSelectionIndex);
var isContextSelected = ContextMenuSelectedIndex != NoSelectionIndex;
return isContextSelected;
}

Expand Down

0 comments on commit 5c1713f

Please sign in to comment.