diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
new file mode 100644
index 0000000000..29d59a669c
--- /dev/null
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
new file mode 100644
index 0000000000..5ff72b6ea5
--- /dev/null
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
@@ -0,0 +1,60 @@
+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 : Window
+ {
+ private Action reindex;
+
+ public AddProgramSource(Action reindex)
+ {
+ this.reindex = reindex;
+ InitializeComponent();
+ }
+
+ 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;
+ }
+ ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
+ {
+ Location = this.Directory.Text,
+ MaxDepth = max,
+ Suffixes = this.Suffixes.Text,
+ Type = "FileSystemProgramSource",
+ Enabled = true
+ });
+ ProgramStorage.Instance.Save();
+ reindex();
+ this.Close();
+ }
+ }
+}
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
index 18b6b9f843..7004ccb873 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml
@@ -21,13 +21,27 @@
Drop="programSourceView_Drop" >
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
index 3037997dfa..f07126dfbf 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
@@ -37,20 +37,8 @@ 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)
- {
- string path = folderBrowserDialog.SelectedPath;
-
- ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
- {
- Location = path,
- Type = "FileSystemProgramSource",
- Enabled = true
- });
- ProgramStorage.Instance.Save();
- ReIndexing();
- }
+ var add = new AddProgramSource(this.ReIndexing);
+ add.Show();
}
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
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/Wox.Plugin.Program.csproj b/Plugins/Wox.Plugin.Program/Wox.Plugin.Program.csproj
index 0f357736f1..87a41e0656 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