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:
parent
6efec9d280
commit
14247fa75a
|
@ -13,7 +13,7 @@ namespace Microsoft.PowerToys.Telemetry
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PowerToysTelemetry : TelemetryBase
|
public class PowerToysTelemetry : TelemetryBase
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Name for ETW event.
|
/// Name for ETW event.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -7,7 +7,6 @@ using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
{
|
{
|
||||||
|
|
||||||
// Represents the configuration property of the settings that store Double type.
|
// Represents the configuration property of the settings that store Double type.
|
||||||
public class DoubleProperty
|
public class DoubleProperty
|
||||||
{
|
{
|
||||||
|
|
|
@ -148,7 +148,7 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null )
|
private void LogTelemetryEvent(bool value, [CallerMemberName] string moduleName = null)
|
||||||
{
|
{
|
||||||
var dataEvent = new SettingsEnabledEvent()
|
var dataEvent = new SettingsEnabledEvent()
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,4 +26,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
|
|
||||||
public PowerPreviewProperties()
|
public PowerPreviewProperties()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
|
|
@ -7,7 +7,6 @@ using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
{
|
{
|
||||||
|
|
||||||
public class PowerRenameLocalProperties
|
public class PowerRenameLocalProperties
|
||||||
{
|
{
|
||||||
public PowerRenameLocalProperties()
|
public PowerRenameLocalProperties()
|
||||||
|
|
|
@ -13,7 +13,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
|
|
||||||
public PowerRenameSettingsIPCMessage()
|
public PowerRenameSettingsIPCMessage()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings)
|
public PowerRenameSettingsIPCMessage(SndPowerRenameSettings settings)
|
||||||
|
|
|
@ -9,7 +9,6 @@ using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
{
|
{
|
||||||
|
|
||||||
public class ShortcutGuideProperties
|
public class ShortcutGuideProperties
|
||||||
{
|
{
|
||||||
public ShortcutGuideProperties()
|
public ShortcutGuideProperties()
|
||||||
|
|
|
@ -17,7 +17,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
|
|
||||||
public ShortcutGuideSettingsIPCMessage()
|
public ShortcutGuideSettingsIPCMessage()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings)
|
public ShortcutGuideSettingsIPCMessage(SndShortcutGuideSettings settings)
|
||||||
|
@ -30,4 +29,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
{
|
{
|
||||||
|
|
||||||
public class SndImageResizerSettings
|
public class SndImageResizerSettings
|
||||||
{
|
{
|
||||||
[JsonPropertyName("Image Resizer")]
|
[JsonPropertyName("Image Resizer")]
|
||||||
|
|
|
@ -27,4 +27,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using System.Text.Json.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.Lib
|
namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
{
|
{
|
||||||
|
|
||||||
public class SndShortcutGuideSettings
|
public class SndShortcutGuideSettings
|
||||||
{
|
{
|
||||||
[JsonPropertyName("Shortcut Guide")]
|
[JsonPropertyName("Shortcut Guide")]
|
||||||
|
@ -14,7 +13,6 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
|
|
||||||
public SndShortcutGuideSettings()
|
public SndShortcutGuideSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SndShortcutGuideSettings(ShortcutGuideSettings settings)
|
public SndShortcutGuideSettings(ShortcutGuideSettings settings)
|
||||||
|
@ -27,4 +25,4 @@ namespace Microsoft.PowerToys.Settings.UI.Lib
|
||||||
return JsonSerializer.Serialize(this);
|
return JsonSerializer.Serialize(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ namespace Microsoft.PowerToys.Settings.UI.Runner
|
||||||
IsUserAnAdmin = false;
|
IsUserAnAdmin = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () => {
|
RunnerHelper.WaitForPowerToysRunner(PowerToysPID, () =>
|
||||||
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.PowerToys.Settings.UI.Helpers
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
protected void Set<T>(ref T storage, T value, [CallerMemberName]string propertyName = null)
|
protected void Set<T>(ref T storage, T value, [CallerMemberName] string propertyName = null)
|
||||||
{
|
{
|
||||||
if (Equals(storage, value))
|
if (Equals(storage, value))
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,258 +1,258 @@
|
||||||
// Copyright (c) Microsoft Corporation
|
// Copyright (c) Microsoft Corporation
|
||||||
// The Microsoft Corporation licenses this file to you under the MIT license.
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
|
||||||
using Microsoft.PowerToys.Settings.UI.Helpers;
|
using Microsoft.PowerToys.Settings.UI.Helpers;
|
||||||
using Microsoft.PowerToys.Settings.UI.Lib;
|
using Microsoft.PowerToys.Settings.UI.Lib;
|
||||||
using Microsoft.PowerToys.Settings.UI.Views;
|
using Microsoft.PowerToys.Settings.UI.Views;
|
||||||
|
|
||||||
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
{
|
{
|
||||||
public class PowerLauncherViewModel : Observable
|
public class PowerLauncherViewModel : Observable
|
||||||
{
|
{
|
||||||
private PowerLauncherSettings settings;
|
private PowerLauncherSettings settings;
|
||||||
private GeneralSettings generalSettings;
|
private GeneralSettings generalSettings;
|
||||||
|
|
||||||
public delegate void SendCallback(PowerLauncherSettings settings);
|
public delegate void SendCallback(PowerLauncherSettings settings);
|
||||||
|
|
||||||
private readonly SendCallback callback;
|
private readonly SendCallback callback;
|
||||||
|
|
||||||
public PowerLauncherViewModel()
|
public PowerLauncherViewModel()
|
||||||
{
|
{
|
||||||
callback = (PowerLauncherSettings settings) =>
|
callback = (PowerLauncherSettings settings) =>
|
||||||
{
|
{
|
||||||
// Propagate changes to Power Launcher through IPC
|
// Propagate changes to Power Launcher through IPC
|
||||||
ShellPage.DefaultSndMSGCallback(
|
ShellPage.DefaultSndMSGCallback(
|
||||||
string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings)));
|
string.Format("{{ \"powertoys\": {{ \"{0}\": {1} }} }}", PowerLauncherSettings.ModuleName, JsonSerializer.Serialize(settings)));
|
||||||
};
|
};
|
||||||
if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName))
|
if (SettingsUtils.SettingsExists(PowerLauncherSettings.ModuleName))
|
||||||
{
|
{
|
||||||
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
settings = SettingsUtils.GetSettings<PowerLauncherSettings>(PowerLauncherSettings.ModuleName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
settings = new PowerLauncherSettings();
|
settings = new PowerLauncherSettings();
|
||||||
settings.Properties.open_powerlauncher.Alt = true;
|
settings.Properties.open_powerlauncher.Alt = true;
|
||||||
settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space;
|
settings.Properties.open_powerlauncher.Code = (int)Windows.System.VirtualKey.Space;
|
||||||
settings.Properties.maximum_number_of_results = 4;
|
settings.Properties.maximum_number_of_results = 4;
|
||||||
callback(settings);
|
callback(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SettingsUtils.SettingsExists())
|
if (SettingsUtils.SettingsExists())
|
||||||
{
|
{
|
||||||
generalSettings = SettingsUtils.GetSettings<GeneralSettings>();
|
generalSettings = SettingsUtils.GetSettings<GeneralSettings>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
generalSettings = new GeneralSettings();
|
generalSettings = new GeneralSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)
|
public PowerLauncherViewModel(PowerLauncherSettings settings, SendCallback callback)
|
||||||
{
|
{
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSettings([CallerMemberName] string propertyName = null)
|
private void UpdateSettings([CallerMemberName] string propertyName = null)
|
||||||
{
|
{
|
||||||
// Notify UI of property change
|
// Notify UI of property change
|
||||||
OnPropertyChanged(propertyName);
|
OnPropertyChanged(propertyName);
|
||||||
|
|
||||||
callback(settings);
|
callback(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool EnablePowerLauncher
|
public bool EnablePowerLauncher
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return generalSettings.Enabled.PowerLauncher;
|
return generalSettings.Enabled.PowerLauncher;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (generalSettings.Enabled.PowerLauncher != value)
|
if (generalSettings.Enabled.PowerLauncher != value)
|
||||||
{
|
{
|
||||||
generalSettings.Enabled.PowerLauncher = value;
|
generalSettings.Enabled.PowerLauncher = value;
|
||||||
OnPropertyChanged(nameof(EnablePowerLauncher));
|
OnPropertyChanged(nameof(EnablePowerLauncher));
|
||||||
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings);
|
OutGoingGeneralSettings outgoing = new OutGoingGeneralSettings(generalSettings);
|
||||||
ShellPage.DefaultSndMSGCallback(outgoing.ToString());
|
ShellPage.DefaultSndMSGCallback(outgoing.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SearchResultPreference
|
public string SearchResultPreference
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.search_result_preference;
|
return settings.Properties.search_result_preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.search_result_preference != value)
|
if (settings.Properties.search_result_preference != value)
|
||||||
{
|
{
|
||||||
settings.Properties.search_result_preference = value;
|
settings.Properties.search_result_preference = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SearchTypePreference
|
public string SearchTypePreference
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.search_type_preference;
|
return settings.Properties.search_type_preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.search_type_preference != value)
|
if (settings.Properties.search_type_preference != value)
|
||||||
{
|
{
|
||||||
settings.Properties.search_type_preference = value;
|
settings.Properties.search_type_preference = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int MaximumNumberOfResults
|
public int MaximumNumberOfResults
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.maximum_number_of_results;
|
return settings.Properties.maximum_number_of_results;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.maximum_number_of_results != value)
|
if (settings.Properties.maximum_number_of_results != value)
|
||||||
{
|
{
|
||||||
settings.Properties.maximum_number_of_results = value;
|
settings.Properties.maximum_number_of_results = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HotkeySettings OpenPowerLauncher
|
public HotkeySettings OpenPowerLauncher
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.open_powerlauncher;
|
return settings.Properties.open_powerlauncher;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.open_powerlauncher != value)
|
if (settings.Properties.open_powerlauncher != value)
|
||||||
{
|
{
|
||||||
settings.Properties.open_powerlauncher = value;
|
settings.Properties.open_powerlauncher = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HotkeySettings OpenFileLocation
|
public HotkeySettings OpenFileLocation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.open_file_location;
|
return settings.Properties.open_file_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.open_file_location != value)
|
if (settings.Properties.open_file_location != value)
|
||||||
{
|
{
|
||||||
settings.Properties.open_file_location = value;
|
settings.Properties.open_file_location = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HotkeySettings CopyPathLocation
|
public HotkeySettings CopyPathLocation
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.copy_path_location;
|
return settings.Properties.copy_path_location;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.copy_path_location != value)
|
if (settings.Properties.copy_path_location != value)
|
||||||
{
|
{
|
||||||
settings.Properties.copy_path_location = value;
|
settings.Properties.copy_path_location = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OverrideWinRKey
|
public bool OverrideWinRKey
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.override_win_r_key;
|
return settings.Properties.override_win_r_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.override_win_r_key != value)
|
if (settings.Properties.override_win_r_key != value)
|
||||||
{
|
{
|
||||||
settings.Properties.override_win_r_key = value;
|
settings.Properties.override_win_r_key = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OverrideWinSKey
|
public bool OverrideWinSKey
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.override_win_s_key;
|
return settings.Properties.override_win_s_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.override_win_s_key != value)
|
if (settings.Properties.override_win_s_key != value)
|
||||||
{
|
{
|
||||||
settings.Properties.override_win_s_key = value;
|
settings.Properties.override_win_s_key = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IgnoreHotkeysInFullScreen
|
public bool IgnoreHotkeysInFullScreen
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.ignore_hotkeys_in_fullscreen;
|
return settings.Properties.ignore_hotkeys_in_fullscreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.ignore_hotkeys_in_fullscreen != value)
|
if (settings.Properties.ignore_hotkeys_in_fullscreen != value)
|
||||||
{
|
{
|
||||||
settings.Properties.ignore_hotkeys_in_fullscreen = value;
|
settings.Properties.ignore_hotkeys_in_fullscreen = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ClearInputOnLaunch
|
public bool ClearInputOnLaunch
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return settings.Properties.clear_input_on_launch;
|
return settings.Properties.clear_input_on_launch;
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (settings.Properties.clear_input_on_launch != value)
|
if (settings.Properties.clear_input_on_launch != value)
|
||||||
{
|
{
|
||||||
settings.Properties.clear_input_on_launch = value;
|
settings.Properties.clear_input_on_launch = value;
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DisableDriveDetectionWarning
|
public bool DisableDriveDetectionWarning
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -268,6 +268,6 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
UpdateSettings();
|
UpdateSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,4 +195,4 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace CommonLibTest
|
||||||
BasePTSettingsTest expected_json = JsonSerializer.Deserialize<BasePTSettingsTest>(file_contents_correct_json_content);
|
BasePTSettingsTest expected_json = JsonSerializer.Deserialize<BasePTSettingsTest>(file_contents_correct_json_content);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
if(SettingsUtils.SettingsFolderExists(file_name))
|
if (SettingsUtils.SettingsFolderExists(file_name))
|
||||||
{
|
{
|
||||||
DeleteFolder(file_name);
|
DeleteFolder(file_name);
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace CommonLibTest
|
||||||
public void SettingsFolderExists_ShouldReturnFalse_WhenFilePathIsNotFound()
|
public void SettingsFolderExists_ShouldReturnFalse_WhenFilePathIsNotFound()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
string file_name_random = "test\\"+ RandomString();
|
string file_name_random = "test\\" + RandomString();
|
||||||
string file_name_exists = "test\\exists";
|
string file_name_exists = "test\\exists";
|
||||||
string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
|
string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Microsoft.PowerToys.Settings.UnitTest
|
||||||
// Place the frame in the current Window
|
// Place the frame in the current Window
|
||||||
Window.Current.Content = rootFrame;
|
Window.Current.Content = rootFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
|
Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
|
||||||
|
|
||||||
// Ensure the current window is active
|
// Ensure the current window is active
|
||||||
|
|
|
@ -272,7 +272,7 @@ namespace ViewModelTests
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
||||||
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesZoneHighlightColor, ToRGBHex(viewModel.ZoneHighlightColor));
|
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesZoneHighlightColor, ToRGBHex(viewModel.ZoneHighlightColor));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
ShellPage.DefaultSndMSGCallback = msg =>
|
ShellPage.DefaultSndMSGCallback = msg =>
|
||||||
|
@ -282,7 +282,7 @@ namespace ViewModelTests
|
||||||
};
|
};
|
||||||
|
|
||||||
// act
|
// act
|
||||||
viewModel.ZoneHighlightColor = Color.FromArgb(0, 225,225,225);
|
viewModel.ZoneHighlightColor = Color.FromArgb(0, 225, 225, 225);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -290,7 +290,7 @@ namespace ViewModelTests
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
||||||
Assert.AreEqual(ConfigDefaults.DefaultFancyzonesBorderColor, ToRGBHex(viewModel.ZoneBorderColor));
|
Assert.AreEqual(ConfigDefaults.DefaultFancyzonesBorderColor, ToRGBHex(viewModel.ZoneBorderColor));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
ShellPage.DefaultSndMSGCallback = msg =>
|
ShellPage.DefaultSndMSGCallback = msg =>
|
||||||
|
@ -308,7 +308,7 @@ namespace ViewModelTests
|
||||||
{
|
{
|
||||||
// arrange
|
// arrange
|
||||||
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
FancyZonesViewModel viewModel = new FancyZonesViewModel();
|
||||||
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, ToRGBHex(viewModel.ZoneInActiveColor));
|
Assert.AreEqual(ConfigDefaults.DefaultFancyZonesInActiveColor, ToRGBHex(viewModel.ZoneInActiveColor));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
ShellPage.DefaultSndMSGCallback = msg =>
|
ShellPage.DefaultSndMSGCallback = msg =>
|
||||||
|
|
|
@ -49,10 +49,10 @@ namespace ViewModelTests
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
GeneralViewModel viewModel = new GeneralViewModel();
|
GeneralViewModel viewModel = new GeneralViewModel();
|
||||||
|
|
||||||
Assert.AreEqual(viewModel.RunningAsUserDefaultText, viewModel.RunningAsText);
|
Assert.AreEqual(viewModel.RunningAsUserDefaultText, viewModel.RunningAsText);
|
||||||
Assert.IsFalse(viewModel.IsElevated);
|
Assert.IsFalse(viewModel.IsElevated);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
viewModel.IsElevated = true;
|
viewModel.IsElevated = true;
|
||||||
|
|
||||||
|
|
|
@ -46,12 +46,13 @@ namespace ColorPickerUI
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_args.Length > 0)
|
if (_args.Length > 0)
|
||||||
{
|
{
|
||||||
_ = int.TryParse(_args[0], out _powerToysPid);
|
_ = int.TryParse(_args[0], out _powerToysPid);
|
||||||
}
|
}
|
||||||
|
|
||||||
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => {
|
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () =>
|
||||||
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ namespace ColorPicker.Behaviors
|
||||||
{
|
{
|
||||||
var sender = ((ResizeBehavior)d).AssociatedObject;
|
var sender = ((ResizeBehavior)d).AssociatedObject;
|
||||||
var move = new DoubleAnimation(sender.Width, (double)e.NewValue, new Duration(TimeSpan.FromMilliseconds(150)), FillBehavior.Stop);
|
var move = new DoubleAnimation(sender.Width, (double)e.NewValue, new Duration(TimeSpan.FromMilliseconds(150)), FillBehavior.Stop);
|
||||||
move.Completed += (s, e1) => {
|
move.Completed += (s, e1) =>
|
||||||
|
{
|
||||||
sender.BeginAnimation(FrameworkElement.WidthProperty, null); sender.Width = (double)e.NewValue;
|
sender.BeginAnimation(FrameworkElement.WidthProperty, null); sender.Width = (double)e.NewValue;
|
||||||
};
|
};
|
||||||
move.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseOut };
|
move.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseOut };
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace ColorPicker.Mouse
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(curFile != null)
|
if (curFile != null)
|
||||||
{
|
{
|
||||||
Registry.SetValue(CursorsRegistryPath, cursorRegistryName, curFile);
|
Registry.SetValue(CursorsRegistryPath, cursorRegistryName, curFile);
|
||||||
Win32Apis.SystemParametersInfo(SPI_SETCURSORS, 0, new IntPtr(0), SPIF_SENDCHANGE);
|
Win32Apis.SystemParametersInfo(SPI_SETCURSORS, 0, new IntPtr(0), SPIF_SENDCHANGE);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace ColorPicker.Settings
|
||||||
ChangeCursor = new SettingItem<bool>(true);
|
ChangeCursor = new SettingItem<bool>(true);
|
||||||
ActivationShortcut = new SettingItem<string>(DefaultActivationShortcut);
|
ActivationShortcut = new SettingItem<string>(DefaultActivationShortcut);
|
||||||
CopiedColorRepresentation = new SettingItem<ColorRepresentationType>(ColorRepresentationType.HEX);
|
CopiedColorRepresentation = new SettingItem<ColorRepresentationType>(ColorRepresentationType.HEX);
|
||||||
|
|
||||||
LoadSettingsFromJson();
|
LoadSettingsFromJson();
|
||||||
_watcher = Helper.GetFileWatcher(ColorPickerModuleName, "settings.json", LoadSettingsFromJson);
|
_watcher = Helper.GetFileWatcher(ColorPickerModuleName, "settings.json", LoadSettingsFromJson);
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ namespace ColorPicker.Settings
|
||||||
Logger.LogError("Failed to read changed settings", ex);
|
Logger.LogError("Failed to read changed settings", ex);
|
||||||
Thread.Sleep(500);
|
Thread.Sleep(500);
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError("Failed to read changed settings", ex);
|
Logger.LogError("Failed to read changed settings", ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ namespace FancyZonesEditor
|
||||||
|
|
||||||
private void OnStartup(object sender, StartupEventArgs e)
|
private void OnStartup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
RunnerHelper.WaitForPowerToysRunner(Settings.PowerToysPID, () => {
|
RunnerHelper.WaitForPowerToysRunner(Settings.PowerToysPID, () =>
|
||||||
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace FancyZonesEditor
|
||||||
internal static class Native
|
internal static class Native
|
||||||
{
|
{
|
||||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||||
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)]string lpFileName);
|
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
|
||||||
|
|
||||||
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
|
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
|
||||||
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Calculator
|
||||||
var result = MagesEngine.Interpret(query.Search);
|
var result = MagesEngine.Interpret(query.Search);
|
||||||
|
|
||||||
// This could happen for some incorrect queries, like pi(2)
|
// This could happen for some incorrect queries, like pi(2)
|
||||||
if(result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
return new List<Result>();
|
return new List<Result>();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ namespace Microsoft.Plugin.Calculator
|
||||||
thread.Join();
|
thread.Join();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Microsoft.Plugin.Calculator
|
||||||
{
|
{
|
||||||
return Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
|
return Translate(input, this.sourceCulture, this.targetCulture, this.splitRegexForSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Translate from target to source culture.
|
/// Translate from target to source culture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace Microsoft.Plugin.Folder
|
||||||
{
|
{
|
||||||
Process.Start("explorer.exe", $" /select,\"{record.FullPath}\"");
|
Process.Start("explorer.exe", $" /select,\"{record.FullPath}\"");
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var message = $"Fail to open file at {record.FullPath}";
|
var message = $"Fail to open file at {record.FullPath}";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
|
@ -159,7 +159,7 @@ namespace Microsoft.Plugin.Folder
|
||||||
|
|
||||||
private bool CanRunAsDifferentUser(string path)
|
private bool CanRunAsDifferentUser(string path)
|
||||||
{
|
{
|
||||||
switch(Path.GetExtension(path))
|
switch (Path.GetExtension(path))
|
||||||
{
|
{
|
||||||
case ".exe":
|
case ".exe":
|
||||||
case ".bat":
|
case ".bat":
|
||||||
|
|
|
@ -197,7 +197,7 @@ namespace Microsoft.Plugin.Folder
|
||||||
{
|
{
|
||||||
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
if ((fileSystemInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) continue;
|
||||||
|
|
||||||
if(fileSystemInfo is DirectoryInfo)
|
if (fileSystemInfo is DirectoryInfo)
|
||||||
{
|
{
|
||||||
var folderSubtitleString = fileSystemInfo.FullName;
|
var folderSubtitleString = fileSystemInfo.FullName;
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ namespace Microsoft.Plugin.Folder
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath}
|
ContextData = new SearchResult { Type = ResultType.File, FullPath = filePath }
|
||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace Microsoft.Plugin.Indexer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extensions for adding run as admin context menu item for applications
|
// Extensions for adding run as admin context menu item for applications
|
||||||
private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" };
|
private readonly string[] appExtensions = { ".exe", ".bat", ".appref-ms", ".lnk" };
|
||||||
|
|
||||||
public ContextMenuLoader(PluginInitContext context)
|
public ContextMenuLoader(PluginInitContext context)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ namespace Microsoft.Plugin.Indexer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item
|
// Test to check if File can be Run as admin, if yes, we add a 'run as admin' context menu item
|
||||||
if(CanFileBeRunAsAdmin(record.Path))
|
if (CanFileBeRunAsAdmin(record.Path))
|
||||||
{
|
{
|
||||||
contextMenus.Add(CreateRunAsAdminContextMenu(record));
|
contextMenus.Add(CreateRunAsAdminContextMenu(record));
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ namespace Microsoft.Plugin.Indexer
|
||||||
Title = _context.API.GetTranslation("Microsoft_plugin_indexer_copy_path"),
|
Title = _context.API.GetTranslation("Microsoft_plugin_indexer_copy_path"),
|
||||||
Glyph = "\xE8C8",
|
Glyph = "\xE8C8",
|
||||||
FontFamily = "Segoe MDL2 Assets",
|
FontFamily = "Segoe MDL2 Assets",
|
||||||
AcceleratorKey = Key.C,
|
AcceleratorKey = Key.C,
|
||||||
AcceleratorModifiers = ModifierKeys.Control,
|
AcceleratorModifiers = ModifierKeys.Control,
|
||||||
|
|
||||||
Action = (context) =>
|
Action = (context) =>
|
||||||
|
@ -128,7 +128,7 @@ namespace Microsoft.Plugin.Indexer
|
||||||
Task.Run(() => Helper.RunAsAdmin(record.Path));
|
Task.Run(() => Helper.RunAsAdmin(record.Path));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Exception($"|Microsoft.Plugin.Indexer.ContextMenu| Failed to run {record.Path} as admin, {e.Message}", e);
|
Log.Exception($"|Microsoft.Plugin.Indexer.ContextMenu| Failed to run {record.Path} as admin, {e.Message}", e);
|
||||||
return false;
|
return false;
|
||||||
|
@ -142,9 +142,9 @@ namespace Microsoft.Plugin.Indexer
|
||||||
private bool CanFileBeRunAsAdmin(string path)
|
private bool CanFileBeRunAsAdmin(string path)
|
||||||
{
|
{
|
||||||
string fileExtension = Path.GetExtension(path);
|
string fileExtension = Path.GetExtension(path);
|
||||||
foreach(string extension in appExtensions)
|
foreach (string extension in appExtensions)
|
||||||
{
|
{
|
||||||
if(extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase))
|
if (extension.Equals(fileExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ namespace Microsoft.Plugin.Indexer
|
||||||
{
|
{
|
||||||
Process.Start("explorer.exe", $" /select,\"{record.Path}\"");
|
Process.Start("explorer.exe", $" /select,\"{record.Path}\"");
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
var message = $"Fail to open file at {record.Path}";
|
var message = $"Fail to open file at {record.Path}";
|
||||||
LogException(message, e);
|
LogException(message, e);
|
||||||
|
|
|
@ -14,10 +14,10 @@ namespace Microsoft.Plugin.Indexer.DriveDetection
|
||||||
{
|
{
|
||||||
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(registryLocation))
|
using (RegistryKey regKey = Registry.LocalMachine.OpenSubKey(registryLocation))
|
||||||
{
|
{
|
||||||
if(regKey != null)
|
if (regKey != null)
|
||||||
{
|
{
|
||||||
Object value = regKey.GetValue(valueName);
|
Object value = regKey.GetValue(valueName);
|
||||||
if(value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
return (int)value;
|
return (int)value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||||
resultDisposed = true;
|
resultDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(conn.State == System.Data.ConnectionState.Closed)
|
if (conn.State == System.Data.ConnectionState.Closed)
|
||||||
{
|
{
|
||||||
connDisposed = true;
|
connDisposed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||||
List<OleDBResult> oleDBResults = WindowsIndexerSearch.Query(queryHelper.ConnectionString, sqlQuery);
|
List<OleDBResult> oleDBResults = WindowsIndexerSearch.Query(queryHelper.ConnectionString, sqlQuery);
|
||||||
|
|
||||||
// Loop over all records from the database
|
// Loop over all records from the database
|
||||||
foreach(OleDBResult oleDBResult in oleDBResults)
|
foreach (OleDBResult oleDBResult in oleDBResults)
|
||||||
{
|
{
|
||||||
if (oleDBResult.fieldData[0] == DBNull.Value || oleDBResult.fieldData[1] == DBNull.Value || oleDBResult.fieldData[2] == DBNull.Value)
|
if (oleDBResult.fieldData[0] == DBNull.Value || oleDBResult.fieldData[1] == DBNull.Value || oleDBResult.fieldData[2] == DBNull.Value)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,7 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||||
Title = (string)oleDBResult.fieldData[1]
|
Title = (string)oleDBResult.fieldData[1]
|
||||||
};
|
};
|
||||||
_Result.Add(result);
|
_Result.Add(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _Result;
|
return _Result;
|
||||||
|
@ -105,7 +105,8 @@ namespace Microsoft.Plugin.Indexer.SearchHelper
|
||||||
|
|
||||||
public IEnumerable<SearchResult> Search(string keyword, string pattern = "*", int maxCount = 30)
|
public IEnumerable<SearchResult> Search(string keyword, string pattern = "*", int maxCount = 30)
|
||||||
{
|
{
|
||||||
lock(_lock){
|
lock (_lock)
|
||||||
|
{
|
||||||
ISearchQueryHelper queryHelper;
|
ISearchQueryHelper queryHelper;
|
||||||
InitQueryHelper(out queryHelper, maxCount);
|
InitQueryHelper(out queryHelper, maxCount);
|
||||||
ModifyQueryHelper(ref queryHelper, pattern);
|
ModifyQueryHelper(ref queryHelper, pattern);
|
||||||
|
|
|
@ -79,7 +79,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||||
// Arrange
|
// Arrange
|
||||||
PackageWrapper invalidPackagedApp = new PackageWrapper();
|
PackageWrapper invalidPackagedApp = new PackageWrapper();
|
||||||
Main._settings = new Settings();
|
Main._settings = new Settings();
|
||||||
List<IPackage> packages = new List<IPackage>() {invalidPackagedApp };
|
List<IPackage> packages = new List<IPackage>() { invalidPackagedApp };
|
||||||
var mock = new Mock<IPackageManager>();
|
var mock = new Mock<IPackageManager>();
|
||||||
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
mock.Setup(x => x.FindPackagesForCurrentUser()).Returns(packages);
|
||||||
UWP.PackageManagerWrapper = mock.Object;
|
UWP.PackageManagerWrapper = mock.Object;
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Programs
|
||||||
Name = "Command Prompt",
|
Name = "Command Prompt",
|
||||||
ExecutableName = "cmd.exe",
|
ExecutableName = "cmd.exe",
|
||||||
FullPath = "c:\\windows\\system32\\cmd.exe",
|
FullPath = "c:\\windows\\system32\\cmd.exe",
|
||||||
LnkResolvedPath ="c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
|
LnkResolvedPath = "c:\\users\\powertoys\\appdata\\roaming\\microsoft\\windows\\start menu\\programs\\system tools\\command prompt.lnk",
|
||||||
AppType = 2
|
AppType = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
{
|
{
|
||||||
//Arrange
|
//Arrange
|
||||||
ListRepository<string> repository = new ListRepository<string>();
|
ListRepository<string> repository = new ListRepository<string>();
|
||||||
var numItems = 1000;
|
var numItems = 1000;
|
||||||
for(var i=0; i<numItems;++i)
|
for (var i = 0; i < numItems; ++i)
|
||||||
{
|
{
|
||||||
repository.Add($"OriginalItem_{i}");
|
repository.Add($"OriginalItem_{i}");
|
||||||
}
|
}
|
||||||
|
@ -87,16 +87,16 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
});
|
});
|
||||||
|
|
||||||
//Act - Insert on another thread
|
//Act - Insert on another thread
|
||||||
var addTask = Task.Run(() =>
|
var addTask = Task.Run(() =>
|
||||||
{
|
{
|
||||||
for (var i = 0; i < numItems; ++i)
|
for (var i = 0; i < numItems; ++i)
|
||||||
{
|
{
|
||||||
repository.Add($"NewItem_{i}");
|
repository.Add($"NewItem_{i}");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
//Assert that this does not throw. Collections that aren't syncronized will throw an invalidoperatioexception if the list is modified while enumerating
|
||||||
Assert.DoesNotThrowAsync(async () =>
|
Assert.DoesNotThrowAsync(async () =>
|
||||||
{
|
{
|
||||||
await Task.WhenAll(new Task[] { iterationTask, addTask });
|
await Task.WhenAll(new Task[] { iterationTask, addTask });
|
||||||
});
|
});
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
||||||
|
|
||||||
Win32 item1 = new Win32
|
Win32 item1 = new Win32
|
||||||
{
|
{
|
||||||
Name = name,
|
Name = name,
|
||||||
ExecutableName = exename,
|
ExecutableName = exename,
|
||||||
FullPath = fullPath,
|
FullPath = fullPath,
|
||||||
Description = description1
|
Description = description1
|
||||||
|
@ -108,7 +108,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
||||||
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory , newpath, oldpath);
|
RenamedEventArgs e = new RenamedEventArgs(WatcherChangeTypes.Renamed, directory, newpath, oldpath);
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
string newFullPath = directory + "\\" + newpath;
|
string newFullPath = directory + "\\" + newpath;
|
||||||
|
@ -132,12 +132,12 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
// Arrange
|
// Arrange
|
||||||
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
Win32ProgramRepository _win32ProgramRepository = new Win32ProgramRepository(_fileSystemWatchers, new BinaryStorage<IList<Win32>>("Win32"), _settings, _pathsToWatch);
|
||||||
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, "directory", path);
|
||||||
|
|
||||||
// FileVersionInfo must be mocked for exe applications
|
// FileVersionInfo must be mocked for exe applications
|
||||||
var mockFileVersionInfo = new Mock<IFileVersionInfoWrapper>();
|
var mockFileVersionInfo = new Mock<IFileVersionInfoWrapper>();
|
||||||
mockFileVersionInfo.Setup(m => m.GetVersionInfo(It.IsAny<string>())).Returns((FileVersionInfo)null);
|
mockFileVersionInfo.Setup(m => m.GetVersionInfo(It.IsAny<string>())).Returns((FileVersionInfo)null);
|
||||||
Win32._fileVersionInfoWrapper = mockFileVersionInfo.Object;
|
Win32._fileVersionInfoWrapper = mockFileVersionInfo.Object;
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
_fileSystemMocks[0].Raise(m => m.Created += null, e);
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ namespace Microsoft.Plugin.Program.UnitTests.Storage
|
||||||
|
|
||||||
string oldFullPath = directory + "\\" + oldpath;
|
string oldFullPath = directory + "\\" + oldpath;
|
||||||
string FullPath = directory + "\\" + path;
|
string FullPath = directory + "\\" + path;
|
||||||
|
|
||||||
// ShellLinkHelper must be mocked for lnk applications
|
// ShellLinkHelper must be mocked for lnk applications
|
||||||
var mockShellLink = new Mock<IShellLinkHelper>();
|
var mockShellLink = new Mock<IShellLinkHelper>();
|
||||||
mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny<string>())).Returns(String.Empty);
|
mockShellLink.Setup(m => m.RetrieveTargetPath(It.IsAny<string>())).Returns(String.Empty);
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace Microsoft.Plugin.Program
|
||||||
Task.WaitAll(a, b);
|
Task.WaitAll(a, b);
|
||||||
|
|
||||||
_settings.LastIndexTime = DateTime.Today;
|
_settings.LastIndexTime = DateTime.Today;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
|
|
|
@ -74,7 +74,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
public interface IAppxManifestProperties
|
public interface IAppxManifestProperties
|
||||||
{
|
{
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)]string name, out bool value);
|
int GetBoolValue([MarshalAs(UnmanagedType.LPWStr)] string name, out bool value);
|
||||||
[PreserveSig]
|
[PreserveSig]
|
||||||
int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value);
|
int GetStringValue([MarshalAs(UnmanagedType.LPWStr)] string name, [MarshalAs(UnmanagedType.LPWStr)] out string value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
string path;
|
string path;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
path = package.InstalledLocation.Path;
|
path = package.InstalledLocation.Path;
|
||||||
}
|
}
|
||||||
catch (Exception e) when (e is ArgumentException || e is FileNotFoundException)
|
catch (Exception e) when (e is ArgumentException || e is FileNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -48,11 +48,11 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
package.Id.Name,
|
package.Id.Name,
|
||||||
package.Id.FullName,
|
package.Id.FullName,
|
||||||
package.Id.FamilyName,
|
package.Id.FamilyName,
|
||||||
package.IsFramework,
|
package.IsFramework,
|
||||||
package.IsDevelopmentMode,
|
package.IsDevelopmentMode,
|
||||||
path
|
path
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
((IPersistFile)link).Load(path, STGM_READ);
|
((IPersistFile)link).Load(path, STGM_READ);
|
||||||
}
|
}
|
||||||
catch(System.IO.FileNotFoundException ex)
|
catch (System.IO.FileNotFoundException ex)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex);
|
ProgramLogger.LogException($"|Win32| ShellLinkHelper.retrieveTargetPath | {path} | Path could not be retrieved", ex);
|
||||||
return String.Empty;
|
return String.Empty;
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
public static IPackageManager PackageManagerWrapper { get; set; } = new PackageManagerWrapper();
|
public static IPackageManager PackageManagerWrapper { get; set; } = new PackageManagerWrapper();
|
||||||
|
|
||||||
public UWP(IPackage package)
|
public UWP(IPackage package)
|
||||||
{
|
{
|
||||||
Name = package.Name;
|
Name = package.Name;
|
||||||
FullName = package.FullName;
|
FullName = package.FullName;
|
||||||
FamilyName = package.FamilyName;
|
FamilyName = package.FamilyName;
|
||||||
|
@ -63,10 +63,10 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
|
|
||||||
if (hResult == Hresult.Ok)
|
if (hResult == Hresult.Ok)
|
||||||
{
|
{
|
||||||
var apps = new List<Application>();
|
var apps = new List<Application>();
|
||||||
|
|
||||||
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
|
List<AppxPackageHelper.IAppxManifestApplication> _apps = _helper.getAppsFromManifest(stream);
|
||||||
foreach(var _app in _apps)
|
foreach (var _app in _apps)
|
||||||
{
|
{
|
||||||
var app = new Application(_app, this);
|
var app = new Application(_app, this);
|
||||||
apps.Add(app);
|
apps.Add(app);
|
||||||
|
@ -194,12 +194,12 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
ProgramLogger.LogException("UWP" ,"CurrentUserPackages", $"id","An unexpected error occurred and "
|
ProgramLogger.LogException("UWP", "CurrentUserPackages", $"id", "An unexpected error occurred and "
|
||||||
+ $"unable to verify if package is valid", e);
|
+ $"unable to verify if package is valid", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
public string Name => DisplayName;
|
public string Name => DisplayName;
|
||||||
public string Location => Package.Location;
|
public string Location => Package.Location;
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
public bool CanRunElevated {get;set;}
|
public bool CanRunElevated { get; set; }
|
||||||
|
|
||||||
public string LogoUri { get; set; }
|
public string LogoUri { get; set; }
|
||||||
public string LogoPath { get; set; }
|
public string LogoPath { get; set; }
|
||||||
|
@ -253,7 +253,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
|
var displayNameMatch = StringMatcher.FuzzySearch(query, DisplayName);
|
||||||
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||||
var score = new[] { displayNameMatch.Score, descriptionMatch.Score/2 }.Max();
|
var score = new[] { displayNameMatch.Score, descriptionMatch.Score / 2 }.Max();
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,23 +325,23 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
contextMenus.Add(
|
contextMenus.Add(
|
||||||
new ContextMenuResult
|
new ContextMenuResult
|
||||||
{
|
{
|
||||||
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
PluginName = Assembly.GetExecutingAssembly().GetName().Name,
|
||||||
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
|
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
|
||||||
Glyph = "\xE838",
|
Glyph = "\xE838",
|
||||||
FontFamily = "Segoe MDL2 Assets",
|
FontFamily = "Segoe MDL2 Assets",
|
||||||
AcceleratorKey = Key.E,
|
AcceleratorKey = Key.E,
|
||||||
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
|
AcceleratorModifiers = (ModifierKeys.Control | ModifierKeys.Shift),
|
||||||
Action = _ =>
|
Action = _ =>
|
||||||
{
|
{
|
||||||
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));
|
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", Package.Location));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
contextMenus.Add(new ContextMenuResult
|
contextMenus.Add(new ContextMenuResult
|
||||||
{
|
{
|
||||||
|
@ -436,7 +436,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
if (File.Exists(manifest))
|
if (File.Exists(manifest))
|
||||||
{
|
{
|
||||||
var file = File.ReadAllText(manifest);
|
var file = File.ReadAllText(manifest);
|
||||||
if(file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase))
|
if (file.Contains("TrustLevel=\"mediumIL\"", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -565,8 +565,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
var end = path.Length - extension.Length;
|
var end = path.Length - extension.Length;
|
||||||
var prefix = path.Substring(0, end);
|
var prefix = path.Substring(0, end);
|
||||||
var paths = new List<string> { path };
|
var paths = new List<string> { path };
|
||||||
|
|
||||||
var scaleFactors = new Dictionary<PackageVersion, List<int>>
|
var scaleFactors = new Dictionary<PackageVersion, List<int>>
|
||||||
{
|
{
|
||||||
// scale factors on win10: https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets#asset-size-tables,
|
// scale factors on win10: https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-app-assets#asset-size-tables,
|
||||||
|
@ -594,7 +594,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int appIconSize = 36;
|
int appIconSize = 36;
|
||||||
var targetSizes = new List<int>{16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256}.AsParallel();
|
var targetSizes = new List<int> { 16, 24, 30, 36, 44, 60, 72, 96, 128, 180, 256 }.AsParallel();
|
||||||
Dictionary<string, int> pathFactorPairs = new Dictionary<string, int>();
|
Dictionary<string, int> pathFactorPairs = new Dictionary<string, int>();
|
||||||
|
|
||||||
foreach (var factor in targetSizes)
|
foreach (var factor in targetSizes)
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
var nameMatch = StringMatcher.FuzzySearch(query, Name);
|
var nameMatch = StringMatcher.FuzzySearch(query, Name);
|
||||||
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
var descriptionMatch = StringMatcher.FuzzySearch(query, Description);
|
||||||
var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName);
|
var executableNameMatch = StringMatcher.FuzzySearch(query, ExecutableName);
|
||||||
var score = new[] { nameMatch.Score, descriptionMatch.Score/2, executableNameMatch.Score }.Max();
|
var score = new[] { nameMatch.Score, descriptionMatch.Score / 2, executableNameMatch.Score }.Max();
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
public bool FilterWebApplication(string query)
|
public bool FilterWebApplication(string query)
|
||||||
{
|
{
|
||||||
// If the app is not a web application, then do not filter it
|
// If the app is not a web application, then do not filter it
|
||||||
if(!IsWebApplication())
|
if (!IsWebApplication())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
pathContainsQuery = true;
|
pathContainsQuery = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Name.Contains(subquery, StringComparison.OrdinalIgnoreCase))
|
if (Name.Contains(subquery, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
nameContainsQuery = true;
|
nameContainsQuery = true;
|
||||||
}
|
}
|
||||||
|
@ -112,19 +112,19 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
// Function to set the subtitle based on the Type of application
|
// Function to set the subtitle based on the Type of application
|
||||||
private string SetSubtitle(IPublicAPI api)
|
private string SetSubtitle(IPublicAPI api)
|
||||||
{
|
{
|
||||||
if(AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
|
if (AppType == (uint)ApplicationTypes.WIN32_APPLICATION)
|
||||||
{
|
{
|
||||||
return api.GetTranslation("powertoys_run_plugin_program_win32_application");
|
return api.GetTranslation("powertoys_run_plugin_program_win32_application");
|
||||||
}
|
}
|
||||||
else if(AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
|
else if (AppType == (uint)ApplicationTypes.INTERNET_SHORTCUT_APPLICATION)
|
||||||
{
|
{
|
||||||
return api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application");
|
return api.GetTranslation("powertoys_run_plugin_program_internet_shortcut_application");
|
||||||
}
|
}
|
||||||
else if(AppType == (uint)ApplicationTypes.WEB_APPLICATION)
|
else if (AppType == (uint)ApplicationTypes.WEB_APPLICATION)
|
||||||
{
|
{
|
||||||
return api.GetTranslation("powertoys_run_plugin_program_web_application");
|
return api.GetTranslation("powertoys_run_plugin_program_web_application");
|
||||||
}
|
}
|
||||||
else if(AppType == (uint)ApplicationTypes.RUN_COMMAND)
|
else if (AppType == (uint)ApplicationTypes.RUN_COMMAND)
|
||||||
{
|
{
|
||||||
return api.GetTranslation("powertoys_run_plugin_program_run_command");
|
return api.GetTranslation("powertoys_run_plugin_program_run_command");
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasArguments)
|
if (!hasArguments)
|
||||||
{
|
{
|
||||||
var noArgumentScoreModifier = 5;
|
var noArgumentScoreModifier = 5;
|
||||||
score += noArgumentScoreModifier;
|
score += noArgumentScoreModifier;
|
||||||
|
@ -168,7 +168,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: This is to display run commands only when there is an exact match, like in start menu
|
// NOTE: This is to display run commands only when there is an exact match, like in start menu
|
||||||
if(!QueryEqualsNameForRunCommands(query))
|
if (!QueryEqualsNameForRunCommands(query))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -330,27 +330,27 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
const string urlPrefix = "URL=";
|
const string urlPrefix = "URL=";
|
||||||
const string iconFilePrefix = "IconFile=";
|
const string iconFilePrefix = "IconFile=";
|
||||||
|
|
||||||
foreach(string line in lines)
|
foreach (string line in lines)
|
||||||
{
|
{
|
||||||
if(line.StartsWith(urlPrefix))
|
if (line.StartsWith(urlPrefix))
|
||||||
{
|
{
|
||||||
urlPath = line.Substring(urlPrefix.Length);
|
urlPath = line.Substring(urlPrefix.Length);
|
||||||
Uri uri = new Uri(urlPath);
|
Uri uri = new Uri(urlPath);
|
||||||
|
|
||||||
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
|
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
|
||||||
if(InternetShortcutURLPrefixes.Match(urlPath).Success)
|
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
|
||||||
{
|
{
|
||||||
validApp = true;
|
validApp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(line.StartsWith(iconFilePrefix))
|
if (line.StartsWith(iconFilePrefix))
|
||||||
{
|
{
|
||||||
iconPath = line.Substring(iconFilePrefix.Length);
|
iconPath = line.Substring(iconFilePrefix.Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!validApp)
|
if (!validApp)
|
||||||
{
|
{
|
||||||
return new Win32() { Valid = false, Enabled = false };
|
return new Win32() { Valid = false, Enabled = false };
|
||||||
}
|
}
|
||||||
|
@ -386,8 +386,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
const int MAX_PATH = 260;
|
const int MAX_PATH = 260;
|
||||||
StringBuilder buffer = new StringBuilder(MAX_PATH);
|
StringBuilder buffer = new StringBuilder(MAX_PATH);
|
||||||
|
|
||||||
string target = _helper.RetrieveTargetPath(path);
|
string target = _helper.RetrieveTargetPath(path);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(target))
|
if (!string.IsNullOrEmpty(target))
|
||||||
|
@ -473,25 +473,25 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
|
|
||||||
string extension = Path.GetExtension(path);
|
string extension = Path.GetExtension(path);
|
||||||
|
|
||||||
if(extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase))
|
if (extension.Equals(exeExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
app = ExeProgram(path);
|
app = ExeProgram(path);
|
||||||
}
|
}
|
||||||
else if(extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase))
|
else if (extension.Equals(lnkExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
app = LnkProgram(path);
|
app = LnkProgram(path);
|
||||||
}
|
}
|
||||||
else if(extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase))
|
else if (extension.Equals(apprefExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
app = Win32Program(path);
|
app = Win32Program(path);
|
||||||
}
|
}
|
||||||
else if(extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase))
|
else if (extension.Equals(urlExtenion, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
app = InternetShortcutProgram(path);
|
app = InternetShortcutProgram(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the app is valid, only then return the application, else return null
|
// if the app is valid, only then return the application, else return null
|
||||||
if(app?.Valid ?? false)
|
if (app?.Valid ?? false)
|
||||||
{
|
{
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
@ -511,8 +511,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
|
|
||||||
var files = new List<string>();
|
var files = new List<string>();
|
||||||
var folderQueue = new Queue<string>();
|
var folderQueue = new Queue<string>();
|
||||||
folderQueue.Enqueue(directory);
|
folderQueue.Enqueue(directory);
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
var currentDirectory = folderQueue.Dequeue();
|
var currentDirectory = folderQueue.Dequeue();
|
||||||
|
@ -540,7 +540,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If the search is set to be non-recursive, then do not enqueue the child directories.
|
// If the search is set to be non-recursive, then do not enqueue the child directories.
|
||||||
if(!recursiveSearch)
|
if (!recursiveSearch)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -606,9 +606,9 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
IEnumerable<String> toFilterAllPaths = new List<String>();
|
IEnumerable<String> toFilterAllPaths = new List<String>();
|
||||||
bool isRecursiveSearch = true;
|
bool isRecursiveSearch = true;
|
||||||
|
|
||||||
foreach(string path in searchPaths)
|
foreach (string path in searchPaths)
|
||||||
{
|
{
|
||||||
if(path.Length > 0)
|
if (path.Length > 0)
|
||||||
{
|
{
|
||||||
// to expand any environment variables present in the path
|
// to expand any environment variables present in the path
|
||||||
string directory = Environment.ExpandEnvironmentVariables(path);
|
string directory = Environment.ExpandEnvironmentVariables(path);
|
||||||
|
@ -629,7 +629,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
var allPrograms = programs1.Concat(programs2).Where(p => p.Valid)
|
var allPrograms = programs1.Concat(programs2).Where(p => p.Valid)
|
||||||
.Concat(programs3).Where(p => p.Valid)
|
.Concat(programs3).Where(p => p.Valid)
|
||||||
.Concat(programs4).Where(p => p.Valid)
|
.Concat(programs4).Where(p => p.Valid)
|
||||||
.Select( p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; });
|
.Select(p => { p.AppType = (uint)ApplicationTypes.RUN_COMMAND; return p; });
|
||||||
|
|
||||||
return allPrograms;
|
return allPrograms;
|
||||||
}
|
}
|
||||||
|
@ -643,8 +643,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
var _paths = ProgramPaths(location, suffixes);
|
var _paths = ProgramPaths(location, suffixes);
|
||||||
toFilter = toFilter.Concat(_paths);
|
toFilter = toFilter.Concat(_paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
var paths = toFilter
|
var paths = toFilter
|
||||||
.Where(t1 => !disabledProgramsList.Any(x => x.UniqueIdentifier == t1))
|
.Where(t1 => !disabledProgramsList.Any(x => x.UniqueIdentifier == t1))
|
||||||
.Select(t1 => t1)
|
.Select(t1 => t1)
|
||||||
|
@ -665,7 +665,7 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
|
var directory1 = Environment.GetFolderPath(Environment.SpecialFolder.Programs);
|
||||||
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms);
|
var directory2 = Environment.GetFolderPath(Environment.SpecialFolder.CommonPrograms);
|
||||||
List<string> IndexLocation = new List<string>() { directory1, directory2};
|
List<string> IndexLocation = new List<string>() { directory1, directory2 };
|
||||||
|
|
||||||
return IndexPath(suffixes, IndexLocation);
|
return IndexPath(suffixes, IndexLocation);
|
||||||
}
|
}
|
||||||
|
@ -777,8 +777,8 @@ namespace Microsoft.Plugin.Program.Programs
|
||||||
{
|
{
|
||||||
public bool Equals(Win32 app1, Win32 app2)
|
public bool Equals(Win32 app1, Win32 app2)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name)
|
if (!string.IsNullOrEmpty(app1.Name) && !string.IsNullOrEmpty(app2.Name)
|
||||||
&& !string.IsNullOrEmpty(app1.ExecutableName) && !string.IsNullOrEmpty(app2.ExecutableName)
|
&& !string.IsNullOrEmpty(app1.ExecutableName) && !string.IsNullOrEmpty(app2.ExecutableName)
|
||||||
&& !string.IsNullOrEmpty(app1.FullPath) && !string.IsNullOrEmpty(app2.FullPath))
|
&& !string.IsNullOrEmpty(app1.FullPath) && !string.IsNullOrEmpty(app2.FullPath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace Microsoft.Plugin.Program
|
||||||
public DateTime LastIndexTime { get; set; }
|
public DateTime LastIndexTime { get; set; }
|
||||||
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
|
public List<ProgramSource> ProgramSources { get; set; } = new List<ProgramSource>();
|
||||||
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
|
public List<DisabledProgramSource> DisabledProgramSources { get; set; } = new List<DisabledProgramSource>();
|
||||||
public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk", "url"};
|
public string[] ProgramSuffixes { get; set; } = { "bat", "appref-ms", "exe", "lnk", "url" };
|
||||||
|
|
||||||
public bool EnableStartMenuSource { get; set; } = true;
|
public bool EnableStartMenuSource { get; set; } = true;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
|
var packageWrapper = PackageWrapper.GetWrapperFromPackage(args.Package);
|
||||||
if(!string.IsNullOrEmpty(packageWrapper.InstalledLocation))
|
if (!string.IsNullOrEmpty(packageWrapper.InstalledLocation))
|
||||||
{
|
{
|
||||||
var uwp = new UWP(packageWrapper);
|
var uwp = new UWP(packageWrapper);
|
||||||
uwp.InitializeAppInfo(packageWrapper.InstalledLocation);
|
uwp.InitializeAppInfo(packageWrapper.InstalledLocation);
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
for(int index = 0; index < _pathsToWatch.Length; index++)
|
for (int index = 0; index < _pathsToWatch.Length; index++)
|
||||||
{
|
{
|
||||||
_fileSystemWatchers[index].Dispose();
|
_fileSystemWatchers[index].Dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
private IList<IFileSystemWatcherWrapper> _fileSystemWatcherHelpers;
|
private IList<IFileSystemWatcherWrapper> _fileSystemWatcherHelpers;
|
||||||
private string[] _pathsToWatch;
|
private string[] _pathsToWatch;
|
||||||
private int _numberOfPathsToWatch;
|
private int _numberOfPathsToWatch;
|
||||||
private Collection<string> extensionsToWatch = new Collection<string>{ "*.exe", "*.lnk", "*.appref-ms", "*.url" };
|
private Collection<string> extensionsToWatch = new Collection<string> { "*.exe", "*.lnk", "*.appref-ms", "*.url" };
|
||||||
private readonly string lnkExtension = ".lnk";
|
private readonly string lnkExtension = ".lnk";
|
||||||
private readonly string urlExtension = ".url";
|
private readonly string urlExtension = ".url";
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
|
|
||||||
private void InitializeFileSystemWatchers()
|
private void InitializeFileSystemWatchers()
|
||||||
{
|
{
|
||||||
for(int index = 0; index < _numberOfPathsToWatch; index++)
|
for (int index = 0; index < _numberOfPathsToWatch; index++)
|
||||||
{
|
{
|
||||||
// To set the paths to monitor
|
// To set the paths to monitor
|
||||||
_fileSystemWatcherHelpers[index].Path = _pathsToWatch[index];
|
_fileSystemWatcherHelpers[index].Path = _pathsToWatch[index];
|
||||||
|
@ -77,7 +77,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
{
|
{
|
||||||
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = newApp.ExecutableName, FullPath = newApp.FullPath };
|
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = newApp.ExecutableName, FullPath = newApp.FullPath };
|
||||||
}
|
}
|
||||||
else if(extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase))
|
else if (extension.Equals(urlExtension, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = Path.GetFileName(e.OldName), FullPath = newApp.FullPath };
|
oldApp = new Win32() { Name = Path.GetFileNameWithoutExtension(e.OldName), ExecutableName = Path.GetFileName(e.OldName), FullPath = newApp.FullPath };
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
app = Programs.Win32.GetAppFromPath(path);
|
app = Programs.Win32.GetAppFromPath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.Info($"|Win32ProgramRepository|OnAppDeleted-{extension}Program|{path}|Unable to create program from {path}| {ex.Message}");
|
Log.Info($"|Win32ProgramRepository|OnAppDeleted-{extension}Program|{path}|Unable to create program from {path}| {ex.Message}");
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
// Unlike the rename event args, since we do not have a newPath, we iterate through all the programs and find the one with the same LnkResolved path.
|
// Unlike the rename event args, since we do not have a newPath, we iterate through all the programs and find the one with the same LnkResolved path.
|
||||||
private Programs.Win32 GetAppWithSameLnkResolvedPath(string lnkResolvedPath)
|
private Programs.Win32 GetAppWithSameLnkResolvedPath(string lnkResolvedPath)
|
||||||
{
|
{
|
||||||
foreach(Programs.Win32 app in Items)
|
foreach (Programs.Win32 app in Items)
|
||||||
{
|
{
|
||||||
if (lnkResolvedPath.ToLower().Equals(app.LnkResolvedPath))
|
if (lnkResolvedPath.ToLower().Equals(app.LnkResolvedPath))
|
||||||
{
|
{
|
||||||
|
@ -167,7 +167,7 @@ namespace Microsoft.Plugin.Program.Storage
|
||||||
private void OnAppCreated(object sender, FileSystemEventArgs e)
|
private void OnAppCreated(object sender, FileSystemEventArgs e)
|
||||||
{
|
{
|
||||||
string path = e.FullPath;
|
string path = e.FullPath;
|
||||||
if(!Path.GetExtension(path).Equals(urlExtension))
|
if (!Path.GetExtension(path).Equals(urlExtension))
|
||||||
{
|
{
|
||||||
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
|
Programs.Win32 app = Programs.Win32.GetAppFromPath(path);
|
||||||
if (app != null)
|
if (app != null)
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Microsoft.Plugin.Program.Views
|
||||||
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var add = new AddProgramSource(context, _settings);
|
var add = new AddProgramSource(context, _settings);
|
||||||
if(add.ShowDialog() ?? false)
|
if (add.ShowDialog() ?? false)
|
||||||
{
|
{
|
||||||
ReIndexing();
|
ReIndexing();
|
||||||
}
|
}
|
||||||
|
@ -139,14 +139,14 @@ namespace Microsoft.Plugin.Program.Views
|
||||||
UniqueIdentifier = directory
|
UniqueIdentifier = directory
|
||||||
};
|
};
|
||||||
|
|
||||||
directoriesToAdd.Add(source);
|
directoriesToAdd.Add(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directoriesToAdd.Count() > 0)
|
if (directoriesToAdd.Count() > 0)
|
||||||
{
|
{
|
||||||
directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
|
directoriesToAdd.ForEach(x => _settings.ProgramSources.Add(x));
|
||||||
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
|
directoriesToAdd.ForEach(x => ProgramSettingDisplayList.Add(x));
|
||||||
|
|
||||||
programSourceView.Items.Refresh();
|
programSourceView.Items.Refresh();
|
||||||
ReIndexing();
|
ReIndexing();
|
||||||
|
@ -212,8 +212,8 @@ namespace Microsoft.Plugin.Program.Views
|
||||||
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true);
|
ProgramSettingDisplayList.SetProgramSourcesStatus(selectedItems, true);
|
||||||
|
|
||||||
ProgramSettingDisplayList.RemoveDisabledFromSettings();
|
ProgramSettingDisplayList.RemoveDisabledFromSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedItems.IsReindexRequired())
|
if (selectedItems.IsReindexRequired())
|
||||||
ReIndexing();
|
ReIndexing();
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ namespace Microsoft.Plugin.Program.Views
|
||||||
var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string;
|
var sortBy = columnBinding?.Path.Path ?? headerClicked.Column.Header as string;
|
||||||
|
|
||||||
Sort(sortBy, direction);
|
Sort(sortBy, direction);
|
||||||
|
|
||||||
_lastHeaderClicked = headerClicked;
|
_lastHeaderClicked = headerClicked;
|
||||||
_lastDirection = direction;
|
_lastDirection = direction;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ namespace Microsoft.Plugin.Shell
|
||||||
else if (_settings.Shell == Shell.RunCommand)
|
else if (_settings.Shell == Shell.RunCommand)
|
||||||
{
|
{
|
||||||
//Open explorer if the path is a file or directory
|
//Open explorer if the path is a file or directory
|
||||||
if(Directory.Exists(command) || File.Exists(command))
|
if (Directory.Exists(command) || File.Exists(command))
|
||||||
{
|
{
|
||||||
info = ShellCommand.SetProcessStartInfo("explorer.exe", arguments: command, verb: runAsAdministratorArg);
|
info = ShellCommand.SetProcessStartInfo("explorer.exe", arguments: command, verb: runAsAdministratorArg);
|
||||||
}
|
}
|
||||||
|
@ -236,11 +236,11 @@ namespace Microsoft.Plugin.Shell
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Execute(Func<ProcessStartInfo, Process> startProcess,ProcessStartInfo info)
|
private void Execute(Func<ProcessStartInfo, Process> startProcess, ProcessStartInfo info)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
startProcess(info);
|
startProcess(info);
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException e)
|
catch (FileNotFoundException e)
|
||||||
{
|
{
|
||||||
|
@ -248,7 +248,7 @@ namespace Microsoft.Plugin.Shell
|
||||||
var message = $"Command not found: {e.Message}";
|
var message = $"Command not found: {e.Message}";
|
||||||
_context.API.ShowMsg(name, message);
|
_context.API.ShowMsg(name, message);
|
||||||
}
|
}
|
||||||
catch(Win32Exception e)
|
catch (Win32Exception e)
|
||||||
{
|
{
|
||||||
var name = "Plugin: Shell";
|
var name = "Plugin: Shell";
|
||||||
var message = $"Error running the command: {e.Message}";
|
var message = $"Error running the command: {e.Message}";
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Microsoft.Plugin.Shell
|
||||||
public class Settings
|
public class Settings
|
||||||
{
|
{
|
||||||
public Shell Shell { get; set; } = Shell.RunCommand;
|
public Shell Shell { get; set; } = Shell.RunCommand;
|
||||||
|
|
||||||
// not overriding Win+R
|
// not overriding Win+R
|
||||||
// crutkas we need to earn the right for Win+R override
|
// crutkas we need to earn the right for Win+R override
|
||||||
public bool ReplaceWinR { get; set; } = false;
|
public bool ReplaceWinR { get; set; } = false;
|
||||||
|
|
|
@ -49,10 +49,10 @@ namespace Microsoft.Plugin.Shell
|
||||||
_settings.ReplaceWinR = false;
|
_settings.ReplaceWinR = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
ShellComboBox.SelectedIndex = (int) _settings.Shell;
|
ShellComboBox.SelectedIndex = (int)_settings.Shell;
|
||||||
ShellComboBox.SelectionChanged += (o, e) =>
|
ShellComboBox.SelectionChanged += (o, e) =>
|
||||||
{
|
{
|
||||||
_settings.Shell = (Shell) ShellComboBox.SelectedIndex;
|
_settings.Shell = (Shell)ShellComboBox.SelectedIndex;
|
||||||
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
LeaveShellOpen.IsEnabled = _settings.Shell != Shell.RunCommand;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -815,7 +815,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
|
||||||
|
|
||||||
[DllImport("psapi.dll")]
|
[DllImport("psapi.dll")]
|
||||||
public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In] [MarshalAs(UnmanagedType.U4)] int nSize);
|
public static extern uint GetProcessImageFileName(IntPtr hProcess, [Out] StringBuilder lpImageFileName, [In][MarshalAs(UnmanagedType.U4)] int nSize);
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
public static extern IntPtr GetProp(IntPtr hWnd, string lpString);
|
public static extern IntPtr GetProp(IntPtr hWnd, string lpString);
|
||||||
|
@ -824,7 +824,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
|
public static extern IntPtr OpenProcess(ProcessAccessFlags dwDesiredAccess, [MarshalAs(UnmanagedType.Bool)] bool bInheritHandle, int dwProcessId);
|
||||||
|
|
||||||
[DllImport("dwmapi.dll", EntryPoint = "#113", CallingConvention = CallingConvention.StdCall)]
|
[DllImport("dwmapi.dll", EntryPoint = "#113", CallingConvention = CallingConvention.StdCall)]
|
||||||
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)]bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
|
public static extern int DwmpActivateLivePreview([MarshalAs(UnmanagedType.Bool)] bool fActivate, IntPtr hWndExclude, IntPtr hWndInsertBefore, LivePreviewTrigger lpt, IntPtr prcFinalRect);
|
||||||
|
|
||||||
[DllImport("dwmapi.dll", PreserveSig = false)]
|
[DllImport("dwmapi.dll", PreserveSig = false)]
|
||||||
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
public static extern int DwmSetWindowAttribute(IntPtr hwnd, int attr, ref int attrValue, int attrSize);
|
||||||
|
|
|
@ -91,7 +91,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
Window newWindow = new Window(hwnd);
|
Window newWindow = new Window(hwnd);
|
||||||
|
|
||||||
if (newWindow.IsWindow && newWindow.Visible && newWindow.IsOwner &&
|
if (newWindow.IsWindow && newWindow.Visible && newWindow.IsOwner &&
|
||||||
(!newWindow.IsToolWindow || newWindow.IsAppWindow ) && !newWindow.TaskListDeleted &&
|
(!newWindow.IsToolWindow || newWindow.IsAppWindow) && !newWindow.TaskListDeleted &&
|
||||||
newWindow.ClassName != "Windows.UI.Core.CoreWindow")
|
newWindow.ClassName != "Windows.UI.Core.CoreWindow")
|
||||||
{
|
{
|
||||||
windows.Add(newWindow);
|
windows.Add(newWindow);
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
/// Event handler for when the search text has been updated
|
/// Event handler for when the search text has been updated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task UpdateSearchText(string searchText)
|
public async Task UpdateSearchText(string searchText)
|
||||||
{
|
{
|
||||||
this.SearchText = searchText;
|
this.SearchText = searchText;
|
||||||
await SyncOpenWindowsWithModelAsync();
|
await SyncOpenWindowsWithModelAsync();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,13 +6,13 @@ using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.Plugin.WindowWalker.Components
|
namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
{
|
{
|
||||||
class WindowResult:Window
|
class WindowResult : Window
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of letters in between constant for when
|
/// Number of letters in between constant for when
|
||||||
/// the result hasn't been set yet
|
/// the result hasn't been set yet
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const int NoResult = -1;
|
public const int NoResult = -1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Properties that signify how many characters (including spaces)
|
/// Properties that signify how many characters (including spaces)
|
||||||
|
@ -27,7 +27,7 @@ namespace Microsoft.Plugin.WindowWalker.Components
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for WindowResult
|
/// Constructor for WindowResult
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WindowResult(Window window):base(window.Hwnd)
|
public WindowResult(Window window) : base(window.Hwnd)
|
||||||
{
|
{
|
||||||
LettersInBetweenScore = WindowResult.NoResult;
|
LettersInBetweenScore = WindowResult.NoResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,8 @@ namespace PowerLauncher
|
||||||
|
|
||||||
private void OnStartup(object sender, StartupEventArgs e)
|
private void OnStartup(object sender, StartupEventArgs e)
|
||||||
{
|
{
|
||||||
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () => {
|
RunnerHelper.WaitForPowerToysRunner(_powerToysPid, () =>
|
||||||
|
{
|
||||||
Dispose();
|
Dispose();
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
});
|
});
|
||||||
|
@ -104,7 +105,7 @@ namespace PowerLauncher
|
||||||
RegisterExitEvents();
|
RegisterExitEvents();
|
||||||
|
|
||||||
_settingsWatcher = new SettingsWatcher(_settings);
|
_settingsWatcher = new SettingsWatcher(_settings);
|
||||||
|
|
||||||
_mainVM.MainWindowVisibility = Visibility.Visible;
|
_mainVM.MainWindowVisibility = Visibility.Visible;
|
||||||
_mainVM.ColdStartFix();
|
_mainVM.ColdStartFix();
|
||||||
_themeManager.ThemeChanged += OnThemeChanged;
|
_themeManager.ThemeChanged += OnThemeChanged;
|
||||||
|
|
|
@ -10,14 +10,14 @@ namespace PowerLauncher.Helper
|
||||||
{
|
{
|
||||||
private static void Report(Exception e)
|
private static void Report(Exception e)
|
||||||
{
|
{
|
||||||
if( e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
var logger = LogManager.GetLogger("UnHandledException");
|
var logger = LogManager.GetLogger("UnHandledException");
|
||||||
logger.Fatal(ExceptionFormatter.FormatException(e));
|
logger.Fatal(ExceptionFormatter.FormatException(e));
|
||||||
|
|
||||||
var reportWindow = new ReportWindow(e);
|
var reportWindow = new ReportWindow(e);
|
||||||
reportWindow.Show();
|
reportWindow.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
public static void UnhandledExceptionHandle(object sender, UnhandledExceptionEventArgs e)
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace PowerLauncher.Helper
|
||||||
/// <param name="newItems"></param>
|
/// <param name="newItems"></param>
|
||||||
public void Update(List<ResultViewModel> newItems)
|
public void Update(List<ResultViewModel> newItems)
|
||||||
{
|
{
|
||||||
if(newItems == null)
|
if (newItems == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(newItems));
|
throw new ArgumentNullException(nameof(newItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
int newCount = newItems.Count;
|
int newCount = newItems.Count;
|
||||||
int oldCount = Items.Count;
|
int oldCount = Items.Count;
|
||||||
int location = newCount > oldCount ? oldCount : newCount;
|
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/
|
// http://blogs.microsoft.co.il/arik/2010/05/28/wpf-single-instance-application/
|
||||||
// modified to allow single instance restart
|
// modified to allow single instance restart
|
||||||
namespace PowerLauncher.Helper
|
namespace PowerLauncher.Helper
|
||||||
{
|
{
|
||||||
internal enum WM
|
internal enum WM
|
||||||
{
|
{
|
||||||
|
@ -208,12 +208,12 @@ namespace PowerLauncher.Helper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ISingleInstanceApp
|
public interface ISingleInstanceApp
|
||||||
{
|
{
|
||||||
void OnSecondAppStarted();
|
void OnSecondAppStarted();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This class checks to make sure that only one instance of
|
/// 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.
|
/// running as Administrator, can activate it with command line arguments.
|
||||||
/// For most apps, this will not be much of an issue.
|
/// For most apps, this will not be much of an issue.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public static class SingleInstance<TApplication>
|
public static class SingleInstance<TApplication>
|
||||||
where TApplication: Application , ISingleInstanceApp
|
where TApplication : Application, ISingleInstanceApp
|
||||||
|
|
||||||
{
|
{
|
||||||
#region Private Fields
|
#region Private Fields
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ namespace PowerLauncher.Helper
|
||||||
/// If not, activates the first instance.
|
/// If not, activates the first instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>True if this is the first instance of the application.</returns>
|
/// <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.
|
// Build unique application Id and the IPC channel name.
|
||||||
string applicationIdentifier = uniqueName + Environment.UserName;
|
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.
|
/// Gets command line args - for ClickOnce deployed applications, command line args may not be passed directly, they have to be retrieved.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>List of command line arg strings.</returns>
|
/// <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;
|
string[] args = null;
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ namespace PowerLauncher.Helper
|
||||||
}
|
}
|
||||||
catch (NotSupportedException)
|
catch (NotSupportedException)
|
||||||
{
|
{
|
||||||
|
|
||||||
// The application was clickonce deployed
|
// The application was clickonce deployed
|
||||||
// Clickonce deployed apps cannot receive traditional commandline arguments
|
// Clickonce deployed apps cannot receive traditional commandline arguments
|
||||||
// As a workaround commandline arguments can be written to a shared location before
|
// 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))
|
using (NamedPipeServerStream pipeServer = new NamedPipeServerStream(channelName, PipeDirection.In))
|
||||||
{
|
{
|
||||||
while(true)
|
while (true)
|
||||||
{
|
{
|
||||||
// Wait for connection to the pipe
|
// Wait for connection to the pipe
|
||||||
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
|
await pipeServer.WaitForConnectionAsync().ConfigureAwait(false);
|
||||||
|
|
|
@ -110,7 +110,7 @@ namespace PowerLauncher
|
||||||
|
|
||||||
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
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)
|
if (Visibility == System.Windows.Visibility.Visible)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ namespace PowerLauncher
|
||||||
_viewModel.LastQuerySelected = true;
|
_viewModel.LastQuerySelected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.PropertyName == nameof(MainViewModel.SystemQueryText))
|
else if (e.PropertyName == nameof(MainViewModel.SystemQueryText))
|
||||||
{
|
{
|
||||||
this._isTextSetProgrammatically = true;
|
this._isTextSetProgrammatically = true;
|
||||||
|
@ -153,19 +153,19 @@ namespace PowerLauncher
|
||||||
|
|
||||||
private void OnActivated(object sender, EventArgs e)
|
private void OnActivated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_settings.ClearInputOnLaunch)
|
if (_settings.ClearInputOnLaunch)
|
||||||
{
|
{
|
||||||
_viewModel.ClearQueryCommand.Execute(null);
|
_viewModel.ClearQueryCommand.Execute(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDeactivated(object sender, EventArgs e)
|
private void OnDeactivated(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_settings.HideWhenDeactivated)
|
if (_settings.HideWhenDeactivated)
|
||||||
{
|
{
|
||||||
//(this.FindResource("OutroStoryboard") as Storyboard).Begin();
|
//(this.FindResource("OutroStoryboard") as Storyboard).Begin();
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdatePosition()
|
private void UpdatePosition()
|
||||||
|
@ -176,7 +176,7 @@ namespace PowerLauncher
|
||||||
Top = _settings.WindowTop;
|
Top = _settings.WindowTop;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Top = WindowTop();
|
Top = WindowTop();
|
||||||
Left = WindowLeft();
|
Left = WindowLeft();
|
||||||
}
|
}
|
||||||
|
@ -290,7 +290,7 @@ namespace PowerLauncher
|
||||||
private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
private void SuggestionsList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
ListView listview = (ListView)sender;
|
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)
|
if (e.AddedItems.Count > 0 && e.AddedItems[0] != null)
|
||||||
{
|
{
|
||||||
listview.ScrollIntoView(e.AddedItems[0]);
|
listview.ScrollIntoView(e.AddedItems[0]);
|
||||||
|
@ -304,7 +304,7 @@ namespace PowerLauncher
|
||||||
_viewModel.Results.SelectedIndex,
|
_viewModel.Results.SelectedIndex,
|
||||||
_viewModel.Results.SelectedItem?.ToString(),
|
_viewModel.Results.SelectedItem?.ToString(),
|
||||||
_viewModel.QueryText);
|
_viewModel.QueryText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const int millisecondsToWait = 100;
|
private const int millisecondsToWait = 100;
|
||||||
|
@ -312,7 +312,7 @@ namespace PowerLauncher
|
||||||
private bool disposedValue = false;
|
private bool disposedValue = false;
|
||||||
|
|
||||||
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
private void QueryTextBox_TextChanged(object sender, TextChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_isTextSetProgrammatically)
|
if (_isTextSetProgrammatically)
|
||||||
{
|
{
|
||||||
var textBox = ((TextBox)sender);
|
var textBox = ((TextBox)sender);
|
||||||
|
@ -345,7 +345,7 @@ namespace PowerLauncher
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
private void ListBox_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ChangedButton == MouseButton.Right)
|
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 ShowMsg(string title, string subTitle = "", string iconPath = "", bool useMainWindowAsOwner = true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InstallPlugin(string path)
|
public void InstallPlugin(string path)
|
||||||
|
@ -115,16 +115,16 @@ namespace Wox
|
||||||
{
|
{
|
||||||
ThemeChanged?.Invoke(oldTheme, newTheme);
|
ThemeChanged?.Invoke(oldTheme, newTheme);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
_themeManager.ThemeChanged -= OnThemeChanged;
|
_themeManager.ThemeChanged -= OnThemeChanged;
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -1,14 +1,17 @@
|
||||||
namespace PowerLauncher.Properties {
|
namespace PowerLauncher.Properties
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
// This class allows you to handle specific events on the settings class:
|
// 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 SettingChanging event is raised before a setting's value is changed.
|
||||||
// The PropertyChanged event is raised after 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 SettingsLoaded event is raised after the setting values are loaded.
|
||||||
// The SettingsSaving event is raised before the setting values are saved.
|
// The SettingsSaving event is raised before the setting values are saved.
|
||||||
internal sealed partial class Settings {
|
internal sealed partial class Settings
|
||||||
|
{
|
||||||
public Settings() {
|
|
||||||
|
public Settings()
|
||||||
|
{
|
||||||
// // To add event handlers for saving and changing settings, uncomment the lines below:
|
// // To add event handlers for saving and changing settings, uncomment the lines below:
|
||||||
//
|
//
|
||||||
// this.SettingChanging += this.SettingChangingEventHandler;
|
// this.SettingChanging += this.SettingChangingEventHandler;
|
||||||
|
@ -16,12 +19,14 @@
|
||||||
// this.SettingsSaving += this.SettingsSavingEventHandler;
|
// 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.
|
// 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.
|
// Add code to handle the SettingsSaving event here.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace PowerLauncher
|
||||||
{
|
{
|
||||||
_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);
|
||||||
|
|
||||||
// Load initial settings file
|
// Load initial settings file
|
||||||
OverloadSettings();
|
OverloadSettings();
|
||||||
|
@ -75,7 +75,7 @@ namespace PowerLauncher
|
||||||
|
|
||||||
if (_settings.ClearInputOnLaunch != overloadSettings.Properties.clear_input_on_launch)
|
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.
|
// 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 Title { get; set; }
|
||||||
public string Glyph { get; set; }
|
public string Glyph { get; set; }
|
||||||
public string FontFamily { get; set; }
|
public string FontFamily { get; set; }
|
||||||
public ICommand Command {
|
public ICommand Command
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this._command;
|
return this._command;
|
||||||
|
|
|
@ -117,7 +117,7 @@ namespace PowerLauncher.ViewModel
|
||||||
|
|
||||||
private void InitializeKeyCommands()
|
private void InitializeKeyCommands()
|
||||||
{
|
{
|
||||||
IgnoreCommand = new RelayCommand(_ => {});
|
IgnoreCommand = new RelayCommand(_ => { });
|
||||||
|
|
||||||
EscCommand = new RelayCommand(_ =>
|
EscCommand = new RelayCommand(_ =>
|
||||||
{
|
{
|
||||||
|
@ -187,7 +187,7 @@ namespace PowerLauncher.ViewModel
|
||||||
results.SelectedIndex = int.Parse(index.ToString(), CultureInfo.InvariantCulture);
|
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.
|
//If there is a context button selected fire the action for that button before the main command.
|
||||||
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
|
bool didExecuteContextButton = results.SelectedItem.ExecuteSelectedContextButton();
|
||||||
|
@ -218,7 +218,7 @@ namespace PowerLauncher.ViewModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
LoadContextMenuCommand = new RelayCommand(_ =>
|
LoadContextMenuCommand = new RelayCommand(_ =>
|
||||||
|
@ -248,12 +248,12 @@ namespace PowerLauncher.ViewModel
|
||||||
|
|
||||||
ClearQueryCommand = new RelayCommand(_ =>
|
ClearQueryCommand = new RelayCommand(_ =>
|
||||||
{
|
{
|
||||||
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));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +271,7 @@ namespace PowerLauncher.ViewModel
|
||||||
public string SystemQueryText { get; set; } = String.Empty;
|
public string SystemQueryText { get; set; } = String.Empty;
|
||||||
|
|
||||||
public string QueryText { get; set; } = String.Empty;
|
public string QueryText { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// we need move cursor to end when we manually changed query
|
/// we need move cursor to end when we manually changed query
|
||||||
|
@ -280,11 +280,11 @@ namespace PowerLauncher.ViewModel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="queryText"></param>
|
/// <param name="queryText"></param>
|
||||||
/// <param name="requery">Optional Parameter that if true, will automatically execute a query against the updated text</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;
|
SystemQueryText = queryText;
|
||||||
|
|
||||||
if(requery)
|
if (requery)
|
||||||
{
|
{
|
||||||
QueryText = queryText;
|
QueryText = queryText;
|
||||||
Query();
|
Query();
|
||||||
|
@ -332,11 +332,13 @@ namespace PowerLauncher.ViewModel
|
||||||
|
|
||||||
private Visibility _visibility;
|
private Visibility _visibility;
|
||||||
|
|
||||||
public Visibility MainWindowVisibility {
|
public Visibility MainWindowVisibility
|
||||||
|
{
|
||||||
get { return _visibility; }
|
get { return _visibility; }
|
||||||
set {
|
set
|
||||||
|
{
|
||||||
_visibility = value;
|
_visibility = value;
|
||||||
if(value == Visibility.Visible)
|
if (value == Visibility.Visible)
|
||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent());
|
PowerToysTelemetry.Log.WriteEvent(new LauncherShowEvent());
|
||||||
}
|
}
|
||||||
|
@ -344,7 +346,7 @@ namespace PowerLauncher.ViewModel
|
||||||
{
|
{
|
||||||
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
|
PowerToysTelemetry.Log.WriteEvent(new LauncherHideEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +505,7 @@ namespace PowerLauncher.ViewModel
|
||||||
_updateSource?.Cancel();
|
_updateSource?.Cancel();
|
||||||
_lastQuery = _emptyQuery;
|
_lastQuery = _emptyQuery;
|
||||||
Results.SelectedItem = null;
|
Results.SelectedItem = null;
|
||||||
Results.Clear();
|
Results.Clear();
|
||||||
Results.Visibility = Visibility.Collapsed;
|
Results.Visibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -569,7 +571,7 @@ namespace PowerLauncher.ViewModel
|
||||||
hotkey.Shift = hotkeyModel.Shift;
|
hotkey.Shift = hotkeyModel.Shift;
|
||||||
hotkey.Ctrl = hotkeyModel.Ctrl;
|
hotkey.Ctrl = hotkeyModel.Ctrl;
|
||||||
hotkey.Win = hotkeyModel.Win;
|
hotkey.Win = hotkeyModel.Win;
|
||||||
hotkey.Key = (byte) KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey);
|
hotkey.Key = (byte)KeyInterop.VirtualKeyFromKey(hotkeyModel.CharKey);
|
||||||
|
|
||||||
_hotkeyHandle = _hotkeyManager.RegisterHotkey(hotkey, action);
|
_hotkeyHandle = _hotkeyManager.RegisterHotkey(hotkey, action);
|
||||||
}
|
}
|
||||||
|
@ -672,7 +674,7 @@ namespace PowerLauncher.ViewModel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
|
public void UpdateResultView(List<Result> list, PluginMetadata metadata, Query originQuery)
|
||||||
{
|
{
|
||||||
if(list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(list));
|
throw new ArgumentNullException(nameof(list));
|
||||||
}
|
}
|
||||||
|
@ -799,8 +801,8 @@ namespace PowerLauncher.ViewModel
|
||||||
_hotkeyManager.Dispose();
|
_hotkeyManager.Dispose();
|
||||||
_updateSource.Dispose();
|
_updateSource.Dispose();
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
|
@ -42,10 +42,10 @@ namespace PowerLauncher.ViewModel
|
||||||
{
|
{
|
||||||
Result = result;
|
Result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContextMenuSelectedIndex = NoSelectionIndex;
|
ContextMenuSelectedIndex = NoSelectionIndex;
|
||||||
LoadContextMenu();
|
LoadContextMenu();
|
||||||
|
|
||||||
ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction);
|
ActivateContextButtonsHoverCommand = new RelayCommand(ActivateContextButtonsHoverAction);
|
||||||
ActivateContextButtonsSelectionCommand = new RelayCommand(ActivateContextButtonsSelectionAction);
|
ActivateContextButtonsSelectionCommand = new RelayCommand(ActivateContextButtonsSelectionAction);
|
||||||
DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction);
|
DeactivateContextButtonsHoverCommand = new RelayCommand(DeactivateContextButtonsHoverAction);
|
||||||
|
|
|
@ -165,7 +165,7 @@ namespace PowerLauncher.ViewModel
|
||||||
public void SelectNextTabItem()
|
public void SelectNextTabItem()
|
||||||
{
|
{
|
||||||
//Do nothing if there is no selected item or we've selected the next context button
|
//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();
|
SelectNextResult();
|
||||||
}
|
}
|
||||||
|
@ -320,6 +320,6 @@ namespace PowerLauncher.ViewModel
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -39,7 +39,7 @@ namespace PowerLauncher.ViewModel
|
||||||
#region about
|
#region about
|
||||||
|
|
||||||
public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
public string ActivatedTimes => string.Format(CultureInfo.InvariantCulture, _translater.GetTranslation("about_activate_times"), Settings.ActivateTimes);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,10 @@ namespace Wox.Core.Plugin
|
||||||
return Execute(_startInfo);
|
return Execute(_startInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string ExecuteContextMenu(Result selectedResult) {
|
protected override string ExecuteContextMenu(Result selectedResult)
|
||||||
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel {
|
{
|
||||||
|
JsonRPCServerRequestModel request = new JsonRPCServerRequestModel
|
||||||
|
{
|
||||||
Method = "contextmenu",
|
Method = "contextmenu",
|
||||||
Parameters = new object[] { selectedResult.ContextData },
|
Parameters = new object[] { selectedResult.ContextData },
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,7 +71,8 @@ namespace Wox.Core.Plugin
|
||||||
|
|
||||||
private string GetParameterByType(object parameter)
|
private string GetParameterByType(object parameter)
|
||||||
{
|
{
|
||||||
if (parameter == null) {
|
if (parameter == null)
|
||||||
|
{
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
if (parameter is string)
|
if (parameter is string)
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace Wox.Core.Plugin
|
||||||
|
|
||||||
public static void ReloadData()
|
public static void ReloadData()
|
||||||
{
|
{
|
||||||
foreach(var plugin in AllPlugins)
|
foreach (var plugin in AllPlugins)
|
||||||
{
|
{
|
||||||
var reloadablePlugin = plugin.Plugin as IReloadable;
|
var reloadablePlugin = plugin.Plugin as IReloadable;
|
||||||
reloadablePlugin?.ReloadData();
|
reloadablePlugin?.ReloadData();
|
||||||
|
@ -104,7 +104,7 @@ namespace Wox.Core.Plugin
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e);
|
Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e);
|
||||||
pair.Metadata.Disabled = true;
|
pair.Metadata.Disabled = true;
|
||||||
failedPlugins.Enqueue(pair);
|
failedPlugins.Enqueue(pair);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -271,10 +271,10 @@ namespace Wox.Core.Plugin
|
||||||
{
|
{
|
||||||
GlobalPlugins.Remove(plugin);
|
GlobalPlugins.Remove(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(oldActionkeyword != Query.GlobalPluginWildcardSign)
|
if (oldActionkeyword != Query.GlobalPluginWildcardSign)
|
||||||
NonGlobalPlugins.Remove(oldActionkeyword);
|
NonGlobalPlugins.Remove(oldActionkeyword);
|
||||||
|
|
||||||
|
|
||||||
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
|
plugin.Metadata.ActionKeywords.Remove(oldActionkeyword);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,10 @@ namespace Wox.Core.Resource
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return (FontWeight) fontWeightConverter.ConvertFromInvariantString(value);
|
return (FontWeight)fontWeightConverter.ConvertFromInvariantString(value);
|
||||||
}
|
}
|
||||||
catch {
|
catch
|
||||||
|
{
|
||||||
return FontWeights.Normal;
|
return FontWeights.Normal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Wox.Infrastructure
|
||||||
private ConcurrentDictionary<string, string[][]> PinyinCache;
|
private ConcurrentDictionary<string, string[][]> PinyinCache;
|
||||||
private BinaryStorage<Dictionary<string, string[][]>> _pinyinStorage;
|
private BinaryStorage<Dictionary<string, string[][]>> _pinyinStorage;
|
||||||
private Settings _settings;
|
private Settings _settings;
|
||||||
|
|
||||||
public void Initialize([NotNull] Settings settings)
|
public void Initialize([NotNull] Settings settings)
|
||||||
{
|
{
|
||||||
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
_settings = settings ?? throw new ArgumentNullException(nameof(settings));
|
||||||
|
@ -60,10 +60,10 @@ namespace Wox.Infrastructure
|
||||||
|
|
||||||
if (!ContainsChinese(source))
|
if (!ContainsChinese(source))
|
||||||
return source;
|
return source;
|
||||||
|
|
||||||
var combination = PinyinCombination(source);
|
var combination = PinyinCombination(source);
|
||||||
|
|
||||||
var pinyinArray=combination.Select(x => string.Join("", x));
|
var pinyinArray = combination.Select(x => string.Join("", x));
|
||||||
var acronymArray = combination.Select(Acronym).Distinct();
|
var acronymArray = combination.Select(Acronym).Distinct();
|
||||||
|
|
||||||
var joinedSingleStringCombination = new StringBuilder();
|
var joinedSingleStringCombination = new StringBuilder();
|
||||||
|
@ -77,7 +77,7 @@ namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
if (!_settings.ShouldUsePinyin)
|
if (!_settings.ShouldUsePinyin)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_pinyinStorage.Save(GetPinyinCacheAsDictionary());
|
_pinyinStorage.Save(GetPinyinCacheAsDictionary());
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,12 +90,12 @@ namespace Wox.Infrastructure.Exception
|
||||||
else if (string.IsNullOrEmpty(ass.Location))
|
else if (string.IsNullOrEmpty(ass.Location))
|
||||||
{
|
{
|
||||||
sb.Append("location is null or empty");
|
sb.Append("location is null or empty");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sb.Append(ass.Location);
|
sb.Append(ass.Location);
|
||||||
|
|
||||||
}
|
}
|
||||||
sb.AppendLine(")");
|
sb.AppendLine(")");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Wox.Infrastructure.FileSystemHelper
|
||||||
public FileVersionInfoWrapper() { }
|
public FileVersionInfoWrapper() { }
|
||||||
public FileVersionInfo GetVersionInfo(string path)
|
public FileVersionInfo GetVersionInfo(string path)
|
||||||
{
|
{
|
||||||
if(File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
return FileVersionInfo.GetVersionInfo(path);
|
return FileVersionInfo.GetVersionInfo(path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
Process.Start(info);
|
Process.Start(info);
|
||||||
}
|
}
|
||||||
catch(System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex);
|
Log.Exception($"Wox.Infrastructure.Helper| Unable to Run {path} as admin : {ex.Message}", ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -103,7 +103,7 @@ namespace Wox.Infrastructure.Hotkey
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CharKey = (Key) Enum.Parse(typeof (Key), charKey);
|
CharKey = (Key)Enum.Parse(typeof(Key), charKey);
|
||||||
}
|
}
|
||||||
catch (ArgumentException)
|
catch (ArgumentException)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Wox.Infrastructure.Image
|
||||||
var i = _data[path];
|
var i = _data[path];
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_data[path] = value;
|
_data[path] = value;
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ namespace Wox.Infrastructure.Image
|
||||||
int ImageCacheValue;
|
int ImageCacheValue;
|
||||||
if (GuidToKey.TryGetValue(hash, out string key))
|
if (GuidToKey.TryGetValue(hash, out string key))
|
||||||
{ // image already exists
|
{ // image already exists
|
||||||
if(ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
|
if (ImageCache.Usage.TryGetValue(path, out ImageCacheValue))
|
||||||
{
|
{
|
||||||
img = ImageCache[key];
|
img = ImageCache[key];
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,8 +41,8 @@ namespace Wox.Infrastructure.Image
|
||||||
internal interface IShellItem
|
internal interface IShellItem
|
||||||
{
|
{
|
||||||
void BindToHandler(IntPtr pbc,
|
void BindToHandler(IntPtr pbc,
|
||||||
[MarshalAs(UnmanagedType.LPStruct)]Guid bhid,
|
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
|
||||||
[MarshalAs(UnmanagedType.LPStruct)]Guid riid,
|
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
|
||||||
out IntPtr ppv);
|
out IntPtr ppv);
|
||||||
|
|
||||||
void GetParent(out IShellItem ppsi);
|
void GetParent(out IShellItem ppsi);
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace Wox.Infrastructure.Logger
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||||
public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")
|
public static void Exception(string className, string message, System.Exception exception, [CallerMemberName] string methodName = "")
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
||||||
if (_storageHelper.clearCache)
|
if (_storageHelper.clearCache)
|
||||||
{
|
{
|
||||||
if(File.Exists(FilePath))
|
if (File.Exists(FilePath))
|
||||||
{
|
{
|
||||||
File.Delete(FilePath);
|
File.Delete(FilePath);
|
||||||
Log.Info($"|BinaryStorage.TryLoad|Deleting cached data| <{FilePath}>");
|
Log.Info($"|BinaryStorage.TryLoad|Deleting cached data| <{FilePath}>");
|
||||||
|
|
|
@ -8,14 +8,14 @@ namespace Wox.Infrastructure.Storage
|
||||||
{
|
{
|
||||||
public FileSystemWatcherWrapper() { }
|
public FileSystemWatcherWrapper() { }
|
||||||
|
|
||||||
Collection<string> IFileSystemWatcherWrapper.Filters
|
Collection<string> IFileSystemWatcherWrapper.Filters
|
||||||
{
|
{
|
||||||
get => this.Filters;
|
get => this.Filters;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if(value != null)
|
if (value != null)
|
||||||
{
|
{
|
||||||
foreach(string filter in value)
|
foreach (string filter in value)
|
||||||
{
|
{
|
||||||
this.Filters.Add(filter);
|
this.Filters.Add(filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
// Depending on the version number of the previously installed PT Run, delete the cache if it is found to be incompatible
|
||||||
if (_storageHelper.clearCache)
|
if (_storageHelper.clearCache)
|
||||||
{
|
{
|
||||||
if(File.Exists(FilePath))
|
if (File.Exists(FilePath))
|
||||||
{
|
{
|
||||||
File.Delete(FilePath);
|
File.Delete(FilePath);
|
||||||
Log.Info($"|JsonStorage.TryLoad|Deleting cached data|<{FilePath}>");
|
Log.Info($"|JsonStorage.TryLoad|Deleting cached data|<{FilePath}>");
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
|
|
||||||
public ListRepository()
|
public ListRepository()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Set(IList<T> items)
|
public void Set(IList<T> items)
|
||||||
|
@ -35,7 +35,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
{
|
{
|
||||||
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
|
_items = new ConcurrentDictionary<int, T>(items.ToDictionary(i => i.GetHashCode()));
|
||||||
}
|
}
|
||||||
catch(ArgumentException e)
|
catch (ArgumentException e)
|
||||||
{
|
{
|
||||||
Log.Info($"|LisRepository.Set| Trying to insert a duplicate item", e.Message);
|
Log.Info($"|LisRepository.Set| Trying to insert a duplicate item", e.Message);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
{
|
{
|
||||||
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
|
Log.Error($"|ListRepository.Add| Item Already Exists <{insertedItem}>");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Remove(T removedItem)
|
public void Remove(T removedItem)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Wox.Infrastructure.Storage
|
namespace Wox.Infrastructure.Storage
|
||||||
{
|
{
|
||||||
public class PluginJsonStorage<T> :JsonStorage<T> where T : new()
|
public class PluginJsonStorage<T> : JsonStorage<T> where T : new()
|
||||||
{
|
{
|
||||||
public PluginJsonStorage()
|
public PluginJsonStorage()
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace Wox.Infrastructure.Storage
|
||||||
// This detail is accessed by the storage items and is used to decide if the cache must be deleted or not
|
// This detail is accessed by the storage items and is used to decide if the cache must be deleted or not
|
||||||
public bool clearCache = false;
|
public bool clearCache = false;
|
||||||
|
|
||||||
|
|
||||||
private String currentPowerToysVersion = String.Empty;
|
private String currentPowerToysVersion = String.Empty;
|
||||||
private String FilePath { get; set; } = String.Empty;
|
private String FilePath { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
@ -32,17 +32,17 @@ namespace Wox.Infrastructure.Storage
|
||||||
|
|
||||||
// If there is some error in populating/retrieving the version numbers, then the cache must be deleted
|
// If there is some error in populating/retrieving the version numbers, then the cache must be deleted
|
||||||
// This case will not be hit, but is present as a fail safe
|
// This case will not be hit, but is present as a fail safe
|
||||||
if(String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2))
|
if (String.IsNullOrEmpty(version1) || String.IsNullOrEmpty(version2))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
string[] split1 = version1.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
|
string[] split1 = version1.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
string[] split2 = version2.Split( new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
|
string[] split2 = version2.Split(new string[] { version, period }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
|
||||||
for(int i=0; i<versionLength; i++)
|
for (int i = 0; i < versionLength; i++)
|
||||||
{
|
{
|
||||||
if(int.Parse(split1[i]) < int.Parse(split2[i]))
|
if (int.Parse(split1[i]) < int.Parse(split2[i]))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,11 @@ namespace Wox.Infrastructure.Storage
|
||||||
string cacheSuffix = ".cache";
|
string cacheSuffix = ".cache";
|
||||||
string jsonSuffix = ".json";
|
string jsonSuffix = ".json";
|
||||||
|
|
||||||
if(type == (uint)StorageType.BINARY_STORAGE)
|
if (type == (uint)StorageType.BINARY_STORAGE)
|
||||||
{
|
{
|
||||||
suffix = cacheSuffix;
|
suffix = cacheSuffix;
|
||||||
}
|
}
|
||||||
else if(type == (uint)StorageType.JSON_STORAGE)
|
else if (type == (uint)StorageType.JSON_STORAGE)
|
||||||
{
|
{
|
||||||
suffix = jsonSuffix;
|
suffix = jsonSuffix;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ namespace Wox.Infrastructure
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption opt)
|
public MatchResult FuzzyMatch(string query, string stringToCompare, MatchOption opt)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult (false, UserSettingSearchPrecision);
|
if (string.IsNullOrEmpty(stringToCompare) || string.IsNullOrEmpty(query)) return new MatchResult(false, UserSettingSearchPrecision);
|
||||||
|
|
||||||
query = query.Trim();
|
query = query.Trim();
|
||||||
|
|
||||||
if (_alphabet != null)
|
if (_alphabet != null)
|
||||||
|
@ -70,8 +70,8 @@ namespace Wox.Infrastructure
|
||||||
|
|
||||||
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
|
var fullStringToCompareWithoutCase = opt.IgnoreCase ? stringToCompare.ToLower() : stringToCompare;
|
||||||
|
|
||||||
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
|
var queryWithoutCase = opt.IgnoreCase ? query.ToLower() : query;
|
||||||
|
|
||||||
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
var querySubstrings = queryWithoutCase.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
int currentQuerySubstringIndex = 0;
|
int currentQuerySubstringIndex = 0;
|
||||||
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
var currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
||||||
|
@ -153,9 +153,9 @@ namespace Wox.Infrastructure
|
||||||
currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
currentQuerySubstring = querySubstrings[currentQuerySubstringIndex];
|
||||||
currentQuerySubstringCharacterIndex = 0;
|
currentQuerySubstringCharacterIndex = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// proceed to calculate score if every char or substring without whitespaces matched
|
// proceed to calculate score if every char or substring without whitespaces matched
|
||||||
if (allQuerySubstringsMatched)
|
if (allQuerySubstringsMatched)
|
||||||
{
|
{
|
||||||
var nearestSpaceIndex = CalculateClosestSpaceIndex(spaceIndices, firstMatchIndex);
|
var nearestSpaceIndex = CalculateClosestSpaceIndex(spaceIndices, firstMatchIndex);
|
||||||
|
@ -164,13 +164,13 @@ namespace Wox.Infrastructure
|
||||||
return new MatchResult(true, UserSettingSearchPrecision, indexList, score);
|
return new MatchResult(true, UserSettingSearchPrecision, indexList, score);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new MatchResult (false, UserSettingSearchPrecision);
|
return new MatchResult(false, UserSettingSearchPrecision);
|
||||||
}
|
}
|
||||||
|
|
||||||
// To get the index of the closest space which preceeds the first matching index
|
// To get the index of the closest space which preceeds the first matching index
|
||||||
private int CalculateClosestSpaceIndex(List<int> spaceIndices, int firstMatchIndex)
|
private int CalculateClosestSpaceIndex(List<int> spaceIndices, int firstMatchIndex)
|
||||||
{
|
{
|
||||||
if(spaceIndices.Count == 0)
|
if (spaceIndices.Count == 0)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ namespace Wox.Infrastructure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex,
|
private static bool AllPreviousCharsMatched(int startIndexToVerify, int currentQuerySubstringCharacterIndex,
|
||||||
string fullStringToCompareWithoutCase, string currentQuerySubstring)
|
string fullStringToCompareWithoutCase, string currentQuerySubstring)
|
||||||
{
|
{
|
||||||
var allMatch = true;
|
var allMatch = true;
|
||||||
|
@ -196,8 +196,8 @@ namespace Wox.Infrastructure
|
||||||
}
|
}
|
||||||
|
|
||||||
return allMatch;
|
return allMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<int> GetUpdatedIndexList(int startIndexToVerify, int currentQuerySubstringCharacterIndex, int firstMatchIndexInWord, List<int> indexList)
|
private static List<int> GetUpdatedIndexList(int startIndexToVerify, int currentQuerySubstringCharacterIndex, int firstMatchIndexInWord, List<int> indexList)
|
||||||
{
|
{
|
||||||
var updatedList = new List<int>();
|
var updatedList = new List<int>();
|
||||||
|
@ -240,7 +240,7 @@ namespace Wox.Infrastructure
|
||||||
{
|
{
|
||||||
int count = query.Count(c => !char.IsWhiteSpace(c));
|
int count = query.Count(c => !char.IsWhiteSpace(c));
|
||||||
int threshold = 4;
|
int threshold = 4;
|
||||||
if(count <= threshold)
|
if (count <= threshold)
|
||||||
{
|
{
|
||||||
score += count * 10;
|
score += count * 10;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||||
{
|
{
|
||||||
ID = metadata.ID,
|
ID = metadata.ID,
|
||||||
Name = metadata.Name,
|
Name = metadata.Name,
|
||||||
ActionKeywords = metadata.ActionKeywords,
|
ActionKeywords = metadata.ActionKeywords,
|
||||||
Disabled = metadata.Disabled
|
Disabled = metadata.Disabled
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,14 @@ namespace Wox.Infrastructure.UserSettings
|
||||||
{
|
{
|
||||||
private string _hotkey = "Alt + Space";
|
private string _hotkey = "Alt + Space";
|
||||||
private string _previousHotkey = "";
|
private string _previousHotkey = "";
|
||||||
public string PreviousHotkey {
|
public string PreviousHotkey
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _previousHotkey;
|
return _previousHotkey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string Hotkey
|
public string Hotkey
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -84,7 +85,7 @@ namespace Wox.Infrastructure.UserSettings
|
||||||
public double WindowTop { get; set; }
|
public double WindowTop { get; set; }
|
||||||
|
|
||||||
private int _maxResultsToShow = 4;
|
private int _maxResultsToShow = 4;
|
||||||
public int MaxResultsToShow
|
public int MaxResultsToShow
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace Wox.Plugin
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Website { get; set; }
|
public string Website { get; set; }
|
||||||
public bool Disabled { get; set; }
|
public bool Disabled { get; set; }
|
||||||
public string ExecuteFilePath { get; private set;}
|
public string ExecuteFilePath { get; private set; }
|
||||||
|
|
||||||
public string ExecuteFileName { get; set; }
|
public string ExecuteFileName { get; set; }
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace Wox.Plugin
|
||||||
|
|
||||||
public List<string> ActionKeywords { get; set; }
|
public List<string> ActionKeywords { get; set; }
|
||||||
|
|
||||||
public string IcoPath { get; set;}
|
public string IcoPath { get; set; }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
public IPlugin Plugin { get; internal set; }
|
public IPlugin Plugin { get; internal set; }
|
||||||
public PluginMetadata Metadata { get; internal set; }
|
public PluginMetadata Metadata { get; internal set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,8 +14,9 @@ namespace Wox.Plugin
|
||||||
private ToolTipData _toolTipData;
|
private ToolTipData _toolTipData;
|
||||||
private string _pluginDirectory;
|
private string _pluginDirectory;
|
||||||
private string _icoPath;
|
private string _icoPath;
|
||||||
public string Title {
|
public string Title
|
||||||
get { return _title; }
|
{
|
||||||
|
get { return _title; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_title = value.Replace("\n", " ");
|
_title = value.Replace("\n", " ");
|
||||||
|
|
|
@ -70,11 +70,11 @@ namespace Wox.Plugin
|
||||||
{
|
{
|
||||||
return currentTheme;
|
return currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Theme GetHighContrastBaseType()
|
private static Theme GetHighContrastBaseType()
|
||||||
{
|
{
|
||||||
string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
|
string RegistryKey = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
|
||||||
string theme = (string) Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
|
string theme = (string)Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
|
||||||
theme = theme.Split('\\').Last().Split('.').First().ToString();
|
theme = theme.Split('\\').Last().Split('.').First().ToString();
|
||||||
|
|
||||||
if (theme == "hc1")
|
if (theme == "hc1")
|
||||||
|
@ -153,13 +153,13 @@ namespace Wox.Plugin
|
||||||
protected virtual void Dispose(bool disposing)
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (!_disposed)
|
if (!_disposed)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
ControlzEx.Theming.ThemeManager.Current.ThemeChanged -= Current_ThemeChanged;
|
ControlzEx.Theming.ThemeManager.Current.ThemeChanged -= Current_ThemeChanged;
|
||||||
SystemParameters.StaticPropertyChanged -= SystemParameters_StaticPropertyChanged;
|
SystemParameters.StaticPropertyChanged -= SystemParameters_StaticPropertyChanged;
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +175,8 @@ namespace Wox.Plugin
|
||||||
public enum Theme
|
public enum Theme
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Light,
|
Light,
|
||||||
Dark,
|
Dark,
|
||||||
HighContrastOne,
|
HighContrastOne,
|
||||||
HighContrastTwo,
|
HighContrastTwo,
|
||||||
HighContrastBlack,
|
HighContrastBlack,
|
||||||
|
|
|
@ -9,8 +9,8 @@ namespace Wox.Plugin
|
||||||
public string Text { get; private set; }
|
public string Text { get; private set; }
|
||||||
|
|
||||||
public ToolTipData(string title, string text)
|
public ToolTipData(string title, string text)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrEmpty(title))
|
if (string.IsNullOrEmpty(title))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("title cannot be null or empty", "title");
|
throw new ArgumentException("title cannot be null or empty", "title");
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace Wox.Test
|
||||||
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, false)]
|
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, false)]
|
||||||
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.None, true)]
|
[TestCase("chr", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.None, true)]
|
||||||
[TestCase("ccs", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Low, true)]
|
[TestCase("ccs", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Low, true)]
|
||||||
[TestCase("cand", "Candy Crush Saga from King",StringMatcher.SearchPrecisionScore.Regular, true)]
|
[TestCase("cand", "Candy Crush Saga from King", StringMatcher.SearchPrecisionScore.Regular, true)]
|
||||||
[TestCase("cand", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
|
[TestCase("cand", "Help cure hope raise on mind entity Chrome", StringMatcher.SearchPrecisionScore.Regular, false)]
|
||||||
public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual(
|
public void WhenGivenDesiredPrecisionThenShouldReturnAllResultsGreaterOrEqual(
|
||||||
string queryString,
|
string queryString,
|
||||||
|
@ -159,7 +159,7 @@ namespace Wox.Test
|
||||||
bool expectedPrecisionResult)
|
bool expectedPrecisionResult)
|
||||||
{
|
{
|
||||||
// When
|
// When
|
||||||
var matcher = new StringMatcher {UserSettingSearchPrecision = expectedPrecisionScore};
|
var matcher = new StringMatcher { UserSettingSearchPrecision = expectedPrecisionScore };
|
||||||
|
|
||||||
// Given
|
// Given
|
||||||
var matchResult = matcher.FuzzyMatch(queryString, compareString);
|
var matchResult = matcher.FuzzyMatch(queryString, compareString);
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Wox.Test
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
string autoCompleteText = MainViewModel.GetAutoCompleteText(index, input, query);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.AreEqual(autoCompleteText, string.Empty);
|
Assert.AreEqual(autoCompleteText, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
|
@ -303,7 +303,7 @@ namespace Wox.Test.Plugins
|
||||||
[TestCase(0, true, ExpectedResult = true)]
|
[TestCase(0, true, ExpectedResult = true)]
|
||||||
[TestCase(1, false, ExpectedResult = true)]
|
[TestCase(1, false, ExpectedResult = true)]
|
||||||
[TestCase(1, true, ExpectedResult = true)]
|
[TestCase(1, true, ExpectedResult = true)]
|
||||||
public bool DriveDetection_MustDisplayResults_WhenEnhancedModeIsOnOrWhenWarningIsDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus)
|
public bool DriveDetection_MustDisplayResults_WhenEnhancedModeIsOnOrWhenWarningIsDisabled(int enhancedModeStatus, bool disableWarningCheckBoxStatus)
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var mockRegistry = new Mock<IRegistryWrapper>();
|
var mockRegistry = new Mock<IRegistryWrapper>();
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace PreviewPaneUnitTests
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
String mdString = "> Blockquotes.";
|
String mdString = "> Blockquotes.";
|
||||||
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(()=> { });
|
HTMLParsingExtension htmlParsingExtension = new HTMLParsingExtension(() => { });
|
||||||
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
MarkdownPipeline markdownPipeline = BuidPipeline(htmlParsingExtension);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue