1
- using System ;
2
- using System . Collections . Generic ;
1
+ using System . Collections . Generic ;
3
2
using System . Linq ;
4
- using System . Text ;
5
- using System . Threading . Tasks ;
6
3
using Flow . Launcher . Plugin . Program . Views . Models ;
7
4
8
5
namespace Flow . Launcher . Plugin . Program . Views . Commands
@@ -20,43 +17,47 @@ internal static List<ProgramSource> LoadProgramSources()
20
17
21
18
internal static void DisplayAllPrograms ( )
22
19
{
23
- Main . _win32s
24
- . Where ( t1 => ! ProgramSetting . ProgramSettingDisplayList . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier ) )
25
- . ToList ( )
26
- . ForEach ( t1 => ProgramSetting . ProgramSettingDisplayList . Add ( new ProgramSource ( t1 ) ) ) ;
20
+ var win32 = Main . _win32s
21
+ . Where ( t1 => ! ProgramSetting . ProgramSettingDisplayList . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier ) )
22
+ . Select ( x => new ProgramSource ( x ) ) ;
27
23
28
- Main . _uwps
29
- . Where ( t1 => ! ProgramSetting . ProgramSettingDisplayList . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier ) )
30
- . ToList ( )
31
- . ForEach ( t1 => ProgramSetting . ProgramSettingDisplayList . Add ( new ProgramSource ( t1 ) ) ) ;
24
+ var uwp = Main . _uwps
25
+ . Where ( t1 => ! ProgramSetting . ProgramSettingDisplayList . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier ) )
26
+ . Select ( x => new ProgramSource ( x ) ) ;
27
+
28
+ ProgramSetting . ProgramSettingDisplayList . AddRange ( win32 ) ;
29
+ ProgramSetting . ProgramSettingDisplayList . AddRange ( uwp ) ;
32
30
}
33
31
34
32
internal static void SetProgramSourcesStatus ( List < ProgramSource > selectedProgramSourcesToDisable , bool status )
35
33
{
36
- ProgramSetting . ProgramSettingDisplayList
37
- . Where ( t1 => selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier && t1 . Enabled != status ) )
38
- . ToList ( )
39
- . ForEach ( t1 => t1 . Enabled = status ) ;
34
+ foreach ( var program in ProgramSetting . ProgramSettingDisplayList )
35
+ {
36
+ if ( selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == program . UniqueIdentifier && program . Enabled != status ) )
37
+ {
38
+ program . Enabled = status ;
39
+ }
40
+ }
40
41
41
- Main . _win32s
42
- . Where ( t1 => selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier && t1 . Enabled != status ) )
43
- . ToList ( )
44
- . ForEach ( t1 => t1 . Enabled = status ) ;
42
+ foreach ( var program in Main . _win32s )
43
+ {
44
+ if ( selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == program . UniqueIdentifier && program . Enabled != status ) )
45
+ {
46
+ program . Enabled = status ;
47
+ }
48
+ }
45
49
46
- Main . _uwps
47
- . Where ( t1 => selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == t1 . UniqueIdentifier && t1 . Enabled != status ) )
48
- . ToList ( )
49
- . ForEach ( t1 => t1 . Enabled = status ) ;
50
+ foreach ( var program in Main . _uwps )
51
+ {
52
+ if ( selectedProgramSourcesToDisable . Any ( x => x . UniqueIdentifier == program . UniqueIdentifier && program . Enabled != status ) )
53
+ {
54
+ program . Enabled = status ;
55
+ }
56
+ }
50
57
}
51
58
52
59
internal static void StoreDisabledInSettings ( )
53
60
{
54
- // no need since using refernce now
55
- //Main._settings.ProgramSources
56
- // .Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && !x.Enabled))
57
- // .ToList()
58
- // .ForEach(t1 => t1.Enabled = false);
59
-
60
61
// Disabled, not in DisabledProgramSources or ProgramSources
61
62
var tmp = ProgramSetting . ProgramSettingDisplayList
62
63
. Where ( t1 => ! t1 . Enabled
@@ -68,13 +69,7 @@ internal static void StoreDisabledInSettings()
68
69
69
70
internal static void RemoveDisabledFromSettings ( )
70
71
{
71
- //Main._settings.ProgramSources
72
- // .Where(t1 => ProgramSetting.ProgramSettingDisplayList.Any(x => x.UniqueIdentifier == t1.UniqueIdentifier && x.Enabled))
73
- // .ToList()
74
- // .ForEach(t1 => t1.Enabled = true);
75
-
76
- Main . _settings . DisabledProgramSources
77
- . RemoveAll ( t1 => t1 . Enabled ) ;
72
+ Main . _settings . DisabledProgramSources . RemoveAll ( t1 => t1 . Enabled ) ;
78
73
}
79
74
80
75
internal static bool IsReindexRequired ( this List < ProgramSource > selectedItems )
0 commit comments