diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
index 9230eb062..39d5f8a4e 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml
@@ -5,12 +5,12 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{DynamicResource flowlauncher_plugin_program_directory}"
- Width="400"
+ Width="530"
Background="{DynamicResource PopuBGColor}"
Foreground="{DynamicResource PopupTextColor}"
+ ResizeMode="NoResize"
SizeToContent="Height"
- WindowStartupLocation="CenterScreen"
- mc:Ignorable="d">
+ WindowStartupLocation="CenterScreen">
@@ -19,7 +19,6 @@
-
@@ -53,33 +52,78 @@
-
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -87,19 +131,17 @@
-
-
-
+
\ No newline at end of file
diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
index f41fd484b..a0e3754e8 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
@@ -9,11 +9,12 @@ namespace Flow.Launcher.Plugin.Program
///
/// Interaction logic for AddProgramSource.xaml
///
- public partial class AddProgramSource
+ public partial class AddProgramSource : Window
{
private PluginInitContext _context;
private ProgramSource _editing;
private Settings _settings;
+ private bool update;
public AddProgramSource(PluginInitContext context, Settings settings)
{
@@ -21,15 +22,19 @@ namespace Flow.Launcher.Plugin.Program
_context = context;
_settings = settings;
Directory.Focus();
+ Chkbox.IsChecked = true;
+ update = false;
+ btnAdd.Content = _context.API.GetTranslation("flowlauncher_plugin_program_add");
}
public AddProgramSource(ProgramSource edit, Settings settings)
{
- _editing = edit;
- _settings = settings;
-
InitializeComponent();
- Directory.Text = _editing.Location;
+ _updating = source;
+ _settings = settings;
+ update = true;
+ Chkbox.IsChecked = _updating.Enabled;
+ Directory.Text = _updating.Location;
}
private void BrowseButton_Click(object sender, RoutedEventArgs e)
@@ -47,19 +52,19 @@ namespace Flow.Launcher.Plugin.Program
Close();
}
- private void ButtonAdd_OnClick(object sender, RoutedEventArgs e)
+ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
{
- string s = Directory.Text;
- if (!System.IO.Directory.Exists(s))
+ string path = Directory.Text;
+ if (!System.IO.Directory.Exists(path))
{
System.Windows.MessageBox.Show(_context.API.GetTranslation("flowlauncher_plugin_program_invalid_path"));
return;
}
- if (_editing == null)
+ if (!update)
{
- if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(Directory.Text, System.StringComparison.InvariantCultureIgnoreCase)))
+ if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier.Equals(path, System.StringComparison.InvariantCultureIgnoreCase)))
{
- var source = new ProgramSource(Directory.Text);
+ var source = new ProgramSource(path);
_settings.ProgramSources.Insert(0, source);
ProgramSetting.ProgramSettingDisplayList.Add(source);
@@ -67,7 +72,8 @@ namespace Flow.Launcher.Plugin.Program
}
else
{
- _editing.Location = Directory.Text;
+ _updating.Location = path;
+ _updating.Enabled = Chkbox.IsChecked ?? true; // Fixme, need to add to disabled source if not custom source
}
DialogResult = true;
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
index 8d8cae02c..74315be7e 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/Languages/en.xaml
@@ -9,6 +9,7 @@
Add
Name
Enable
+ Enabled
Disable
Location
All Programs
@@ -34,7 +35,10 @@
Please select a program source
Are you sure you want to delete the selected program sources?
- OK
+ Program Source
+ Edit directory and status of this program source.
+
+ Update
Flow Launcher will only index files that end with the following suffixes. (Each suffix should split by ';' )
Successfully updated file suffixes
File suffixes can't be empty
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Main.cs b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
index 9a4e8e5a3..61efbb923 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Main.cs
@@ -191,12 +191,17 @@ namespace Flow.Launcher.Plugin.Program
return;
if (_uwps.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ {
_uwps.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
- .Enabled = false;
+ .Enabled = false;
+
+ }
- if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ if (_win32s.Any(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier))
+ {
_win32s.First(x => x.UniqueIdentifier == programToDelete.UniqueIdentifier)
.Enabled = false;
+ }
_settings.DisabledProgramSources.Add(new DisabledProgramSource(programToDelete));
}
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
index f07879465..171f6081b 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
+++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml
@@ -116,6 +116,8 @@
Drop="programSourceView_Drop"
GridViewColumnHeader.Click="GridViewColumnHeaderClickedHandler"
PreviewMouseRightButtonUp="ProgramSourceView_PreviewMouseRightButtonUp"
+ MouseDoubleClick="programSourceView_MouseDoubleClick"
+ SelectionChanged="programSourceView_SelectionChanged"
SelectionMode="Extended">
@@ -126,7 +128,7 @@
-
+
_settings.HideAppsPath;
@@ -232,18 +233,14 @@ namespace Flow.Launcher.Plugin.Program.Views
.SelectedItems.Cast()
.ToList();
- if (selectedItems.Count() == 0)
+ if (selectedItems.Count == 0)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBox.Show(msg);
return;
}
- if (selectedItems
- .Where(t1 => !_settings
- .ProgramSources
- .Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
- .Count() == 0)
+ if (IsAllItemsUserAdded(selectedItems))
{
var msg = string.Format(context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"));
@@ -254,7 +251,7 @@ namespace Flow.Launcher.Plugin.Program.Views
DeleteProgramSources(selectedItems);
}
- else if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
+ else if (HasMoreOrEqualEnabledItems(selectedItems))
{
ProgramSettingDisplay.SetProgramSourcesStatus(selectedItems, false);
@@ -326,35 +323,47 @@ namespace Flow.Launcher.Plugin.Program.Views
dataView.Refresh();
}
- private bool IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(List selectedItems)
+ private static bool HasMoreOrEqualEnabledItems(List items)
{
- return selectedItems.Where(x => x.Enabled).Count() >= selectedItems.Where(x => !x.Enabled).Count();
+ return items.Where(x => x.Enabled).Count() >= items.Count / 2;
}
- private void Row_OnClick(object sender, RoutedEventArgs e)
+ private void programSourceView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var selectedItems = programSourceView
.SelectedItems.Cast()
.ToList();
- if (selectedItems
- .Where(t1 => !_settings
- .ProgramSources
- .Any(x => t1.UniqueIdentifier == x.UniqueIdentifier))
- .Count() == 0)
+ if (IsAllItemsUserAdded(selectedItems))
{
btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_delete");
- return;
}
-
- if (IsSelectedRowStatusEnabledMoreOrEqualThanDisabled(selectedItems))
+ else if (HasMoreOrEqualEnabledItems(selectedItems))
{
- btnProgramSourceStatus.Content = "Disable";
+ btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_disable");
}
else
{
- btnProgramSourceStatus.Content = "Enable";
+ btnProgramSourceStatus.Content = context.API.GetTranslation("flowlauncher_plugin_program_enable");
}
}
+
+ private void programSourceView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
+ {
+ var selectedProgramSource = programSourceView.SelectedItem as ProgramSource;
+ if (selectedProgramSource != null)
+ {
+ var add = new AddProgramSource(selectedProgramSource, _settings);
+ if (add.ShowDialog() ?? false)
+ {
+ ReIndexing();
+ }
+ }
+ }
+
+ private bool IsAllItemsUserAdded(List items)
+ {
+ return items.All(x => _settings.ProgramSources.Any(y => y.UniqueIdentifier == x.UniqueIdentifier));
+ }
}
}