Start working towards Squirrel install/update

This commit is contained in:
2018-05-24 20:39:19 -04:00
parent 299d85140d
commit 54da717e56
19 changed files with 671 additions and 110 deletions

View File

@@ -1,4 +1,6 @@
using FloatingStatusWindowLibrary;
using Squirrel;
using System;
using System.Diagnostics;
using System.Windows;
using SystemTemperatureStatusWindow.Properties;
@@ -8,6 +10,18 @@ namespace SystemTemperatureStatusWindow
public partial class App
{
private WindowSource _windowSource;
public static string UpdateUrl = "https://github.com/ckaczor/SystemTemperatureStatusWindow";
[STAThread]
public static void Main(string[] args)
{
SquirrelAwareApp.HandleEvents(onAppUpdate: version => Common.Settings.Extensions.RestoreSettings());
var application = new App();
application.InitializeComponent();
application.Run();
}
protected override void OnStartup(StartupEventArgs e)
{
@@ -15,11 +29,11 @@ namespace SystemTemperatureStatusWindow
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

@@ -0,0 +1,46 @@
<windows:CategoryPanel x:Class="SystemTemperatureStatusWindow.Options.AboutOptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
xmlns:properties="clr-namespace:SystemTemperatureStatusWindow.Properties"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="[Application Name]"
Name="ApplicationNameLabel"
VerticalAlignment="Top"
FontWeight="Bold"
Grid.Row="0" />
<TextBlock Text="[Application Version]"
Margin="0,6,0,0"
Name="VersionLabel"
VerticalAlignment="Top"
Grid.Row="1" />
<TextBlock Text="[Company]"
Margin="0,6,0,0"
Name="CompanyLabel"
VerticalAlignment="Top"
Grid.Row="2" />
<StackPanel Grid.Row="3"
Grid.Column="0"
Margin="0,20,0,0"
Orientation="Horizontal">
<Button Content="{x:Static properties:Resources.CheckUpdate}"
HorizontalAlignment="Left"
Padding="6,2"
Click="HandleCheckForUpdateButtonClick"
VerticalContentAlignment="Center" />
<Label Name="UpdateMessage" Content="" VerticalContentAlignment="Center" Padding="6,0" />
</StackPanel>
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,41 @@
using System.Reflection;
using System.Windows;
namespace SystemTemperatureStatusWindow.Options
{
public partial class AboutOptionsPanel
{
public AboutOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
ApplicationNameLabel.Text = Properties.Resources.ApplicationName;
var version = UpdateCheck.LocalVersion.ToString();
VersionLabel.Text = string.Format(Properties.Resources.About_Version, version);
CompanyLabel.Text = ((AssemblyCompanyAttribute)Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), false)[0]).Company;
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
}
public override string CategoryName => Properties.Resources.OptionCategory_About;
private async void HandleCheckForUpdateButtonClick(object sender, RoutedEventArgs e)
{
await UpdateCheck.CheckUpdate((status, message) => UpdateMessage.Content = message);
}
}
}

View File

@@ -0,0 +1,28 @@
<windows:CategoryPanel x:Class="SystemTemperatureStatusWindow.Options.GeneralOptionsPanel"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:windows="clr-namespace:Common.Wpf.Windows;assembly=Common.Wpf"
xmlns:properties="clr-namespace:SystemTemperatureStatusWindow.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="300">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<CheckBox Content="{x:Static properties:Resources.StartWithWindows}"
Name="StartWithWindows"
VerticalAlignment="Top"
VerticalContentAlignment="Center"
Grid.ColumnSpan="2" />
</Grid>
</windows:CategoryPanel>

View File

@@ -0,0 +1,39 @@
using Common.Wpf.Extensions;
using System.Windows;
namespace SystemTemperatureStatusWindow.Options
{
public partial class GeneralOptionsPanel
{
public GeneralOptionsPanel()
{
InitializeComponent();
}
public override void LoadPanel(object data)
{
base.LoadPanel(data);
var settings = Properties.Settings.Default;
StartWithWindows.IsChecked = settings.AutoStart;
}
public override bool ValidatePanel()
{
return true;
}
public override void SavePanel()
{
var settings = Properties.Settings.Default;
if (StartWithWindows.IsChecked.HasValue && settings.AutoStart != StartWithWindows.IsChecked.Value)
settings.AutoStart = StartWithWindows.IsChecked.Value;
Application.Current.SetStartWithWindows(settings.AutoStart);
}
public override string CategoryName => Properties.Resources.OptionCategory_General;
}
}

View File

@@ -1,55 +1,21 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SystemTemperatureStatusWindow")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("Chris Kaczor")]
[assembly: AssemblyProduct("SystemTemperatureStatusWindow")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyCopyright("Copyright © Chris Kaczor 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// 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: 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.
@@ -19,10 +19,10 @@ namespace SystemTemperatureStatusWindow.Properties {
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
public class Resources {
private static global::System.Resources.ResourceManager resourceMan;
@@ -36,7 +36,7 @@ namespace SystemTemperatureStatusWindow.Properties {
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
public static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SystemTemperatureStatusWindow.Properties.Resources", typeof(Resources).Assembly);
@@ -51,7 +51,7 @@ namespace SystemTemperatureStatusWindow.Properties {
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
public static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
@@ -60,20 +60,56 @@ namespace SystemTemperatureStatusWindow.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Version: {0}.
/// </summary>
public static string About_Version {
get {
return ResourceManager.GetString("About_Version", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon ApplicationIcon {
public static System.Drawing.Icon ApplicationIcon {
get {
object obj = ResourceManager.GetObject("ApplicationIcon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to System Temperature Status Window.
/// </summary>
public static string ApplicationName {
get {
return ResourceManager.GetString("ApplicationName", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Checking for update....
/// </summary>
public static string CheckingForUpdate {
get {
return ResourceManager.GetString("CheckingForUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Check for Update.
/// </summary>
public static string CheckUpdate {
get {
return ResourceManager.GetString("CheckUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to CPU.
/// </summary>
internal static string CPU {
public static string CPU {
get {
return ResourceManager.GetString("CPU", resourceCulture);
}
@@ -82,16 +118,25 @@ namespace SystemTemperatureStatusWindow.Properties {
/// <summary>
/// Looks up a localized string similar to {0}: &lt;font color=&apos;{2}&apos;&gt;{1:f1}{3}&lt;/font&gt;.
/// </summary>
internal static string DisplayLineTemplate {
public static string DisplayLineTemplate {
get {
return ResourceManager.GetString("DisplayLineTemplate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Downloading update....
/// </summary>
public static string DownloadingUpdate {
get {
return ResourceManager.GetString("DownloadingUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to GPU.
/// </summary>
internal static string GPU {
public static string GPU {
get {
return ResourceManager.GetString("GPU", resourceCulture);
}
@@ -100,25 +145,116 @@ namespace SystemTemperatureStatusWindow.Properties {
/// <summary>
/// Looks up a localized string similar to HD{0}.
/// </summary>
internal static string HD {
public static string HD {
get {
return ResourceManager.GetString("HD", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Installing update....
/// </summary>
public static string InstallingUpdate {
get {
return ResourceManager.GetString("InstallingUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Loading....
/// </summary>
internal static string Loading {
public static string Loading {
get {
return ResourceManager.GetString("Loading", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to No update found.
/// </summary>
public static string NoUpdate {
get {
return ResourceManager.GetString("NoUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to About.
/// </summary>
public static string OptionCategory_About {
get {
return ResourceManager.GetString("OptionCategory_About", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to General.
/// </summary>
public static string OptionCategory_General {
get {
return ResourceManager.GetString("OptionCategory_General", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Cancel.
/// </summary>
public static string OptionsWindow_CancelButton {
get {
return ResourceManager.GetString("OptionsWindow_CancelButton", resourceCulture);
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
public static System.Drawing.Icon OptionsWindow_Icon {
get {
object obj = ResourceManager.GetObject("OptionsWindow_Icon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized string similar to OK.
/// </summary>
public static string OptionsWindow_OkayButton {
get {
return ResourceManager.GetString("OptionsWindow_OkayButton", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Options.
/// </summary>
public static string OptionsWindow_Title {
get {
return ResourceManager.GetString("OptionsWindow_Title", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Restarting application....
/// </summary>
public static string RestartingAfterUpdate {
get {
return ResourceManager.GetString("RestartingAfterUpdate", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to _Start when Windows starts.
/// </summary>
public static string StartWithWindows {
get {
return ResourceManager.GetString("StartWithWindows", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to °C.
/// </summary>
internal static string SuffixC {
public static string SuffixC {
get {
return ResourceManager.GetString("SuffixC", resourceCulture);
}
@@ -127,10 +263,19 @@ namespace SystemTemperatureStatusWindow.Properties {
/// <summary>
/// Looks up a localized string similar to °F.
/// </summary>
internal static string SuffixF {
public static string SuffixF {
get {
return ResourceManager.GetString("SuffixF", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Updating application....
/// </summary>
public static string Updating {
get {
return ResourceManager.GetString("Updating", resourceCulture);
}
}
}
}

View File

@@ -142,4 +142,52 @@
<data name="SuffixF" xml:space="preserve">
<value>°F</value>
</data>
<data name="CheckingForUpdate" xml:space="preserve">
<value>Checking for update...</value>
</data>
<data name="CheckUpdate" xml:space="preserve">
<value>_Check for Update</value>
</data>
<data name="DownloadingUpdate" xml:space="preserve">
<value>Downloading update...</value>
</data>
<data name="NoUpdate" xml:space="preserve">
<value>No update found</value>
</data>
<data name="Updating" xml:space="preserve">
<value>Updating application...</value>
</data>
<data name="RestartingAfterUpdate" xml:space="preserve">
<value>Restarting application...</value>
</data>
<data name="InstallingUpdate" xml:space="preserve">
<value>Installing update...</value>
</data>
<data name="ApplicationName" xml:space="preserve">
<value>System Temperature Status Window</value>
</data>
<data name="StartWithWindows" xml:space="preserve">
<value>_Start when Windows starts</value>
</data>
<data name="OptionCategory_About" xml:space="preserve">
<value>About</value>
</data>
<data name="OptionCategory_General" xml:space="preserve">
<value>General</value>
</data>
<data name="About_Version" xml:space="preserve">
<value>Version: {0}</value>
</data>
<data name="OptionsWindow_CancelButton" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="OptionsWindow_Icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ApplicationIcon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="OptionsWindow_OkayButton" xml:space="preserve">
<value>OK</value>
</data>
<data name="OptionsWindow_Title" xml:space="preserve">
<value>Options</value>
</data>
</root>

View File

@@ -35,6 +35,52 @@
</PropertyGroup>
<PropertyGroup />
<ItemGroup>
<Reference Include="Common.Native, Version=1.0.6627.16339, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Native.dll</HintPath>
</Reference>
<Reference Include="Common.Wpf, Version=1.0.6627.16340, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FloatingStatusWindow.1.0.0.9\lib\net45\Common.Wpf.dll</HintPath>
</Reference>
<Reference Include="DeltaCompressionDotNet, Version=1.1.0.0, Culture=neutral, PublicKeyToken=1d14d6e5194e7f4a, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.dll</HintPath>
</Reference>
<Reference Include="DeltaCompressionDotNet.MsDelta, Version=1.1.0.0, Culture=neutral, PublicKeyToken=46b2138a390abf55, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.MsDelta.dll</HintPath>
</Reference>
<Reference Include="DeltaCompressionDotNet.PatchApi, Version=1.1.0.0, Culture=neutral, PublicKeyToken=3e8888ee913ed789, processorArchitecture=MSIL">
<HintPath>..\packages\DeltaCompressionDotNet.1.1.0\lib\net20\DeltaCompressionDotNet.PatchApi.dll</HintPath>
</Reference>
<Reference Include="FloatingStatusWindowLibrary, Version=1.0.0.9, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FloatingStatusWindow.1.0.0.9\lib\net45\FloatingStatusWindowLibrary.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Win32.TaskScheduler, Version=2.8.1.0, Culture=neutral, PublicKeyToken=c416bc1b32d97233, processorArchitecture=MSIL">
<HintPath>..\packages\TaskScheduler.2.8.1\lib\net40\Microsoft.Win32.TaskScheduler.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Mdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Pdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Pdb.dll</HintPath>
</Reference>
<Reference Include="Mono.Cecil.Rocks, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.1\lib\net45\Mono.Cecil.Rocks.dll</HintPath>
</Reference>
<Reference Include="NuGet.Squirrel, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.8.0\lib\Net45\NuGet.Squirrel.dll</HintPath>
</Reference>
<Reference Include="SharpCompress, Version=0.17.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
<HintPath>..\packages\SharpCompress.0.17.1\lib\net45\SharpCompress.dll</HintPath>
</Reference>
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath>
</Reference>
<Reference Include="Squirrel, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\squirrel.windows.1.8.0\lib\Net45\Squirrel.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.Serialization" />
@@ -49,20 +95,35 @@
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Page Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Options\AboutOptionsPanel.xaml.cs">
<DependentUpon>AboutOptionsPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Options\GeneralOptionsPanel.xaml.cs">
<DependentUpon>GeneralOptionsPanel.xaml</DependentUpon>
</Compile>
<Compile Include="Service References\SystemTemperatureService\Reference.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="UpdateCheck.cs" />
<Compile Include="WindowSource.cs" />
<Page Include="Options\AboutOptionsPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Options\GeneralOptionsPanel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
@@ -79,9 +140,12 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<Generator>PublicResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<None Include="appveyor.yml" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -100,6 +164,7 @@
<None Include="Service References\SystemTemperatureService\SystemTemperatureStatusWindow.SystemTemperatureService.Device.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
<None Include="SystemTemperatureStatusWindow.nuspec" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
@@ -129,9 +194,9 @@
<None Include="Service References\SystemTemperatureService\SystemTemperatureService1.disco" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="FloatingStatusWindow\Library\FloatingStatusWindow.csproj">
<Project>{f023a16c-2f13-4a87-a8b7-22c43c4a58a4}</Project>
<Name>FloatingStatusWindow</Name>
<ProjectReference Include="..\Service\Common\Common.csproj">
<Project>{17864d82-457d-4a0a-bc10-1d07f2b3a5d6}</Project>
<Name>Common</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>SystemTemperatureStatusWindow</id>
<title>System Temperature Status Window</title>
<version>$version$</version>
<authors>Chris Kaczor</authors>
<description>A "floating" status window that shows CPU, GPU, and HDD temperature.</description>
<projectUrl>https://github.com/ckaczor/SystemTemperatureStatusWindow</projectUrl>
<licenseUrl>https://raw.githubusercontent.com/ckaczor/SystemTemperatureStatusWindow/master/LICENSE.md</licenseUrl>
<tags>cpu</tags>
</metadata>
<files>
<file src="bin\$configuration$\**\*" target="lib\net45" exclude="*.pdb;*.nupkg;*.vshost.*" />
</files>
</package>

71
Window/UpdateCheck.cs Normal file
View File

@@ -0,0 +1,71 @@
using Squirrel;
using System;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Threading.Tasks;
namespace SystemTemperatureStatusWindow
{
public static class UpdateCheck
{
public enum UpdateStatus
{
Checking,
None,
Downloading,
Installing,
Restarting
}
public delegate void UpdateStatusDelegate(UpdateStatus updateStatus, string message);
public static Version LocalVersion => Assembly.GetEntryAssembly().GetName().Version;
public static async Task<bool> CheckUpdate(UpdateStatusDelegate onUpdateStatus)
{
try
{
onUpdateStatus.Invoke(UpdateStatus.Checking, Properties.Resources.CheckingForUpdate);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
using (var updateManager = await UpdateManager.GitHubUpdateManager(App.UpdateUrl))
{
var updates = await updateManager.CheckForUpdate();
var lastVersion = updates?.ReleasesToApply?.OrderBy(releaseEntry => releaseEntry.Version).LastOrDefault();
if (lastVersion == null)
{
onUpdateStatus.Invoke(UpdateStatus.None, Properties.Resources.NoUpdate);
return false;
}
onUpdateStatus.Invoke(UpdateStatus.Downloading, Properties.Resources.DownloadingUpdate);
Common.Settings.Extensions.BackupSettings();
await updateManager.DownloadReleases(new[] { lastVersion });
onUpdateStatus.Invoke(UpdateStatus.Installing, Properties.Resources.InstallingUpdate);
await updateManager.ApplyReleases(updates);
await updateManager.UpdateApp();
}
onUpdateStatus.Invoke(UpdateStatus.Restarting, Properties.Resources.RestartingAfterUpdate);
UpdateManager.RestartApp();
return true;
}
catch (Exception exception)
{
Console.WriteLine(exception);
return false;
}
}
}
}

View File

@@ -1,29 +1,91 @@
using FloatingStatusWindowLibrary;
using Microsoft.Win32.TaskScheduler;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Threading;
using SystemTemperatureStatusWindow.Options;
using SystemTemperatureStatusWindow.Properties;
using SystemTemperatureStatusWindow.SystemTemperatureService;
using Common.Wpf.Windows;
using Task = Microsoft.Win32.TaskScheduler.Task;
namespace SystemTemperatureStatusWindow
{
public class WindowSource : IWindowSource, IDisposable
{
private const string ScheduledTaskName = "SystemTemperatureService";
private readonly FloatingStatusWindow _floatingStatusWindow;
private readonly Timer _refreshTimer;
private readonly Dispatcher _dispatcher;
private CategoryWindow _optionsWindow;
internal WindowSource()
{
_dispatcher = Dispatcher.CurrentDispatcher;
try
{
using (var taskService = new TaskService())
{
var existingTask = taskService.FindTask(ScheduledTaskName);
if (existingTask == null)
{
var assembly = Assembly.GetExecutingAssembly();
var path = Path.GetDirectoryName(assembly.Location);
if (path != null)
{
var fileName = Path.Combine(path, "SystemTemperatureService.exe");
Process.Start(fileName, "-install");
}
}
}
}
catch (Exception)
{
// Ignored
}
_floatingStatusWindow = new FloatingStatusWindow(this);
_floatingStatusWindow.SetText(Resources.Loading);
_refreshTimer = new Timer(Settings.Default.UpdateInterval) { AutoReset = false };
_refreshTimer.Elapsed += HandleTimerElapsed;
_refreshTimer.Start();
System.Threading.Tasks.Task.Factory.StartNew(UpdateApp).ContinueWith(task => StartUpdate(task.Result.Result));
}
private void StartUpdate(bool updateRequired)
{
if (updateRequired)
return;
System.Threading.Tasks.Task.Factory.StartNew(() => _refreshTimer.Start());
}
private async Task<bool> UpdateApp()
{
return await UpdateCheck.CheckUpdate(HandleUpdateStatus);
}
private void HandleUpdateStatus(UpdateCheck.UpdateStatus status, string message)
{
if (status == UpdateCheck.UpdateStatus.None)
message = Resources.Loading;
_dispatcher.Invoke(() => _floatingStatusWindow.SetText(message));
}
private void HandleTimerElapsed(object sender, ElapsedEventArgs e)
@@ -119,12 +181,36 @@ namespace SystemTemperatureStatusWindow
_refreshTimer.Start();
}
public void ShowAbout()
{
}
public string Name => "System Temperature";
public System.Drawing.Icon Icon => Resources.ApplicationIcon;
public void ShowSettings()
{
var panels = new List<CategoryPanel>
{
new GeneralOptionsPanel(),
new AboutOptionsPanel()
};
if (_optionsWindow == null)
{
_optionsWindow = new CategoryWindow(null, panels, Resources.ResourceManager, "OptionsWindow");
_optionsWindow.Closed += (o, args) => { _optionsWindow = null; };
}
var dialogResult = _optionsWindow.ShowDialog();
if (dialogResult.HasValue && dialogResult.Value)
{
Settings.Default.Save();
Refresh();
}
}
public void Refresh()
@@ -132,8 +218,9 @@ namespace SystemTemperatureStatusWindow
Update();
}
public bool HasSettingsMenu => false;
public bool HasSettingsMenu => true;
public bool HasRefreshMenu => true;
public bool HasAboutMenu => false;
public string WindowSettings
{

31
Window/appveyor.yml Normal file
View File

@@ -0,0 +1,31 @@
version: 1.0.{build}
pull_requests:
do_not_increment_build_number: true
skip_tags: true
image: Visual Studio 2017
configuration: Release
assembly_info:
patch: true
file: 'Properties\AssemblyInfo.cs'
assembly_version: '{version}'
assembly_file_version: '{version}'
build:
project: SystemTemperatureStatusWindow.sln
verbosity: minimal
after_build:
- ps: >-
nuget pack SystemTemperatureStatusWindow.nuspec -Version $env:APPVEYOR_BUILD_VERSION -Properties Configuration=Release -OutputDirectory bin\Release\
$squirrel = "..\packages\squirrel.windows.*\tools\Squirrel.exe"
.$squirrel -releasify ".\bin\$env:CONFIGURATION\SystemTemperatureStatusWindow.$env:APPVEYOR_BUILD_VERSION.nupkg" | Write-Output
artifacts:
- path: Releases\*
name: Releases
deploy:
- provider: Environment
name: GitHub
install:
- cmd: git submodule update --init --recursive
before_build:
- cmd: nuget restore

10
Window/packages.config Normal file
View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DeltaCompressionDotNet" version="1.1.0" targetFramework="net45" />
<package id="FloatingStatusWindow" version="1.0.0.9" targetFramework="net45" />
<package id="Mono.Cecil" version="0.9.6.1" targetFramework="net45" />
<package id="SharpCompress" version="0.17.1" targetFramework="net45" />
<package id="Splat" version="1.6.2" targetFramework="net45" />
<package id="squirrel.windows" version="1.8.0" targetFramework="net45" />
<package id="TaskScheduler" version="2.8.1" targetFramework="net45" />
</packages>