whitespace changes (#5750)

This commit is contained in:
Clint Rutkas 2020-08-06 20:38:49 -07:00 committed by GitHub
parent b815718c26
commit 26bf05dd7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 37 additions and 23 deletions

View File

@ -106,7 +106,6 @@ namespace PowerLauncher
InternationalizationManager.Instance.ChangeLanguage(_settings.Language); InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
// main windows needs initialized before theme change because of blur settings // main windows needs initialized before theme change because of blur settings
Http.Proxy = _settings.Proxy; Http.Proxy = _settings.Proxy;
RegisterExitEvents(); RegisterExitEvents();
@ -203,7 +202,6 @@ namespace PowerLauncher
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false); // Dispose(disposing: false);
// } // }
public void Dispose() public void Dispose()
{ {
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method

View File

@ -34,6 +34,7 @@ namespace PowerLauncher.Helper
{ {
// handle ui thread exceptions // handle ui thread exceptions
Report(e?.Exception); Report(e?.Exception);
// prevent application exist, so the user can copy prompted error info // prevent application exist, so the user can copy prompted error info
e.Handled = true; e.Handled = true;
} }

View File

@ -17,21 +17,25 @@ namespace PowerLauncher.Helper
{ {
state.ShiftPressed = true; state.ShiftPressed = true;
} }
if ((Keyboard.GetKeyStates(Key.LWin) & KeyStates.Down) > 0 || if ((Keyboard.GetKeyStates(Key.LWin) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RWin) & KeyStates.Down) > 0) (Keyboard.GetKeyStates(Key.RWin) & KeyStates.Down) > 0)
{ {
state.WinPressed = true; state.WinPressed = true;
} }
if ((Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) > 0 || if ((Keyboard.GetKeyStates(Key.LeftCtrl) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RightCtrl) & KeyStates.Down) > 0) (Keyboard.GetKeyStates(Key.RightCtrl) & KeyStates.Down) > 0)
{ {
state.CtrlPressed = true; state.CtrlPressed = true;
} }
if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 || if ((Keyboard.GetKeyStates(Key.LeftAlt) & KeyStates.Down) > 0 ||
(Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0) (Keyboard.GetKeyStates(Key.RightAlt) & KeyStates.Down) > 0)
{ {
state.AltPressed = true; state.AltPressed = true;
} }
return state; return state;
} }
} }

View File

@ -44,6 +44,5 @@ namespace PowerLauncher.Helper
{ {
CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); CollectionChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
} }
} }
} }

View File

@ -188,6 +188,7 @@ namespace PowerLauncher.Helper
{ {
throw new Win32Exception(); throw new Win32Exception();
} }
var result = new string[numArgs]; var result = new string[numArgs];
for (int i = 0; i < numArgs; i++) for (int i = 0; i < numArgs; i++)
@ -201,11 +202,11 @@ namespace PowerLauncher.Helper
finally finally
{ {
IntPtr p = _LocalFree(argv); IntPtr p = _LocalFree(argv);
// Otherwise LocalFree failed. // Otherwise LocalFree failed.
// Assert.AreEqual(IntPtr.Zero, p); // Assert.AreEqual(IntPtr.Zero, p);
} }
} }
} }
public interface ISingleInstanceApp public interface ISingleInstanceApp
@ -359,6 +360,7 @@ namespace PowerLauncher.Helper
// Do an asynchronous call to ActivateFirstInstance function // Do an asynchronous call to ActivateFirstInstance function
Application.Current.Dispatcher.Invoke(ActivateFirstInstance); Application.Current.Dispatcher.Invoke(ActivateFirstInstance);
} }
// Disconnect client // Disconnect client
pipeServer.Disconnect(); pipeServer.Disconnect();
} }

View File

@ -186,6 +186,7 @@ namespace PowerLauncher.Helper
matrix = src.CompositionTarget.TransformFromDevice; matrix = src.CompositionTarget.TransformFromDevice;
} }
} }
return new Point((int)(matrix.M11 * unitX), (int)(matrix.M22 * unitY)); return new Point((int)(matrix.M11 * unitX), (int)(matrix.M22 * unitY));
} }

View File

@ -40,7 +40,6 @@ namespace PowerLauncher
_firstDeleteTimer.Elapsed += CheckForFirstDelete; _firstDeleteTimer.Elapsed += CheckForFirstDelete;
_firstDeleteTimer.Interval = 1000; _firstDeleteTimer.Interval = 1000;
} }
private void CheckForFirstDelete(object sender, ElapsedEventArgs e) private void CheckForFirstDelete(object sender, ElapsedEventArgs e)
@ -53,7 +52,6 @@ namespace PowerLauncher
PowerToysTelemetry.Log.WriteEvent(new LauncherFirstDeleteEvent()); PowerToysTelemetry.Log.WriteEvent(new LauncherFirstDeleteEvent());
} }
} }
} }
public MainWindow() public MainWindow()
@ -251,7 +249,7 @@ namespace PowerLauncher
} }
else if (e.Key == Key.Right) else if (e.Key == Key.Right)
{ {
if(SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length) if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
{ {
_viewModel.SelectNextContextMenuItemCommand.Execute(null); _viewModel.SelectNextContextMenuItemCommand.Execute(null);
e.Handled = true; e.Handled = true;
@ -261,7 +259,7 @@ namespace PowerLauncher
{ {
if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length) if (SearchBox.QueryTextBox.CaretIndex == SearchBox.QueryTextBox.Text.Length)
{ {
if(_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected()) if (_viewModel.Results != null && _viewModel.Results.IsContextMenuItemSelected())
{ {
_viewModel.SelectPreviousContextMenuItemCommand.Execute(null); _viewModel.SelectPreviousContextMenuItemCommand.Execute(null);
e.Handled = true; e.Handled = true;
@ -334,6 +332,7 @@ namespace PowerLauncher
{ {
SearchBox.AutoCompleteTextBlock.Text = string.Empty; SearchBox.AutoCompleteTextBlock.Text = string.Empty;
} }
_viewModel.QueryText = text; _viewModel.QueryText = text;
_viewModel.Query(); _viewModel.Query();
} }
@ -356,8 +355,8 @@ namespace PowerLauncher
{ {
_firstDeleteTimer.Start(); _firstDeleteTimer.Start();
} }
// (this.FindResource("IntroStoryboard") as Storyboard).Begin();
// (this.FindResource("IntroStoryboard") as Storyboard).Begin();
SearchBox.QueryTextBox.Focus(); SearchBox.QueryTextBox.Focus();
Keyboard.Focus(SearchBox.QueryTextBox); Keyboard.Focus(SearchBox.QueryTextBox);
@ -429,7 +428,6 @@ namespace PowerLauncher
// // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
// Dispose(disposing: false); // Dispose(disposing: false);
// } // }
public void Dispose() public void Dispose()
{ {
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method // Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method

View File

@ -25,10 +25,11 @@ namespace PowerLauncher
{ {
InitializeComponent(); InitializeComponent();
BitmapImage image = GetImageFromPath(ImageLoader.ErrorIconPath); BitmapImage image = GetImageFromPath(ImageLoader.ErrorIconPath);
if(image != null) if (image != null)
{ {
this.Icon = image; this.Icon = image;
} }
ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0); ErrorTextbox.Document.Blocks.FirstBlock.Margin = new Thickness(0);
SetException(exception); SetException(exception);
} }

View File

@ -26,6 +26,7 @@ namespace PowerLauncher
public SettingsWatcher(Settings settings) public SettingsWatcher(Settings settings)
{ {
_settings = settings; _settings = settings;
// Set up watcher // Set up watcher
_watcher = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings); _watcher = Microsoft.PowerToys.Settings.UI.Lib.Utilities.Helper.GetFileWatcher(PowerLauncherSettings.ModuleName, "settings.json", OverloadSettings);
@ -38,7 +39,7 @@ namespace PowerLauncher
Monitor.Enter(_watcherSyncObject); Monitor.Enter(_watcherSyncObject);
var retry = true; var retry = true;
var retryCount = 0; var retryCount = 0;
while(retry) while (retry)
{ {
try try
{ {
@ -90,6 +91,7 @@ namespace PowerLauncher
retry = false; retry = false;
} }
// the settings application can hold a lock on the settings.json file which will result in a IOException. // the settings application can hold a lock on the settings.json file which will result in a IOException.
// This should be changed to properly synch with the settings app instead of retrying. // This should be changed to properly synch with the settings app instead of retrying.
catch (IOException e) catch (IOException e)
@ -98,10 +100,12 @@ namespace PowerLauncher
{ {
retry = false; retry = false;
} }
Thread.Sleep(1000); Thread.Sleep(1000);
Debug.WriteLine(e.Message); Debug.WriteLine(e.Message);
} }
} }
Monitor.Exit(_watcherSyncObject); Monitor.Exit(_watcherSyncObject);
} }
@ -111,6 +115,5 @@ namespace PowerLauncher
HotkeyModel model = new HotkeyModel(hotkey.Alt, hotkey.Shift, hotkey.Win, hotkey.Ctrl, key); HotkeyModel model = new HotkeyModel(hotkey.Alt, hotkey.Shift, hotkey.Win, hotkey.Ctrl, key);
return model.ToString(); return model.ToString();
} }
} }
} }

View File

@ -27,6 +27,7 @@ namespace PowerLauncher.Storage
years += 1; years += 1;
return $"about {years} {(years == 1 ? "year" : "years")} ago"; return $"about {years} {(years == 1 ? "year" : "years")} ago";
} }
if (span.Days > 30) if (span.Days > 30)
{ {
int months = (span.Days / 30); int months = (span.Days / 30);
@ -34,6 +35,7 @@ namespace PowerLauncher.Storage
months += 1; months += 1;
return $"about {months} {(months == 1 ? "month" : "months")} ago"; return $"about {months} {(months == 1 ? "month" : "months")} ago";
} }
if (span.Days > 0) if (span.Days > 0)
return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago"; return $"about {span.Days} {(span.Days == 1 ? "day" : "days")} ago";
if (span.Hours > 0) if (span.Hours > 0)

View File

@ -43,7 +43,6 @@ namespace PowerLauncher.Storage
SubTitle = result.SubTitle SubTitle = result.SubTitle
}; };
records[result.OriginQuery.RawQuery] = record; records[result.OriginQuery.RawQuery] = record;
} }
public void Load(Dictionary<string, Record> dictionary) public void Load(Dictionary<string, Record> dictionary)

View File

@ -43,6 +43,7 @@ namespace PowerLauncher.Storage
{ {
return value; return value;
} }
return 0; return 0;
} }
} }

View File

@ -52,7 +52,6 @@ namespace PowerLauncher.ViewModel
PluginName = PluginName, PluginName = PluginName,
Trigger = triggerType.ToString(), Trigger = triggerType.ToString(),
ActionName = Title ActionName = Title
}; };
PowerToysTelemetry.Log.WriteEvent(eventData); PowerToysTelemetry.Log.WriteEvent(eventData);
} }

View File

@ -260,6 +260,7 @@ namespace PowerLauncher.ViewModel
if (!string.IsNullOrEmpty(QueryText)) if (!string.IsNullOrEmpty(QueryText))
{ {
ChangeQueryText(string.Empty, true); ChangeQueryText(string.Empty, true);
// Push Event to UI SystemQuery has changed // Push Event to UI SystemQuery has changed
OnPropertyChanged(nameof(SystemQueryText)); OnPropertyChanged(nameof(SystemQueryText));
} }
@ -337,6 +338,7 @@ namespace PowerLauncher.ViewModel
QueryText = string.Empty; QueryText = string.Empty;
} }
} }
_selectedResults.Visibility = Visibility.Visible; _selectedResults.Visibility = Visibility.Visible;
} }
} }
@ -360,7 +362,6 @@ namespace PowerLauncher.ViewModel
{ {
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent()); PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
} }
} }
} }
@ -535,7 +536,6 @@ namespace PowerLauncher.ViewModel
QueryLength = query.RawQuery.Length QueryLength = query.RawQuery.Length
}; };
PowerToysTelemetry.Log.WriteEvent(queryEvent); PowerToysTelemetry.Log.WriteEvent(queryEvent);
}, currentCancellationToken); }, currentCancellationToken);
} }
} }
@ -660,6 +660,7 @@ namespace PowerLauncher.ViewModel
{ {
StartHotkeyTimer(); StartHotkeyTimer();
} }
if (_settings.LastQueryMode == LastQueryMode.Empty) if (_settings.LastQueryMode == LastQueryMode.Empty)
{ {
ChangeQueryText(string.Empty); ChangeQueryText(string.Empty);
@ -772,7 +773,9 @@ namespace PowerLauncher.ViewModel
{ {
var _ = PluginManager.QueryForPlugin(plugin, query); var _ = PluginManager.QueryForPlugin(plugin, query);
} }
}; }
;
} }
public void HandleContextMenu(Key AcceleratorKey, ModifierKeys AcceleratorModifiers) public void HandleContextMenu(Key AcceleratorKey, ModifierKeys AcceleratorModifiers)
@ -819,6 +822,7 @@ namespace PowerLauncher.ViewModel
return query + input.Substring(query.Length); return query + input.Substring(query.Length);
} }
} }
return input; return input;
} }
@ -849,6 +853,7 @@ namespace PowerLauncher.ViewModel
{ {
_hotkeyManager?.UnregisterHotkey(_hotkeyHandle); _hotkeyManager?.UnregisterHotkey(_hotkeyHandle);
} }
_hotkeyManager?.Dispose(); _hotkeyManager?.Dispose();
_updateSource?.Dispose(); _updateSource?.Dispose();
_disposed = true; _disposed = true;

View File

@ -20,7 +20,7 @@ namespace PowerLauncher.ViewModel
{ {
Selection, Selection,
Hover Hover
}; }
public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>(); public ObservableCollection<ContextMenuItemViewModel> ContextMenuItems { get; } = new ObservableCollection<ContextMenuItemViewModel>();

View File

@ -23,8 +23,8 @@ namespace PowerLauncher.ViewModel
private readonly object _collectionLock = new object(); private readonly object _collectionLock = new object();
private readonly Settings _settings; private readonly Settings _settings;
// private int MaxResults => _settings?.MaxResultsToShow ?? 6;
// private int MaxResults => _settings?.MaxResultsToShow ?? 6;
public ResultsViewModel() public ResultsViewModel()
{ {
Results = new ResultCollection(); Results = new ResultCollection();
@ -105,6 +105,7 @@ namespace PowerLauncher.ViewModel
break; break;
} }
} }
return index; return index;
} }
@ -189,9 +190,9 @@ namespace PowerLauncher.ViewModel
public void SelectNextContextMenuItem() public void SelectNextContextMenuItem()
{ {
if(SelectedItem != null) if (SelectedItem != null)
{ {
if(!SelectedItem.SelectNextContextButton()) if (!SelectedItem.SelectNextContextButton())
{ {
SelectedItem.SelectLastContextButton(); SelectedItem.SelectLastContextButton();
} }
@ -229,7 +230,7 @@ namespace PowerLauncher.ViewModel
} }
List<ResultViewModel> newResults = new List<ResultViewModel>(newRawResults.Count); List<ResultViewModel> newResults = new List<ResultViewModel>(newRawResults.Count);
foreach(Result r in newRawResults) foreach (Result r in newRawResults)
{ {
newResults.Add(new ResultViewModel(r)); newResults.Add(new ResultViewModel(r));
ct.ThrowIfCancellationRequested(); ct.ThrowIfCancellationRequested();