Added start on windows startup feature IO-404
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user