mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Add right click option on query to disable program
This commit is contained in:
BIN
Plugins/Wox.Plugin.Program/Images/disable.png
Normal file
BIN
Plugins/Wox.Plugin.Program/Images/disable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
@@ -31,10 +31,15 @@
|
||||
|
||||
<system:String x:Key="wox_plugin_program_run_as_administrator">Run As Administrator</system:String>
|
||||
<system:String x:Key="wox_plugin_program_open_containing_folder">Open containing folder</system:String>
|
||||
<system:String x:Key="wox_plugin_program_disable_program">Disable this program from displaying</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_plugin_name">Program</system:String>
|
||||
<system:String x:Key="wox_plugin_program_plugin_description">Search programs in Wox</system:String>
|
||||
|
||||
<system:String x:Key="wox_plugin_program_invalid_path">Invalid Path</system:String>
|
||||
|
||||
<!--Dialogs-->
|
||||
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success">Success</system:String>
|
||||
<system:String x:Key="wox_plugin_program_disable_dlgtitle_success_message">Successfully disabled this program from displaying in your query</system:String>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -102,8 +102,6 @@ namespace Wox.Plugin.Program
|
||||
lock (IndexLock)
|
||||
{
|
||||
_uwps = support ? UWP.All() : new UWP.Application[] { };
|
||||
|
||||
//_uwps = UWP.RetainApplications(allUWPs, _settings.ProgramSources, _settings.EnableProgramSourceOnly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,16 +131,49 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public List<Result> LoadContextMenus(Result selectedResult)
|
||||
{
|
||||
var menuOptions = new List<Result>();
|
||||
var program = selectedResult.ContextData as IProgram;
|
||||
if (program != null)
|
||||
{
|
||||
var menus = program.ContextMenus(_context.API);
|
||||
return menus;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new List<Result>();
|
||||
menuOptions = program.ContextMenus(_context.API);
|
||||
}
|
||||
|
||||
menuOptions.Add(
|
||||
new Result
|
||||
{
|
||||
Title = _context.API.GetTranslation("wox_plugin_program_disable_program"),
|
||||
Action = c =>
|
||||
{
|
||||
DisableProgram(program);
|
||||
_context.API.ShowMsg(_context.API.GetTranslation("wox_plugin_program_disable_dlgtitle_success"),
|
||||
_context.API.GetTranslation("wox_plugin_program_disable_dlgtitle_success_message"));
|
||||
return false;
|
||||
},
|
||||
IcoPath = "Images/disable.png"
|
||||
}
|
||||
);
|
||||
|
||||
return menuOptions;
|
||||
}
|
||||
|
||||
private void DisableProgram(IProgram ProgramToDelete)
|
||||
{
|
||||
if(_uwps.Any(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier))
|
||||
_uwps.Where(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;
|
||||
|
||||
if (_win32s.Any(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier))
|
||||
_win32s.Where(x => x.UniqueIdentifier == ProgramToDelete.UniqueIdentifier).FirstOrDefault().Enabled = false;
|
||||
|
||||
_settings.DisabledProgramSources
|
||||
.Add(
|
||||
new Settings.DisabledProgramSource
|
||||
{
|
||||
Name = ProgramToDelete.Name,
|
||||
Location = ProgramToDelete.Location,
|
||||
UniqueIdentifier = ProgramToDelete.UniqueIdentifier,
|
||||
Enabled = false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public static bool StartProcess(ProcessStartInfo info)
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Wox.Plugin.Program.Programs
|
||||
{
|
||||
@@ -10,5 +6,8 @@ namespace Wox.Plugin.Program.Programs
|
||||
{
|
||||
List<Result> ContextMenus(IPublicAPI api);
|
||||
Result Result(string query, IPublicAPI api);
|
||||
string UniqueIdentifier { get; set; }
|
||||
string Name { get; }
|
||||
string Location { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,6 +241,9 @@ namespace Wox.Plugin.Program.Programs
|
||||
public string UserModelId { get; set; }
|
||||
public string BackgroundColor { get; set; }
|
||||
|
||||
public string Name => DisplayName;
|
||||
public string Location => Package.Location;
|
||||
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
public string LogoUri { get; set; }
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace Wox.Plugin.Program.Programs
|
||||
public string Description { get; set; }
|
||||
public bool Valid { get; set; }
|
||||
public bool Enabled { get; set; }
|
||||
public string Location => ParentDirectory;
|
||||
|
||||
private const string ShortcutExtension = "lnk";
|
||||
private const string ApplicationReferenceExtension = "appref-ms";
|
||||
|
||||
@@ -105,6 +105,9 @@
|
||||
<None Include="Images\folder.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Images\disable.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
<Content Include="Languages\en.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
Reference in New Issue
Block a user