Fix up settings update and a few other things

This commit is contained in:
2018-02-22 12:55:35 -05:00
parent bc8cc4092d
commit 9b862f0db9
7 changed files with 36 additions and 9 deletions

View File

@@ -22,6 +22,9 @@
<setting name="AutoStart" serializeAs="String"> <setting name="AutoStart" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>
<setting name="FirstRun" serializeAs="String">
<value>True</value>
</setting>
</ProcessCpuUsageStatusWindow.Properties.Settings> </ProcessCpuUsageStatusWindow.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@@ -18,6 +18,13 @@ namespace ProcessCpuUsageStatusWindow
{ {
SquirrelAwareApp.HandleEvents(); SquirrelAwareApp.HandleEvents();
if (Settings.Default.FirstRun)
{
Settings.Default.Upgrade();
Settings.Default.FirstRun = false;
Settings.Default.Save();
}
var application = new App(); var application = new App();
application.InitializeComponent(); application.InitializeComponent();
application.Run(); application.Run();
@@ -27,15 +34,13 @@ namespace ProcessCpuUsageStatusWindow
{ {
base.OnStartup(e); base.OnStartup(e);
Settings.Default.Upgrade();
StartManager.ManageAutoStart = true; StartManager.ManageAutoStart = true;
StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart; StartManager.AutoStartEnabled = !Debugger.IsAttached && Settings.Default.AutoStart;
StartManager.AutoStartChanged += (value => StartManager.AutoStartChanged += value =>
{ {
Settings.Default.AutoStart = value; Settings.Default.AutoStart = value;
Settings.Default.Save(); Settings.Default.Save();
}); };
_windowSource = new WindowSource(); _windowSource = new WindowSource();
} }

View File

@@ -2,6 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata> <metadata>
<id>ProcessCpuUsageStatusWindow</id> <id>ProcessCpuUsageStatusWindow</id>
<title>CPU Usage Status Window</title>
<version>$version$</version> <version>$version$</version>
<authors>Chris Kaczor</authors> <authors>Chris Kaczor</authors>
<description>A "floating" status window that shows the top X processes by CPU usage.</description> <description>A "floating" status window that shows the top X processes by CPU usage.</description>

View File

@@ -76,8 +76,11 @@ namespace ProcessCpuUsageStatusWindow
public void Terminate() public void Terminate()
{ {
// Get rid of the timer // Get rid of the timer
_processUpdateTimer.Stop(); if (_processUpdateTimer != null)
_processUpdateTimer.Dispose(); {
_processUpdateTimer.Stop();
_processUpdateTimer.Dispose();
}
// Clear the callback // Clear the callback
_processListUpdatedCallback = null; _processListUpdatedCallback = null;

View File

@@ -51,7 +51,7 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")] [assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // This code was generated by a tool.
// Runtime Version:4.0.30319.34014 // Runtime Version:4.0.30319.42000
// //
// Changes to this file may cause incorrect behavior and will be lost if // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // the code is regenerated.
@@ -12,7 +12,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -70,5 +70,17 @@ namespace ProcessCpuUsageStatusWindow.Properties {
this["AutoStart"] = value; this["AutoStart"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool FirstRun {
get {
return ((bool)(this["FirstRun"]));
}
set {
this["FirstRun"] = value;
}
}
} }
} }

View File

@@ -14,5 +14,8 @@
<Setting Name="AutoStart" Type="System.Boolean" Scope="User"> <Setting Name="AutoStart" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>
<Setting Name="FirstRun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>