diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
index 29d59a669c..85e58e916b 100644
--- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml
@@ -8,28 +8,20 @@
Height="180"
WindowStartupLocation="CenterScreen"
d:DesignHeight="400" d:DesignWidth="300">
-
-
-
-
-
-
-
-
+
+
-
+
-
+
-
-
-
-
+
+
diff --git a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
index 96db90a613..c93df57d13 100644
--- a/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
+++ b/Plugins/Wox.Plugin.Program/AddProgramSource.xaml.cs
@@ -19,14 +19,21 @@ namespace Wox.Plugin.Program
///
public partial class AddProgramSource
{
- private Action reindex;
+ private ProgramSource _editing;
- public AddProgramSource(Action reindex)
+ public AddProgramSource()
{
- this.reindex = reindex;
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();
@@ -44,16 +51,27 @@ namespace Wox.Plugin.Program
{
max = -1;
}
- ProgramStorage.Instance.ProgramSources.Add(new ProgramSource()
+
+ if(this._editing == null)
{
- Location = this.Directory.Text,
- MaxDepth = max,
- Suffixes = this.Suffixes.Text,
- Type = "FileSystemProgramSource",
- Enabled = true
- });
+ 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();
- reindex();
+ this.DialogResult = true;
this.Close();
}
}
diff --git a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
index 3558c85146..3d4b50a89b 100644
--- a/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
+++ b/Plugins/Wox.Plugin.Program/ProgramSetting.xaml.cs
@@ -39,8 +39,11 @@ namespace Wox.Plugin.Program
private void btnAddProgramSource_OnClick(object sender, RoutedEventArgs e)
{
- var add = new AddProgramSource(this.ReIndexing);
- add.Show();
+ var add = new AddProgramSource();
+ if(add.ShowDialog() ?? false)
+ {
+ this.ReIndexing();
+ }
}
private void btnDeleteProgramSource_OnClick(object sender, RoutedEventArgs e)
@@ -69,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