diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs index 25bc3d670..4276023e6 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs @@ -59,11 +59,7 @@ namespace Flow.Launcher.Plugin.Program { if (!ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == Directory.Text)) { - var source = new ProgramSource - { - Location = Directory.Text, - UniqueIdentifier = Directory.Text - }; + var source = new ProgramSource(Directory.Text); _settings.ProgramSources.Insert(0, source); ProgramSetting.ProgramSettingDisplayList.Add(source); diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Commands/ProgramSettingDisplay.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Commands/ProgramSettingDisplay.cs index 5e2a288f7..06e72176d 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Commands/ProgramSettingDisplay.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Commands/ProgramSettingDisplay.cs @@ -13,16 +13,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands { var list = new List(); - programSources.ForEach(x => list - .Add( - new ProgramSource - { - Enabled = x.Enabled, - Location = x.Location, - Name = x.Name, - UniqueIdentifier = x.UniqueIdentifier - } - )); + programSources.ForEach(x => list.Add(new ProgramSource(x))); // Even though these are disabled, we still want to display them so users can enable later on Main._settings @@ -32,16 +23,7 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands .Any(x => t1.UniqueIdentifier == x.UniqueIdentifier)) .Select(x => x) .ToList() - .ForEach(x => list - .Add( - new ProgramSource - { - Enabled = x.Enabled, - Location = x.Location, - Name = x.Name, - UniqueIdentifier = x.UniqueIdentifier - } - )); + .ForEach(x => list.Add(new ProgramSource(x))); return list; } @@ -51,30 +33,12 @@ namespace Flow.Launcher.Plugin.Program.Views.Commands Main._win32s .Where(t1 => !ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier)) .ToList() - .ForEach(t1 => ProgramSetting.ProgramSettingDisplayList - .Add( - new ProgramSource - { - Name = t1.Name, - Location = t1.ParentDirectory, - UniqueIdentifier = t1.UniqueIdentifier, - Enabled = t1.Enabled - } - )); + .ForEach(t1 => ProgramSetting.ProgramSettingDisplayList.Add(new ProgramSource(t1))); Main._uwps .Where(t1 => !ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier)) .ToList() - .ForEach(t1 => ProgramSetting.ProgramSettingDisplayList - .Add( - new ProgramSource - { - Name = t1.DisplayName, - Location = t1.Package.Location, - UniqueIdentifier = t1.UniqueIdentifier, - Enabled = t1.Enabled - } - )); + .ForEach(t1 => ProgramSetting.ProgramSettingDisplayList.Add(new ProgramSource(t1))); } internal static void SetProgramSourcesStatus(this List list, List selectedProgramSourcesToDisable, bool status) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs index f562d992b..7d7ca8902 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/Models/ProgramSource.cs @@ -26,16 +26,14 @@ namespace Flow.Launcher.Plugin.Program.Views.Models /// public string UniqueIdentifier { get => uid; set => uid = value.ToLowerInvariant(); } - public ProgramSource() - { - } // TODO Remove + //public ProgramSource() {} /// /// Custom user added source. /// /// /// - public ProgramSource(string location, bool enabled) + public ProgramSource(string location, bool enabled=true) { Location = location; Enabled = enabled; diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs index 0c4892abc..364977b71 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs @@ -199,13 +199,9 @@ namespace Flow.Launcher.Plugin.Program.Views { foreach (string directory in directories) { - if (Directory.Exists(directory) && !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == directory)) + if (Directory.Exists(directory) && !ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == directory.ToLowerInvariant())) { - var source = new ProgramSource - { - Location = directory, - UniqueIdentifier = directory - }; + var source = new ProgramSource(directory); directoriesToAdd.Add(source); }