diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
new file mode 100644
index 0000000000..4819a2f18d
--- /dev/null
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
new file mode 100644
index 0000000000..c93df57d13
--- /dev/null
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Wox.Plugin.Program
+{
+ ///
+ /// Interaction logic for AddProgramSource.xaml
+ ///
+ public partial class AddProgramSource
+ {
+ private ProgramSource _editing;
+
+ public AddProgramSource()
+ {
+ InitializeComponent();
+ }
+
+ public AddProgramSource(ProgramSource edit) : this()
+ {
+ this._editing = edit;
+ this.Directory.Text = this._editing.Location;
+ this.MaxDepth.Text = this._editing.MaxDepth.ToString();
+ this.Suffixes.Text = this._editing.Suffixes;
+ }
+
+ private void BrowseButton_Click(object sender, RoutedEventArgs e)
+ {
+ var dialog = new System.Windows.Forms.FolderBrowserDialog();
+ System.Windows.Forms.DialogResult result = dialog.ShowDialog();
+ if (result == System.Windows.Forms.DialogResult.OK)
+ {
+ this.Directory.Text = dialog.SelectedPath;
+ }
+ }
+
+ private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
+ {
+ int max;
+ if(!int.TryParse(this.MaxDepth.Text, out max))
+ {
+ max = -1;
+ }
+
+ if(this._editing == null)
+ {
+ ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
+ {
+ Location = this.Directory.Text,
+ MaxDepth = max,
+ Suffixes = this.Suffixes.Text,
+ Type = "FileSystemProgramSource",
+ Enabled = true
+ });
+ }
+ else
+ {
+ this._editing.Location = this.Directory.Text;
+ this._editing.MaxDepth = max;
+ this._editing.Suffixes = this.Suffixes.Text;
+ }
+
+ ProgramStorage.Instance.Save();
+ this.DialogResult = true;
+ this.Close();
+ }
+ }
+}
diff --git a/Plugins/Wox.Plugin.Program/Languages/en.xaml b/Plugins/Wox.Plugin.Program/Languages/en.xaml
index 84a3e064f4..07630a1cda 100644
--- a/Plugins/Wox.Plugin.Program/Languages/en.xaml
+++ b/Plugins/Wox.Plugin.Program/Languages/en.xaml
@@ -10,6 +10,15 @@
Index file suffixes
Reindex
Indexing
+ Index Start Menu
+ Index Registry
+ Suffixes
+ Max Depth
+
+ Directory:
+ Browse
+ File Suffixes:
+ Maximum Search Depth (-1 is unlimited):
Please select a program source
Are your sure to delete {0}?
diff --git a/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml
index 39e5f3b32a..ee397b26be 100644
--- a/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml
+++ b/Plugins/Wox.Plugin.Program/Languages/zh-cn.xaml
@@ -1,30 +1,38 @@
-
-
-
- 删除
- 编辑
- 增加
- 位置
- 索引文件后缀
- 重新索引
- 索引中
-
-
- 请先选择一项
- 你确定要删除{0}吗?
-
- 更新
- Wox仅索引下列后缀的文件:
- (每个后缀以英文状态下的分号分隔)
- 成功更新索引文件后缀
- 文件后缀不能为空
-
- 以管理员身份运行
- 打开所属文件夹
-
- 程序
- 在Wox中搜索程序
-
+
+
+
+ 删除
+ 编辑
+ 增加
+ 位置
+ 索引文件后缀
+ 重新索引
+ 索引中
+ 指数开始菜单
+ 指数注册
+ 后缀
+ 最大深度
+
+ 目录
+ 浏览
+ 文件后缀
+ 最大搜索深度(-1是无限的):
+
+ 请先选择一项
+ 你确定要删除{0}吗?
+
+ 更新
+ Wox仅索引下列后缀的文件:
+ (每个后缀以英文状态下的分号分隔)
+ 成功更新索引文件后缀
+ 文件后缀不能为空
+
+ 以管理员身份运行
+ 打开所属文件夹
+
+ 程序
+ 在Wox中搜索程序
+
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml b/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml
index 93cf54cb9f..e520458d84 100644
--- a/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml
+++ b/Plugins/Wox.Plugin.Program/Languages/zh-tw.xaml
@@ -1,29 +1,37 @@
-
-
-
- 刪除
- 編輯
- 增加
- 位置
- 索引文件後綴
- 重新索引
- 索引中
-
-
- 請先選擇一項
- 你確定要刪除{0}嗎?
-
- 更新
- Wox僅索引下列後綴的文件:
- (每個後綴以英文狀態下的分號分隔)
- 成功更新索引文件後綴
- 文件後綴不能為空
-
- 以管理員身份運行
- 打開所屬文件夾
-
- 程序
- 在Wox中搜索程序
+
+
+
+ 刪除
+ 編輯
+ 增加
+ 位置
+ 索引文件後綴
+ 重新索引
+ 索引中
+ 指数开始菜单
+ 指数注册
+ 后缀
+ 最大深度
+
+ 目录
+ 浏览
+ 文件后缀
+ 最大搜索深度(-1是无限的):
+
+ 請先選擇一項
+ 你確定要刪除{0}嗎?
+
+ 更新
+ Wox僅索引下列後綴的文件:
+ (每個後綴以英文狀態下的分號分隔)
+ 成功更新索引文件後綴
+ 文件後綴不能為空
+
+ 以管理員身份運行
+ 打開所屬文件夾
+
+ 程序
+ 在Wox中搜索程序
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
index 18b6b9f843..af8616cab3 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
@@ -12,7 +12,11 @@
-
+
+
+
+
+
@@ -21,13 +25,27 @@
Drop="programSourceView_Drop" >
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
index 3037997dfa..3d4b50a89b 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
@@ -22,6 +22,8 @@ namespace Wox.Plugin.Program
private void Setting_Loaded(object sender, RoutedEventArgs e)
{
programSourceView.ItemsSource = ProgramStorage.Instance.ProgramSources;
+ StartMenuEnabled.IsChecked = ProgramStorage.Instance.EnableStartMenuSource;
+ RegistryEnabled.IsChecked = ProgramStorage.Instance.EnableRegistrySource;
}
private void ReIndexing()
@@ -37,19 +39,10 @@ namespace Wox.Plugin.Program
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
{
- var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
- if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ var add = new AddProgramSource();
+ if(add.ShowDialog() ?? false)
{
- string path = folderBrowserDialog.SelectedPath;
-
- ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
- {
- Location = path,
- Type = "FileSystemProgramSource",
- Enabled = true
- });
- ProgramStorage.Instance.Save();
- ReIndexing();
+ this.ReIndexing();
}
}
@@ -79,14 +72,10 @@ namespace Wox.Plugin.Program
ProgramSource selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
if (selectedProgramSource != null)
{
- //todo: update
- var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog();
- if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
+ var add = new AddProgramSource(selectedProgramSource);
+ if (add.ShowDialog() ?? false)
{
- string path = folderBrowserDialog.SelectedPath;
- selectedProgramSource.Location = path;
- ProgramStorage.Instance.Save();
- ReIndexing();
+ this.ReIndexing();
}
}
else
@@ -142,5 +131,19 @@ namespace Wox.Plugin.Program
}
}
}
+
+ private void StartMenuEnabled_Click(object sender, RoutedEventArgs e)
+ {
+ ProgramStorage.Instance.EnableStartMenuSource = StartMenuEnabled.IsChecked ?? false;
+ ProgramStorage.Instance.Save();
+ ReIndexing();
+ }
+
+ private void RegistryEnabled_Click(object sender, RoutedEventArgs e)
+ {
+ ProgramStorage.Instance.EnableRegistrySource = RegistryEnabled.IsChecked ?? false;
+ ProgramStorage.Instance.Save();
+ ReIndexing();
+ }
}
}
\ No newline at end of file
diff --git a/Plugins/Wox.Plugin.Program/ProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSource.cs
index 99548b89e0..97a779d969 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSource.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSource.cs
@@ -10,6 +10,8 @@ namespace Wox.Plugin.Program
public string Type { get; set; }
public int BonusPoints { get; set; }
public bool Enabled { get; set; }
+ public string Suffixes { get; set; }
+ public int MaxDepth { get; set; }
public Dictionary Meta { get; set; }
public override string ToString()
diff --git a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs
index f4997615e8..b1ef2dcd4c 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSources/FileSystemProgramSource.cs
@@ -10,14 +10,21 @@ namespace Wox.Plugin.Program.ProgramSources
public class FileSystemProgramSource : AbstractProgramSource
{
private string baseDirectory;
+ private int maxDepth;
+ private string suffixes;
- public FileSystemProgramSource(string baseDirectory)
+ public FileSystemProgramSource(string baseDirectory, int maxDepth, string suffixes)
{
this.baseDirectory = baseDirectory;
+ this.maxDepth = maxDepth;
+ this.suffixes = suffixes;
}
+ public FileSystemProgramSource(string baseDirectory)
+ : this(baseDirectory, -1, "") {}
+
public FileSystemProgramSource(ProgramSource source)
- : this(source.Location)
+ : this(source.Location, source.MaxDepth, source.Suffixes)
{
this.BonusPoints = source.BonusPoints;
}
@@ -35,11 +42,21 @@ namespace Wox.Plugin.Program.ProgramSources
private void GetAppFromDirectory(string path, List list)
{
+ GetAppFromDirectory(path, list, 0);
+ }
+
+ private void GetAppFromDirectory(string path, List list, int depth)
+ {
+ if(maxDepth != -1 && depth > maxDepth)
+ {
+ return;
+ }
try
{
foreach (string file in Directory.GetFiles(path))
{
- if (ProgramStorage.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o)))
+ if (ProgramStorage.Instance.ProgramSuffixes.Split(';').Any(o => file.EndsWith("." + o)) ||
+ suffixes.Split(';').Any(o => file.EndsWith("." + o)))
{
Program p = CreateEntry(file);
list.Add(p);
@@ -48,7 +65,7 @@ namespace Wox.Plugin.Program.ProgramSources
foreach (var subDirectory in Directory.GetDirectories(path))
{
- GetAppFromDirectory(subDirectory, list);
+ GetAppFromDirectory(subDirectory, list, depth + 1);
}
}
catch (Exception e)
diff --git a/Plugins/Wox.Plugin.Program/ProgramStorage.cs b/Plugins/Wox.Plugin.Program/ProgramStorage.cs
index d6607c768c..a274237f87 100644
--- a/Plugins/Wox.Plugin.Program/ProgramStorage.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramStorage.cs
@@ -6,6 +6,7 @@ using System.Reflection;
using System.Text;
using Newtonsoft.Json;
using Wox.Infrastructure.Storage;
+using System.ComponentModel;
namespace Wox.Plugin.Program
{
@@ -17,6 +18,14 @@ namespace Wox.Plugin.Program
[JsonProperty]
public string ProgramSuffixes { get; set; }
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ [DefaultValue(true)]
+ public bool EnableStartMenuSource { get; set; }
+
+ [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)]
+ [DefaultValue(true)]
+ public bool EnableRegistrySource { get; set; }
+
protected override string ConfigFolder
{
get { return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
@@ -25,6 +34,8 @@ namespace Wox.Plugin.Program
protected override ProgramStorage LoadDefault()
{
ProgramSources = new List();
+ EnableStartMenuSource = true;
+ EnableRegistrySource = true;
return this;
}
diff --git a/Plugins/Wox.Plugin.Program/Programs.cs b/Plugins/Wox.Plugin.Program/Programs.cs
index fad46efa3f..d6a3a35183 100644
--- a/Plugins/Wox.Plugin.Program/Programs.cs
+++ b/Plugins/Wox.Plugin.Program/Programs.cs
@@ -28,6 +28,7 @@ namespace Wox.Plugin.Program
public List Query(Query query)
{
+
var fuzzyMather = FuzzyMatcher.Create(query.Search);
List returnList = programs.Where(o => MatchProgram(o, fuzzyMather)).ToList();
returnList.ForEach(ScoreFilter);
@@ -97,11 +98,11 @@ namespace Wox.Plugin.Program
if (ProgramStorage.Instance.ProgramSources != null &&
ProgramStorage.Instance.ProgramSources.Count(o => o.Enabled) > 0)
{
- programSources.AddRange(ProgramStorage.Instance.ProgramSources.Where(o => o.Enabled));
+ programSources.AddRange(ProgramStorage.Instance.ProgramSources);
}
sources.Clear();
- programSources.ForEach(source =>
+ foreach(var source in programSources.Where(o => o.Enabled))
{
Type sourceClass;
if (SourceTypes.TryGetValue(source.Type, out sourceClass))
@@ -114,7 +115,7 @@ namespace Wox.Plugin.Program
sources.Add(programSource);
}
}
- });
+ }
var tempPrograms = new List();
foreach (var source in sources)
@@ -145,19 +146,19 @@ namespace Wox.Plugin.Program
list.Add(new ProgramSource()
{
BonusPoints = 0,
- Enabled = true,
+ Enabled = ProgramStorage.Instance.EnableStartMenuSource,
Type = "CommonStartMenuProgramSource"
});
list.Add(new ProgramSource()
{
BonusPoints = 0,
- Enabled = true,
+ Enabled = ProgramStorage.Instance.EnableStartMenuSource,
Type = "UserStartMenuProgramSource"
});
list.Add(new ProgramSource()
{
BonusPoints = -10,
- Enabled = true,
+ Enabled = ProgramStorage.Instance.EnableRegistrySource,
Type = "AppPathsProgramSource"
});
return list;
diff --git a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj
index 0f357736f1..70e612ac2a 100644
--- a/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj
+++ b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj
@@ -1,153 +1,156 @@
-
-
-
-
- Debug
- AnyCPU
- {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
- Library
- Properties
- Wox.Plugin.Program
- Wox.Plugin.Program
- v3.5
- 512
- ..\..\
- true
-
-
-
- true
- full
- false
- ..\..\Output\Debug\Plugins\Wox.Plugin.Program\
- DEBUG;TRACE
- prompt
- 4
- false
-
-
- pdbonly
- true
- ..\..\Output\Release\Plugins\Wox.Plugin.Program\
- TRACE
- prompt
- 4
- false
-
-
-
- False
- ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ProgramSetting.xaml
-
-
-
-
-
-
-
-
- ProgramSuffixes.xaml
-
-
-
-
-
-
-
- PreserveNewest
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- MSBuild:Compile
- Designer
- PreserveNewest
-
-
-
-
- MSBuild:Compile
- Designer
- PreserveNewest
-
-
- MSBuild:Compile
- Designer
- PreserveNewest
-
-
- MSBuild:Compile
- Designer
-
-
- MSBuild:Compile
- Designer
-
-
-
-
- {4fd29318-a8ab-4d8f-aa47-60bc241b8da3}
- Wox.Infrastructure
-
-
- {8451ecdd-2ea4-4966-bb0a-7bbc40138e80}
- Wox.Plugin
-
-
-
-
- {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}
- 1
- 0
- 0
- tlbimp
- False
- True
-
-
-
-
-
-
- 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
-
-
-
+
+
+
+
+ Debug
+ AnyCPU
+ {FDB3555B-58EF-4AE6-B5F1-904719637AB4}
+ Library
+ Properties
+ Wox.Plugin.Program
+ Wox.Plugin.Program
+ v3.5
+ 512
+ ..\..\
+ true
+
+
+
+ true
+ full
+ false
+ ..\..\Output\Debug\Plugins\Wox.Plugin.Program\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ pdbonly
+ true
+ ..\..\Output\Release\Plugins\Wox.Plugin.Program\
+ TRACE
+ prompt
+ 4
+ false
+
+
+
+ False
+ ..\..\packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ AddProgramSource.xaml
+
+
+
+
+
+
+
+ ProgramSetting.xaml
+
+
+
+
+
+
+
+
+ ProgramSuffixes.xaml
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ MSBuild:Compile
+ Designer
+ PreserveNewest
+
+
+
+
+ MSBuild:Compile
+ Designer
+ PreserveNewest
+
+
+ MSBuild:Compile
+ Designer
+ PreserveNewest
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ {4fd29318-a8ab-4d8f-aa47-60bc241b8da3}
+ Wox.Infrastructure
+
+
+ {8451ecdd-2ea4-4966-bb0a-7bbc40138e80}
+ Wox.Plugin
+
+
+
+
+ {F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}
+ 1
+ 0
+ 0
+ tlbimp
+ False
+ True
+
+
+
+
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。启用“NuGet 程序包还原”可下载这些程序包。有关详细信息,请参阅 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+ -->
\ No newline at end of file