From 89b4ef0c6aad7a8b5f1dcdee0e1320a6b162e756 Mon Sep 17 00:00:00 2001 From: Chris Kaczor Date: Sat, 3 May 2014 09:51:46 -0400 Subject: [PATCH] Auto start support --- App.config | 3 +++ App.xaml.cs | 13 ++++++++++++- Properties/Settings.Designer.cs | 12 ++++++++++++ Properties/Settings.settings | 3 +++ 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/App.config b/App.config index 3062bfd..8723ca1 100644 --- a/App.config +++ b/App.config @@ -19,6 +19,9 @@ + + True + \ No newline at end of file diff --git a/App.xaml.cs b/App.xaml.cs index e755a39..4768dab 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,4 +1,7 @@ -using System.Windows; +using FloatingStatusWindowLibrary; +using ProcessCpuUsageStatusWindow.Properties; +using System.Diagnostics; +using System.Windows; namespace ProcessCpuUsageStatusWindow { @@ -10,6 +13,14 @@ namespace ProcessCpuUsageStatusWindow { base.OnStartup(e); + StartManager.ManageAutoStart = true; + StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart; + StartManager.AutoStartChanged += (value => + { + Settings.Default.AutoStart = value; + Settings.Default.Save(); + }); + _windowSource = new WindowSource(); } diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 6e0bde0..5f6f8ba 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -58,5 +58,17 @@ namespace ProcessCpuUsageStatusWindow.Properties { this["WindowSettings"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool AutoStart { + get { + return ((bool)(this["AutoStart"])); + } + set { + this["AutoStart"] = value; + } + } } } diff --git a/Properties/Settings.settings b/Properties/Settings.settings index af8bde6..6d8c7f4 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -11,5 +11,8 @@ + + True + \ No newline at end of file