mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-02-23 19:49:43 +01:00
Add display of all loaded applications
This commit is contained in:
@@ -54,7 +54,7 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
Location = Directory.Text,
|
||||
};
|
||||
_settings.ProgramSources.Add(source);
|
||||
_settings.ProgramSources.Insert(0, source);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -137,6 +137,19 @@ namespace Wox.Plugin.Program
|
||||
Task.WaitAll(t1, t2);
|
||||
}
|
||||
|
||||
public static void AddLoadedApplicationsToSettings()
|
||||
{
|
||||
_win32s
|
||||
.Where(t1 => !_settings.ProgramSources.Any(x => x.Name == t1.Name))
|
||||
.ToList()
|
||||
.ForEach(t1 => _settings.ProgramSources.Add(new Settings.ProgramSource (){Name = t1.Name, Location = t1.ParentDirectory }));
|
||||
|
||||
_uwps
|
||||
.Where(t1 => !_settings.ProgramSources.Any(x => x.Name == t1.DisplayName))
|
||||
.ToList()
|
||||
.ForEach(t1 => _settings.ProgramSources.Add(new Settings.ProgramSource() { Name = t1.DisplayName, Location = t1.Package.Location }));
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return new ProgramSetting(_context, _settings);
|
||||
|
||||
@@ -25,6 +25,13 @@
|
||||
Drop="programSourceView_Drop" >
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Name" Width="150">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Name}"/>
|
||||
</DataTemplate>
|
||||
</GridViewColumn.CellTemplate>
|
||||
</GridViewColumn>
|
||||
<GridViewColumn Header="{DynamicResource wox_plugin_program_location}" Width="550">
|
||||
<GridViewColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
@@ -44,6 +51,7 @@
|
||||
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_delete}"/>
|
||||
<Button x:Name="btnEditProgramSource" Click="btnEditProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_edit}"/>
|
||||
<Button x:Name="btnAddProgramSource" Click="btnAddProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_add}"/>
|
||||
<Button x:Name="btnLoadAllProgramSource" Click="btnLoadAllProgramSource_OnClick" Width="100" Margin="10" Content="Load All"/>
|
||||
</StackPanel>
|
||||
</DockPanel>
|
||||
</Grid>
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace Wox.Plugin.Program
|
||||
{
|
||||
ReIndexing();
|
||||
}
|
||||
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
|
||||
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
@@ -142,5 +144,12 @@ namespace Wox.Plugin.Program
|
||||
_settings.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
|
||||
ReIndexing();
|
||||
}
|
||||
|
||||
private void btnLoadAllProgramSource_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Main.AddLoadedApplicationsToSettings();
|
||||
|
||||
programSourceView.Items.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,12 +207,12 @@ namespace Wox.Plugin.Program.Programs
|
||||
if(enableProgramSourceOnly)
|
||||
return applications
|
||||
.Where(t1 => applicationsToRetainPaths
|
||||
.Any(x => x.LocationFile == t1.Package.Location
|
||||
&& x.EnableIndexing))
|
||||
.Any(x => x.Location == t1.Package.Location
|
||||
&& x.Enabled))
|
||||
.Select(t1 => t1).ToArray();
|
||||
|
||||
// Do not return if the application is disabled for indexing
|
||||
return applications.Where(t1 => !applicationsToRetainPaths.Any(x => x.LocationFile == t1.Package.Location && !x.EnableIndexing))
|
||||
return applications.Where(t1 => !applicationsToRetainPaths.Any(x => x.Location == t1.Package.Location && !x.Enabled))
|
||||
.Select(t1 => t1).ToArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -263,15 +263,15 @@ namespace Wox.Plugin.Program.Programs
|
||||
private static ParallelQuery<Win32> UnregisteredPrograms(List<Settings.ProgramSource> sources, string[] suffixes)
|
||||
{
|
||||
var list = new List<string>();
|
||||
sources.Where(s => Directory.Exists(s.Location) && s.EnableIndexing)
|
||||
sources.Where(s => Directory.Exists(s.Location) && s.Enabled)
|
||||
.SelectMany(s => ProgramPaths(s.Location, suffixes))
|
||||
.ToList()
|
||||
.ForEach(x => list.Add(x));
|
||||
|
||||
sources.Where(x=> File.Exists(x.LocationFile) && x.EnableIndexing)
|
||||
.Select(y => y.LocationFile)
|
||||
sources.Where(s => File.Exists(s.Location) && s.Enabled)
|
||||
.Select(s => s.Location)
|
||||
.ToList()
|
||||
.ForEach(z => list.Add(z));
|
||||
.ForEach(x => list.Add(x));
|
||||
|
||||
var paths = list.ToArray();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Wox.Plugin.Program.Programs;
|
||||
|
||||
namespace Wox.Plugin.Program
|
||||
@@ -18,9 +19,11 @@ namespace Wox.Plugin.Program
|
||||
|
||||
public class ProgramSource
|
||||
{
|
||||
private string name;
|
||||
|
||||
public string Location { get; set; }
|
||||
public string LocationFile { get; set; }
|
||||
public bool EnableIndexing { get; set; } = true;
|
||||
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