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">
<value>True</value>
</setting>
<setting name="FirstRun" serializeAs="String">
<value>True</value>
</setting>
</ProcessCpuUsageStatusWindow.Properties.Settings>
</userSettings>
</configuration>

View File

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

View File

@@ -2,6 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>ProcessCpuUsageStatusWindow</id>
<title>CPU Usage Status Window</title>
<version>$version$</version>
<authors>Chris Kaczor</authors>
<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()
{
// Get rid of the timer
_processUpdateTimer.Stop();
_processUpdateTimer.Dispose();
if (_processUpdateTimer != null)
{
_processUpdateTimer.Stop();
_processUpdateTimer.Dispose();
}
// Clear the callback
_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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

View File

@@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 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
// the code is regenerated.
@@ -12,7 +12,7 @@ namespace ProcessCpuUsageStatusWindow.Properties {
[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 {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -70,5 +70,17 @@ namespace ProcessCpuUsageStatusWindow.Properties {
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">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="FirstRun" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>