This commit is contained in:
bao-qian 2016-08-19 23:24:21 +01:00
parent 69c00d272b
commit 9e033d1673
16 changed files with 99 additions and 53 deletions

View File

@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Windows;
using System.Windows;
using System.Windows.Forms;
using Wox.Plugin.Program.ProgramSources;
@ -10,7 +9,7 @@ namespace Wox.Plugin.Program
/// </summary>
public partial class AddProgramSource
{
private FileSystemProgramSource _editing;
private UnregisteredPrograms _editing;
private Settings _settings;
public AddProgramSource(Settings settings)
@ -20,7 +19,7 @@ namespace Wox.Plugin.Program
Directory.Focus();
}
public AddProgramSource(FileSystemProgramSource edit, Settings settings)
public AddProgramSource(UnregisteredPrograms edit, Settings settings)
{
_editing = edit;
_settings = settings;
@ -50,10 +49,10 @@ namespace Wox.Plugin.Program
if(_editing == null)
{
var source = new FileSystemProgramSource
var source = new UnregisteredPrograms
{
Location = Directory.Text,
MaxDepth = max,
MaxDepth = max
};
_settings.ProgramSources.Add(source);
}

View File

@ -10,7 +10,7 @@ namespace Wox.Plugin.Program
{
private static readonly List<string> WatchedPath = new List<string>();
// todo remove previous watcher events
public static void AddAll(List<FileSystemProgramSource> sources, string[] suffixes)
public static void AddAll(List<UnregisteredPrograms> sources, string[] suffixes)
{
foreach (var s in sources)
{

View File

@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Controls;
using Wox.Infrastructure;
@ -162,7 +161,7 @@ namespace Wox.Plugin.Program
}
if (_settings.EnableRegistrySource)
{
var source3 = new AppPathsProgramSource();
var source3 = new AppPathsPrograms();
sources.Add(source3);
}

View File

@ -1,8 +1,4 @@
using System;
using System.Text.RegularExpressions;
using System.Threading;
using Wox.Infrastructure;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program
{

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using Wox.Infrastructure.Storage;
namespace Wox.Plugin.Program
{

View File

@ -14,11 +14,11 @@
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" HorizontalAlignment="Stretch">
<StackPanel Orientation="Vertical" Width="310">
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}"></CheckBox>
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}"></CheckBox>
<CheckBox Name="StartMenuEnabled" Click="StartMenuEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_start}" />
<CheckBox Name="RegistryEnabled" Click="RegistryEnabled_Click" Margin="5" Content="{DynamicResource wox_plugin_program_index_registry}" />
</StackPanel>
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}"></Button>
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}"></Button>
<Button Height="30" HorizontalAlignment="Right" x:Name="btnProgramSuffixes" Width="130" Click="BtnProgramSuffixes_OnClick" Content="{DynamicResource wox_plugin_program_suffixes}" />
<Button Height="30" HorizontalAlignment="Right" Margin="10 0 0 0" x:Name="btnReindex" Width="100" Click="btnReindex_Click" Content="{DynamicResource wox_plugin_program_reindex}" />
</StackPanel>
<ListView x:Name="programSourceView" Grid.Row="1" AllowDrop="True"
DragEnter="programSourceView_DragEnter"
@ -44,8 +44,8 @@
</ListView>
<DockPanel Grid.Row="2">
<StackPanel x:Name="indexingPanel" Visibility="Hidden" HorizontalAlignment="Left" Orientation="Horizontal">
<ProgressBar x:Name="progressBarIndexing" Height="20" Width="80" Minimum="0" Maximum="100" IsIndeterminate="True"></ProgressBar>
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource wox_plugin_program_indexing}"></TextBlock>
<ProgressBar x:Name="progressBarIndexing" Height="20" Width="80" Minimum="0" Maximum="100" IsIndeterminate="True" />
<TextBlock Margin="10 0 0 0" Height="20" HorizontalAlignment="Center" Text="{DynamicResource wox_plugin_program_indexing}" />
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
<Button x:Name="btnDeleteProgramSource" Click="btnDeleteProgramSource_OnClick" Width="100" Margin="10" Content="{DynamicResource wox_plugin_program_delete}"/>
@ -55,3 +55,66 @@
</DockPanel>
</Grid>
</UserControl>

View File

@ -51,7 +51,7 @@ namespace Wox.Plugin.Program
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
{
var selectedProgramSource = programSourceView.SelectedItem as FileSystemProgramSource;
var selectedProgramSource = programSourceView.SelectedItem as UnregisteredPrograms;
if (selectedProgramSource != null)
{
string msg = string.Format(context.API.GetTranslation("wox_plugin_program_delete_program_source"), selectedProgramSource.Location);
@ -71,7 +71,7 @@ namespace Wox.Plugin.Program
private void btnEditProgramSource_OnClick(object sender, RoutedEventArgs e)
{
var selectedProgramSource = programSourceView.SelectedItem as FileSystemProgramSource;
var selectedProgramSource = programSourceView.SelectedItem as UnregisteredPrograms;
if (selectedProgramSource != null)
{
var add = new AddProgramSource(selectedProgramSource, _settings);
@ -120,9 +120,9 @@ namespace Wox.Plugin.Program
{
if (Directory.Exists(s))
{
_settings.ProgramSources.Add(new FileSystemProgramSource
_settings.ProgramSources.Add(new UnregisteredPrograms
{
Location = s,
Location = s
});
ReIndexing();

View File

@ -7,7 +7,7 @@ using Microsoft.Win32;
namespace Wox.Plugin.Program.ProgramSources
{
[Serializable]
public class AppPathsProgramSource : Win32
public class AppPathsPrograms : Win32
{
public override List<Program> LoadPrograms()
{

View File

@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;
namespace Wox.Plugin.Program.ProgramSources
{
[Serializable]
public class FileSystemProgramSource : Win32
public class UnregisteredPrograms : Win32
{
public string Location { get; set; } = "";

View File

@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
namespace Wox.Plugin.Program.ProgramSources
{

View File

@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Wox.Plugin.Program.ProgramSources
{

View File

@ -5,18 +5,18 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Principal;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Windows.ApplicationModel;
using Windows.Management.Deployment;
using Windows.ApplicationModel.Core;
using Windows.Foundation;
using Windows.Management.Deployment;
using Windows.Storage.Streams;
using AppxPackaing;
using Shell;
using Wox.Infrastructure.Logger;
using IStream = AppxPackaing.IStream;
using Size = Windows.Foundation.Size;
using Rect = System.Windows.Rect;
namespace Wox.Plugin.Program.ProgramSources
{
@ -26,14 +26,12 @@ namespace Wox.Plugin.Program.ProgramSources
public string FullName { get; }
public string FamilyName { get; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string PublisherDisplayName { get; set; }
public string Location { get; set; }
public Application[] Apps { get; set; }
public Package Package { get; }
public int Score { get; set; }
@ -96,7 +94,6 @@ namespace Wox.Plugin.Program.ProgramSources
}
}
private void InitializeAppDisplayInfo(Package package)
{
IReadOnlyList<AppListEntry> apps;
@ -328,12 +325,12 @@ namespace Wox.Plugin.Program.ProgramSources
private enum Stgm : uint
{
Read = 0x0,
ShareExclusive = 0x10,
ShareExclusive = 0x10
}
private enum Hresult : uint
{
Ok = 0x0000,
Ok = 0x0000
}
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]

View File

@ -3,8 +3,6 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wox.Infrastructure.Exception;
using Wox.Infrastructure.Logger;

View File

@ -9,9 +9,16 @@
WindowStartupLocation="CenterScreen"
d:DesignHeight="400" d:DesignWidth="300">
<StackPanel>
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_only_index_tip}"></TextBlock>
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_split_by_tip}"></TextBlock>
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_only_index_tip}" />
<TextBlock Margin="10 10 0 0" Foreground="Gray" Text="{DynamicResource wox_plugin_program_split_by_tip}" />
<TextBox x:Name="tbSuffixes" Margin="10"/>
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="10" Content="{DynamicResource wox_plugin_program_update}"></Button>
<Button HorizontalAlignment="Right" Height="30" Width="80" Click="ButtonBase_OnClick" Margin="10" Content="{DynamicResource wox_plugin_program_update}" />
</StackPanel>
</Window>

View File

@ -1,6 +1,4 @@
using System.Windows;
using System.Linq;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program
{

View File

@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using Wox.Plugin.Program.ProgramSources;
namespace Wox.Plugin.Program
{
public class Settings
{
public List<FileSystemProgramSource> ProgramSources { get; set; } = new List<FileSystemProgramSource>();
public List<UnregisteredPrograms> ProgramSources { get; set; } = new List<UnregisteredPrograms>();
public string[] ProgramSuffixes { get; set; } = {"bat", "appref-ms", "exe", "lnk"};
public bool EnableStartMenuSource { get; set; } = true;