mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-28 11:10:23 +12:00
Configure startup async
This commit is contained in:
parent
1967af93d9
commit
b7cb663a29
|
@ -336,6 +336,43 @@ private void CheckWindowsStoreStartup()
|
|||
});
|
||||
}
|
||||
|
||||
private void ConfigureWindowsStoreStartup()
|
||||
{
|
||||
if (cbStartWithWindows.Enabled)
|
||||
{
|
||||
cbStartWithWindows.Enabled = false;
|
||||
lblWindowsStoreStartupStatus.Text = "Configuring startup...";
|
||||
lblWindowsStoreStartupStatus.Visible = true;
|
||||
|
||||
bool enable = cbStartWithWindows.Checked;
|
||||
StartupTaskState state = StartupTaskState.Error;
|
||||
|
||||
TaskEx.Run(() =>
|
||||
{
|
||||
state = IntegrationHelpers.ConfigureStartupWindowsStore(enable);
|
||||
},
|
||||
() =>
|
||||
{
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (state == StartupTaskState.Error)
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Text = "Startup configuration failed. Check debug log for more info.";
|
||||
}
|
||||
else if (state == StartupTaskState.DisabledByUser)
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Text = "The startup has been disabled by the user.";
|
||||
}
|
||||
else
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Visible = false;
|
||||
cbStartWithWindows.Enabled = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#region General
|
||||
|
||||
private void cbShowTray_CheckedChanged(object sender, EventArgs e)
|
||||
|
@ -414,25 +451,7 @@ private void cbStartWithWindows_CheckedChanged(object sender, EventArgs e)
|
|||
if (ready)
|
||||
{
|
||||
#if WindowsStore
|
||||
if (cbStartWithWindows.Enabled)
|
||||
{
|
||||
StartupTaskState state = IntegrationHelpers.SetStartupWindowsStore(cbStartWithWindows.Checked);
|
||||
|
||||
if (state == StartupTaskState.Error)
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Text = "Startup configuration failed. Check debug log for more info.";
|
||||
lblWindowsStoreStartupStatus.Visible = true;
|
||||
}
|
||||
else if (state == StartupTaskState.DisabledByUser)
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Text = "The startup has been disabled by the user.";
|
||||
lblWindowsStoreStartupStatus.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblWindowsStoreStartupStatus.Visible = false;
|
||||
}
|
||||
}
|
||||
ConfigureWindowsStoreStartup();
|
||||
#else
|
||||
IntegrationHelpers.CreateStartupShortcut(cbStartWithWindows.Checked);
|
||||
#endif
|
||||
|
|
|
@ -170,7 +170,7 @@ public static StartupTaskState CheckStartupWindowsStore()
|
|||
return RunStartupWindowsStore("-StartupState", "Startup state check");
|
||||
}
|
||||
|
||||
public static StartupTaskState SetStartupWindowsStore(bool enable)
|
||||
public static StartupTaskState ConfigureStartupWindowsStore(bool enable)
|
||||
{
|
||||
return RunStartupWindowsStore(enable ? "-StartupEnable" : "-StartupDisable", "Startup configuration");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue