Added start on windows startup feature IO-404

This commit is contained in:
Patrick Fic
2021-01-18 11:49:55 -08:00
parent 34a5ae2292
commit 1b4e5fb3f0
9 changed files with 72 additions and 2 deletions

View File

@@ -192,7 +192,23 @@ namespace BodyshopPartner.ViewModels
}
}
private ICommand _startWithWindowsCommand;
public ICommand StartWithWindowsCommand
{
get
{
if (_startWithWindowsCommand == null)
{
_startWithWindowsCommand = new RelayCommand(
p => true,
p =>
{
ToggleStartWithWindows((bool)(p));
});
}
return _startWithWindowsCommand;
}
}
}
}

View File

@@ -198,7 +198,24 @@ namespace BodyshopPartner.ViewModels
App.Current.Shutdown();
}
public async Task LoadBodyshopData()
public void ToggleStartWithWindows(bool shouldStart)
{
RegistryKey rkApp = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
if (shouldStart)
{
// Add the value in the registry so that the application runs at startup
rkApp.SetValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, System.Reflection.Assembly.GetEntryAssembly().Location);
}
else
{
// Remove the value from the registry so that the application doesn't start
rkApp.DeleteValue(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name, false);
}
}
public async Task LoadBodyshopData()
{
var r = new GraphQLRequest
{