mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 12:18:50 +02:00
Add initial disable program code
This commit is contained in:
@@ -17,14 +17,14 @@ namespace Wox.Plugin.Program
|
|||||||
public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable
|
public class Main : ISettingProvider, IPlugin, IPluginI18n, IContextMenu, ISavable
|
||||||
{
|
{
|
||||||
private static readonly object IndexLock = new object();
|
private static readonly object IndexLock = new object();
|
||||||
private static Win32[] _win32s;
|
internal static Win32[] _win32s { get; set; }
|
||||||
private static UWP.Application[] _uwps;
|
internal static UWP.Application[] _uwps { get; set; }
|
||||||
|
internal static Settings _settings { get; set; }
|
||||||
|
|
||||||
private static PluginInitContext _context;
|
private static PluginInitContext _context;
|
||||||
|
|
||||||
private static BinaryStorage<Win32[]> _win32Storage;
|
private static BinaryStorage<Win32[]> _win32Storage;
|
||||||
private static BinaryStorage<UWP.Application[]> _uwpStorage;
|
private static BinaryStorage<UWP.Application[]> _uwpStorage;
|
||||||
private static Settings _settings;
|
|
||||||
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
private readonly PluginJsonStorage<Settings> _settingsStorage;
|
||||||
|
|
||||||
public Main()
|
public Main()
|
||||||
|
|||||||
@@ -248,6 +248,8 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public string UserModelId { get; set; }
|
public string UserModelId { get; set; }
|
||||||
public string BackgroundColor { get; set; }
|
public string BackgroundColor { get; set; }
|
||||||
|
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
public string LogoUri { get; set; }
|
public string LogoUri { get; set; }
|
||||||
public string LogoPath { get; set; }
|
public string LogoPath { get; set; }
|
||||||
public UWP Package { get; set; }
|
public UWP Package { get; set; }
|
||||||
@@ -344,6 +346,8 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
Description = ResourceFromPri(package.FullName, Description);
|
Description = ResourceFromPri(package.FullName, Description);
|
||||||
LogoUri = LogoUriFromManifest(manifestApp);
|
LogoUri = LogoUriFromManifest(manifestApp);
|
||||||
LogoPath = LogoPathFromUri(LogoUri);
|
LogoPath = LogoPathFromUri(LogoUri);
|
||||||
|
|
||||||
|
Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string ResourceFromPri(string packageFullName, string resourceReference)
|
internal string ResourceFromPri(string packageFullName, string resourceReference)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
public string ExecutableName { get; set; }
|
public string ExecutableName { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public bool Valid { get; set; }
|
public bool Valid { get; set; }
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
private const string ShortcutExtension = "lnk";
|
private const string ShortcutExtension = "lnk";
|
||||||
private const string ApplicationReferenceExtension = "appref-ms";
|
private const string ApplicationReferenceExtension = "appref-ms";
|
||||||
@@ -129,7 +130,8 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
FullPath = path,
|
FullPath = path,
|
||||||
ParentDirectory = Directory.GetParent(path).FullName,
|
ParentDirectory = Directory.GetParent(path).FullName,
|
||||||
Description = string.Empty,
|
Description = string.Empty,
|
||||||
Valid = true
|
Valid = true,
|
||||||
|
Enabled = true
|
||||||
};
|
};
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,5 +28,28 @@ namespace Wox.Plugin.Program.Views.Commands
|
|||||||
.ToList()
|
.ToList()
|
||||||
.ForEach(t1 => ProgramSetting.ProgramSettingDisplayList.Add(new ProgramSource { Name = t1.DisplayName, Location = t1.Package.Location, Enabled = t1.Enabled }));
|
.ForEach(t1 => ProgramSetting.ProgramSettingDisplayList.Add(new ProgramSource { Name = t1.DisplayName, Location = t1.Package.Location, Enabled = t1.Enabled }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void DisableProgramSources(this List<ProgramSource> listToUpdate, List<ProgramSource> selectedprogramSourcesToDisable)
|
||||||
|
{
|
||||||
|
ProgramSetting.ProgramSettingDisplayList
|
||||||
|
.Where(t1 => selectedprogramSourcesToDisable.Any(x => x.Name == t1.Name && x.Location == t1.Location && t1.Enabled))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(t1 => t1.Enabled = false);
|
||||||
|
|
||||||
|
Main._win32s
|
||||||
|
.Where(t1 => selectedprogramSourcesToDisable.Any(x => x.Name == t1.Name && x.Location == t1.ParentDirectory && t1.Enabled))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(t1 => t1.Enabled = false);
|
||||||
|
|
||||||
|
Main._uwps
|
||||||
|
.Where(t1 => selectedprogramSourcesToDisable.Any(x => x.Name == t1.DisplayName && x.Location == t1.Package.Location && t1.Enabled))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(t1 => t1.Enabled = false);
|
||||||
|
|
||||||
|
Main._settings.ProgramSources
|
||||||
|
.Where(t1 => selectedprogramSourcesToDisable.Any(x => x.Name == t1.Name && x.Location == t1.Location && t1.Enabled))
|
||||||
|
.ToList()
|
||||||
|
.ForEach(t1 => t1.Enabled = false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs
Normal file
18
Plugins/Wox.Plugin.Program/Views/Models/ProgramSource.cs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Wox.Plugin.Program.Views.Models
|
||||||
|
{
|
||||||
|
public class ProgramSource
|
||||||
|
{
|
||||||
|
private string name;
|
||||||
|
|
||||||
|
public string Location { get; set; }
|
||||||
|
public string Name { get => name ?? new DirectoryInfo(Location).Name; set => name = value; }
|
||||||
|
public bool Enabled { get; set; } = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user