diff --git a/BodyshopUploader/App.config b/BodyshopUploader/App.config index 5434933..f0467ee 100644 --- a/BodyshopUploader/App.config +++ b/BodyshopUploader/App.config @@ -63,6 +63,9 @@ + + True + diff --git a/BodyshopUploader/App.xaml.cs b/BodyshopUploader/App.xaml.cs index d72d1cd..74ebe40 100644 --- a/BodyshopUploader/App.xaml.cs +++ b/BodyshopUploader/App.xaml.cs @@ -21,6 +21,7 @@ namespace BodyshopPartner private void Application_Exit(object sender, ExitEventArgs e) { + BodyshopPartner.Properties.Settings.Default.Save(); Utils.QuickBooksInterop.DisconnectFromQuickBooks(); } } diff --git a/BodyshopUploader/Properties/Resources.Designer.cs b/BodyshopUploader/Properties/Resources.Designer.cs index dc5d3dc..89def06 100644 --- a/BodyshopUploader/Properties/Resources.Designer.cs +++ b/BodyshopUploader/Properties/Resources.Designer.cs @@ -240,6 +240,15 @@ namespace BodyshopPartner.Properties { } } + /// + /// Looks up a localized string similar to Start with Windows. + /// + public static string Label_StartWithWindows { + get { + return ResourceManager.GetString("Label_StartWithWindows", resourceCulture); + } + } + /// /// Looks up a localized string similar to Status. /// diff --git a/BodyshopUploader/Properties/Resources.resx b/BodyshopUploader/Properties/Resources.resx index 080817d..819ee27 100644 --- a/BodyshopUploader/Properties/Resources.resx +++ b/BodyshopUploader/Properties/Resources.resx @@ -177,6 +177,9 @@ Start _All Monitors + + Start with Windows + Status diff --git a/BodyshopUploader/Properties/Settings.Designer.cs b/BodyshopUploader/Properties/Settings.Designer.cs index 33d57f1..33140e5 100644 --- a/BodyshopUploader/Properties/Settings.Designer.cs +++ b/BodyshopUploader/Properties/Settings.Designer.cs @@ -128,5 +128,17 @@ namespace BodyshopPartner.Properties { this["RefreshToken"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool StartWithWindows { + get { + return ((bool)(this["StartWithWindows"])); + } + set { + this["StartWithWindows"] = value; + } + } } } diff --git a/BodyshopUploader/Properties/Settings.settings b/BodyshopUploader/Properties/Settings.settings index 5913e1a..1f99d4b 100644 --- a/BodyshopUploader/Properties/Settings.settings +++ b/BodyshopUploader/Properties/Settings.settings @@ -29,5 +29,8 @@ + + True + \ No newline at end of file diff --git a/BodyshopUploader/ViewModels/MainViewModel.commands.cs b/BodyshopUploader/ViewModels/MainViewModel.commands.cs index 5e62334..9464a33 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.commands.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.commands.cs @@ -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; + } + } } } diff --git a/BodyshopUploader/ViewModels/MainViewModel.cs b/BodyshopUploader/ViewModels/MainViewModel.cs index 3f8d6e4..686c7b1 100644 --- a/BodyshopUploader/ViewModels/MainViewModel.cs +++ b/BodyshopUploader/ViewModels/MainViewModel.cs @@ -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 { diff --git a/BodyshopUploader/Views/Main.xaml b/BodyshopUploader/Views/Main.xaml index 6d87e32..22a0a9a 100644 --- a/BodyshopUploader/Views/Main.xaml +++ b/BodyshopUploader/Views/Main.xaml @@ -128,6 +128,12 @@ + +