mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
Dev/crutkas/fixing warnings (#5161)
* new lines & braces * Tabs /space auto fix Co-authored-by: Clint Rutkas <crutkas@microsoft.com>
This commit is contained in:
@@ -58,7 +58,8 @@ namespace PowerLauncher
|
||||
|
||||
private void OnStartup(object sender, StartupEventArgs e)
|
||||
{
|
||||
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => {
|
||||
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () =>
|
||||
{
|
||||
Dispose();
|
||||
Environment.Exit(0);
|
||||
});
|
||||
@@ -104,7 +105,7 @@ namespace PowerLauncher
|
||||
RegisterExitEvents();
|
||||
|
||||
_settingsWatcher = new SettingsWatcher(_settings);
|
||||
|
||||
|
||||
_mainVM.MainWindowVisibility = Visibility.Visible;
|
||||
_mainVM.ColdStartFix();
|
||||
_themeManager.ThemeChanged += OnThemeChanged;
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace PowerLauncher.Helper
|
||||
{
|
||||
private static void Report(Exception e)
|
||||
{
|
||||
if( e != null)
|
||||
if (e != null)
|
||||
{
|
||||
var logger = LogManager.GetLogger("UnHandledException");
|
||||
logger.Fatal(ExceptionFormatter.FormatException(e));
|
||||
|
||||
var reportWindow = new ReportWindow(e);
|
||||
reportWindow.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace PowerLauncher.Helper
|
||||
/// <param name="newItems"></param>
|
||||
public void Update(List<ResultViewModel> newItems)
|
||||
{
|
||||
if(newItems == null)
|
||||
if (newItems == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(newItems));
|
||||
}
|
||||
|
||||
|
||||
int newCount = newItems.Count;
|
||||
int oldCount = Items.Count;
|
||||
int location = newCount > oldCount ? oldCount : newCount;
|
||||
|
||||
@@ -16,7 +16,7 @@ using static PowerLauncher.Helper.WindowsInteropHelper;
|
||||
|
||||
// http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/
|
||||
// modified to allow single instance restart
|
||||
namespace PowerLauncher.Helper
|
||||
namespace PowerLauncher.Helper
|
||||
{
|
||||
internal enum WM
|
||||
{
|
||||
@@ -208,12 +208,12 @@ namespace PowerLauncher.Helper
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public interface ISingleInstanceApp
|
||||
{
|
||||
void OnSecondAppStarted();
|
||||
}
|
||||
public interface ISingleInstanceApp
|
||||
{
|
||||
void OnSecondAppStarted();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This class checks to make sure that only one instance of
|
||||
@@ -226,9 +226,9 @@ namespace PowerLauncher.Helper
|
||||
/// running as Administrator, can activate it with command line arguments.
|
||||
/// For most apps, this will not be much of an issue.
|
||||
/// </remarks>
|
||||
public static class SingleInstance<TApplication>
|
||||
where TApplication: Application , ISingleInstanceApp
|
||||
|
||||
public static class SingleInstance<TApplication>
|
||||
where TApplication : Application, ISingleInstanceApp
|
||||
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
@@ -260,7 +260,7 @@ namespace PowerLauncher.Helper
|
||||
/// If not, activates the first instance.
|
||||
/// </summary>
|
||||
/// <returns>True if this is the first instance of the application.</returns>
|
||||
internal static bool InitializeAsFirstInstance( string uniqueName )
|
||||
internal static bool InitializeAsFirstInstance(string uniqueName)
|
||||
{
|
||||
// Build unique application Id and the IPC channel name.
|
||||
string applicationIdentifier = uniqueName + Environment.UserName;
|
||||
@@ -298,7 +298,7 @@ namespace PowerLauncher.Helper
|
||||
/// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved.
|
||||
/// </summary>
|
||||
/// <returns>List of command line arg strings.</returns>
|
||||
private static IList<string> GetCommandLineArgs( string uniqueApplicationName )
|
||||
private static IList<string> GetCommandLineArgs(string uniqueApplicationName)
|
||||
{
|
||||
string[] args = null;
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace PowerLauncher.Helper
|
||||
}
|
||||
catch (NotSupportedException)
|
||||
{
|
||||
|
||||
|
||||
// The application was clickonce deployed
|
||||
// Clickonce deployed apps cannot receive traditional commandline arguments
|
||||
// As a workaround commandline arguments can be written to a shared location before
|
||||
@@ -353,7 +353,7 @@ namespace PowerLauncher.Helper
|
||||
{
|
||||
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(channelName, PipeDirection.In))
|
||||
{
|
||||
while(true)
|
||||
while (true)
|
||||
{
|
||||
// Wait for connection to the pipe
|
||||
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace PowerLauncher
|
||||
|
||||
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if(e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
||||
if (e.PropertyName == nameof(MainViewModel.MainWindowVisibility))
|
||||
{
|
||||
if (Visibility == System.Windows.Visibility.Visible)
|
||||
{
|
||||
@@ -124,7 +124,7 @@ namespace PowerLauncher
|
||||
_viewModel.LastQuerySelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.PropertyName == nameof(MainViewModel.SystemQueryText))
|
||||
{
|
||||
this._isTextSetProgrammatically = true;
|
||||
@@ -153,19 +153,19 @@ namespace PowerLauncher
|
||||
|
||||
private void OnActivated(object sender, EventArgs e)
|
||||
{
|
||||
if (_settings.ClearInputOnLaunch)
|
||||
{
|
||||
_viewModel.ClearQueryCommand.Execute(null);
|
||||
}
|
||||
if (_settings.ClearInputOnLaunch)
|
||||
{
|
||||
_viewModel.ClearQueryCommand.Execute(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeactivated(object sender, EventArgs e)
|
||||
{
|
||||
if (_settings.HideWhenDeactivated)
|
||||
if (_settings.HideWhenDeactivated)
|
||||
{
|
||||
//(this.FindResource("OutroStoryboard") as Storyboard).Begin();
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePosition()
|
||||
@@ -176,7 +176,7 @@ namespace PowerLauncher
|
||||
Top = _settings.WindowTop;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Top = WindowTop();
|
||||
Left = WindowLeft();
|
||||
}
|
||||
@@ -290,7 +290,7 @@ namespace PowerLauncher
|
||||
private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
ListView listview = (ListView)sender;
|
||||
_viewModel.Results.SelectedItem = (ResultViewModel) listview.SelectedItem;
|
||||
_viewModel.Results.SelectedItem = (ResultViewModel)listview.SelectedItem;
|
||||
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||
{
|
||||
listview.ScrollIntoView(e.AddedItems[0]);
|
||||
@@ -304,7 +304,7 @@ namespace PowerLauncher
|
||||
_viewModel.Results.SelectedIndex,
|
||||
_viewModel.Results.SelectedItem?.ToString(),
|
||||
_viewModel.QueryText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private const int millisecondsToWait = 100;
|
||||
@@ -312,7 +312,7 @@ namespace PowerLauncher
|
||||
private bool disposedValue = false;
|
||||
|
||||
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
{
|
||||
if (_isTextSetProgrammatically)
|
||||
{
|
||||
var textBox = ((TextBox)sender);
|
||||
@@ -345,7 +345,7 @@ namespace PowerLauncher
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Right)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Wox
|
||||
}
|
||||
|
||||
public void ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true)
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
public void InstallPlugin(string path)
|
||||
@@ -115,16 +115,16 @@ namespace Wox
|
||||
{
|
||||
ThemeChanged?.Invoke(oldTheme, newTheme);
|
||||
}
|
||||
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
_themeManager.ThemeChanged -= OnThemeChanged;
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
namespace PowerLauncher.Properties {
|
||||
|
||||
|
||||
namespace PowerLauncher.Properties
|
||||
{
|
||||
|
||||
|
||||
// This class allows you to handle specific events on the settings class:
|
||||
// The SettingChanging event is raised before a setting's value is changed.
|
||||
// The PropertyChanged event is raised after a setting's value is changed.
|
||||
// The SettingsLoaded event is raised after the setting values are loaded.
|
||||
// The SettingsSaving event is raised before the setting values are saved.
|
||||
internal sealed partial class Settings {
|
||||
|
||||
public Settings() {
|
||||
internal sealed partial class Settings
|
||||
{
|
||||
|
||||
public Settings()
|
||||
{
|
||||
// // To add event handlers for saving and changing settings, uncomment the lines below:
|
||||
//
|
||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||
@@ -16,12 +19,14 @@
|
||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
||||
//
|
||||
}
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
|
||||
|
||||
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e)
|
||||
{
|
||||
// Add code to handle the SettingChangingEvent event here.
|
||||
}
|
||||
|
||||
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
|
||||
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
// Add code to handle the SettingsSaving event here.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace PowerLauncher
|
||||
{
|
||||
_settings = settings;
|
||||
// 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);
|
||||
|
||||
// Load initial settings file
|
||||
OverloadSettings();
|
||||
@@ -75,7 +75,7 @@ namespace PowerLauncher
|
||||
|
||||
if (_settings.ClearInputOnLaunch != overloadSettings.Properties.clear_input_on_launch)
|
||||
{
|
||||
_settings.ClearInputOnLaunch = overloadSettings.Properties.clear_input_on_launch;
|
||||
_settings.ClearInputOnLaunch = overloadSettings.Properties.clear_input_on_launch;
|
||||
}
|
||||
}
|
||||
// the settings application can hold a lock on the settings.json file which will result in a IOException.
|
||||
|
||||
@@ -15,7 +15,8 @@ namespace PowerLauncher.ViewModel
|
||||
public string Title { get; set; }
|
||||
public string Glyph { get; set; }
|
||||
public string FontFamily { get; set; }
|
||||
public ICommand Command {
|
||||
public ICommand Command
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._command;
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
private void InitializeKeyCommands()
|
||||
{
|
||||
IgnoreCommand = new RelayCommand(_ => {});
|
||||
IgnoreCommand = new RelayCommand(_ => { });
|
||||
|
||||
EscCommand = new RelayCommand(_ =>
|
||||
{
|
||||
@@ -187,7 +187,7 @@ namespace PowerLauncher.ViewModel
|
||||
results.SelectedIndex = int.Parse(index.ToString(), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
if(results.SelectedItem != null)
|
||||
if (results.SelectedItem != null)
|
||||
{
|
||||
//If there is a context button selected fire the action for that button before the main command.
|
||||
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
|
||||
@@ -218,7 +218,7 @@ namespace PowerLauncher.ViewModel
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
LoadContextMenuCommand = new RelayCommand(_ =>
|
||||
@@ -248,12 +248,12 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
ClearQueryCommand = new RelayCommand(_ =>
|
||||
{
|
||||
if(!string.IsNullOrEmpty(QueryText))
|
||||
if (!string.IsNullOrEmpty(QueryText))
|
||||
{
|
||||
ChangeQueryText(string.Empty,true);
|
||||
//Push Event to UI SystemQuery has changed
|
||||
OnPropertyChanged(nameof(SystemQueryText));
|
||||
}
|
||||
ChangeQueryText(string.Empty, true);
|
||||
//Push Event to UI SystemQuery has changed
|
||||
OnPropertyChanged(nameof(SystemQueryText));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -271,7 +271,7 @@ namespace PowerLauncher.ViewModel
|
||||
public string SystemQueryText { get; set; } = String.Empty;
|
||||
|
||||
public string QueryText { get; set; } = String.Empty;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// we need move cursor to end when we manually changed query
|
||||
@@ -280,11 +280,11 @@ namespace PowerLauncher.ViewModel
|
||||
/// </summary>
|
||||
/// <param name="queryText"></param>
|
||||
/// <param name="requery">Optional Parameter that if true, will automatically execute a query against the updated text</param>
|
||||
public void ChangeQueryText(string queryText, bool requery=false)
|
||||
public void ChangeQueryText(string queryText, bool requery = false)
|
||||
{
|
||||
SystemQueryText = queryText;
|
||||
|
||||
if(requery)
|
||||
|
||||
if (requery)
|
||||
{
|
||||
QueryText = queryText;
|
||||
Query();
|
||||
@@ -332,11 +332,13 @@ namespace PowerLauncher.ViewModel
|
||||
|
||||
private Visibility _visibility;
|
||||
|
||||
public Visibility MainWindowVisibility {
|
||||
public Visibility MainWindowVisibility
|
||||
{
|
||||
get { return _visibility; }
|
||||
set {
|
||||
set
|
||||
{
|
||||
_visibility = value;
|
||||
if(value == Visibility.Visible)
|
||||
if (value == Visibility.Visible)
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent());
|
||||
}
|
||||
@@ -344,7 +346,7 @@ namespace PowerLauncher.ViewModel
|
||||
{
|
||||
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,7 +505,7 @@ namespace PowerLauncher.ViewModel
|
||||
_updateSource?.Cancel();
|
||||
_lastQuery = _emptyQuery;
|
||||
Results.SelectedItem = null;
|
||||
Results.Clear();
|
||||
Results.Clear();
|
||||
Results.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
@@ -569,7 +571,7 @@ namespace PowerLauncher.ViewModel
|
||||
hotkey.Shift = hotkeyModel.Shift;
|
||||
hotkey.Ctrl = hotkeyModel.Ctrl;
|
||||
hotkey.Win = hotkeyModel.Win;
|
||||
hotkey.Key = (byte) KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey);
|
||||
hotkey.Key = (byte)KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey);
|
||||
|
||||
_hotkeyHandle = _hotkeyManager.RegisterHotkey(hotkey, action);
|
||||
}
|
||||
@@ -672,7 +674,7 @@ namespace PowerLauncher.ViewModel
|
||||
/// </summary>
|
||||
public void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
|
||||
{
|
||||
if(list == null)
|
||||
if (list == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(list));
|
||||
}
|
||||
@@ -799,8 +801,8 @@ namespace PowerLauncher.ViewModel
|
||||
_hotkeyManager.Dispose();
|
||||
_updateSource.Dispose();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace PowerLauncher.ViewModel
|
||||
{
|
||||
Result = result;
|
||||
}
|
||||
|
||||
|
||||
ContextMenuSelectedIndex = NoSelectionIndex;
|
||||
LoadContextMenu();
|
||||
|
||||
|
||||
ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction);
|
||||
ActivateContextButtonsSelectionCommand = new RelayCommand(ActivateContextButtonsSelectionAction);
|
||||
DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction);
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace PowerLauncher.ViewModel
|
||||
public void SelectNextTabItem()
|
||||
{
|
||||
//Do nothing if there is no selected item or we've selected the next context button
|
||||
if(!SelectedItem?.SelectNextContextButton() ?? true)
|
||||
if (!SelectedItem?.SelectNextContextButton() ?? true)
|
||||
{
|
||||
SelectNextResult();
|
||||
}
|
||||
@@ -320,6 +320,6 @@ namespace PowerLauncher.ViewModel
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ namespace PowerLauncher.ViewModel
|
||||
#region about
|
||||
|
||||
public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user