Skip to content

Commit 9630516

Browse files
committed
Improve function names for code quality
1 parent 2a445e3 commit 9630516

File tree

3 files changed

+55
-11
lines changed

3 files changed

+55
-11
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ private void AutoStartup()
119119
{
120120
try
121121
{
122-
Helper.AutoStartup.Enable(_settings.UseLogonTaskForStartup);
122+
if (_settings.UseLogonTaskForStartup)
123+
{
124+
Helper.AutoStartup.EnableViaLogonTask();
125+
}
126+
else
127+
{
128+
Helper.AutoStartup.EnableViaRegistry();
129+
}
123130
}
124131
catch (Exception e)
125132
{

Flow.Launcher/Helper/AutoStartup.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,35 @@ private static bool CheckLogonTask()
6868
return false;
6969
}
7070

71-
public static void Disable(bool logonTask)
71+
public static void DisableViaLogonTaskAndRegistry()
72+
{
73+
Disable(true);
74+
Disable(false);
75+
}
76+
77+
public static void EnableViaLogonTask()
78+
{
79+
Enable(true);
80+
}
81+
82+
public static void EnableViaRegistry()
83+
{
84+
Enable(false);
85+
}
86+
87+
public static void ChangeToViaLogonTask()
88+
{
89+
Disable(false);
90+
Enable(true);
91+
}
92+
93+
public static void ChangeToViaRegistry()
94+
{
95+
Disable(true);
96+
Enable(false);
97+
}
98+
99+
private static void Disable(bool logonTask)
72100
{
73101
try
74102
{
@@ -89,7 +117,7 @@ public static void Disable(bool logonTask)
89117
}
90118
}
91119

92-
internal static void Enable(bool logonTask)
120+
private static void Enable(bool logonTask)
93121
{
94122
try
95123
{

Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ public bool StartFlowLauncherOnSystemStartup
4343
{
4444
if (value)
4545
{
46-
// Enable either registry or task scheduler
47-
AutoStartup.Enable(UseLogonTaskForStartup);
46+
if (UseLogonTaskForStartup)
47+
{
48+
AutoStartup.EnableViaLogonTask();
49+
}
50+
else
51+
{
52+
AutoStartup.EnableViaRegistry();
53+
}
4854
}
4955
else
5056
{
51-
// Disable both registry and task scheduler
52-
AutoStartup.Disable(true);
53-
AutoStartup.Disable(false);
57+
AutoStartup.DisableViaLogonTaskAndRegistry();
5458
}
5559
}
5660
catch (Exception e)
@@ -72,9 +76,14 @@ public bool UseLogonTaskForStartup
7276
{
7377
try
7478
{
75-
// Disable and enable to update the startup method
76-
AutoStartup.Disable(!UseLogonTaskForStartup);
77-
AutoStartup.Enable(UseLogonTaskForStartup);
79+
if (UseLogonTaskForStartup)
80+
{
81+
AutoStartup.ChangeToViaLogonTask();
82+
}
83+
else
84+
{
85+
AutoStartup.ChangeToViaRegistry();
86+
}
7887
}
7988
catch (Exception e)
8089
{

0 commit comments

Comments
 (0)