Add Updater.exe that can update to latest release and debug

This commit is contained in:
Kamil Trzciński 2022-12-11 02:35:46 +01:00
parent 275ce48509
commit 2259e17b21
18 changed files with 623 additions and 59 deletions

View file

@ -8,6 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.7.6" />
<PackageReference Include="LibreHardwareMonitorLib" Version="0.9.1" />
<PackageReference Include="TaskScheduler" Version="2.10.1" />
</ItemGroup>

View file

@ -1,12 +1,8 @@
using System;
using System.IO;
using System.Linq;
using System.Security;
using System.Security.Principal;
using System.Security.AccessControl;
using System.Windows.Forms;
using System.Runtime.CompilerServices;
using AutoUpdaterDotNET;
using Microsoft.Win32;
using System.Diagnostics;
namespace CommonHelpers
{
@ -125,7 +121,7 @@ namespace CommonHelpers
}
}
public static void RunOnce(String title, String mutexName, int runOnceTimeout = 1000)
public static void RunOnce(String? title, String mutexName, int runOnceTimeout = 1000)
{
runOnceMutex = TryCreateOrOpenExistingMutex(mutexName);
@ -135,8 +131,57 @@ namespace CommonHelpers
}
}
public static void Fatal(String title, String message)
public static String MachineID
{
get
{
try
{
using (var registryKey = Registry.CurrentUser.OpenSubKey(@"Software\SteamDeckTools"))
{
var machineID = registryKey?.GetValue("MachineID") as string;
if (machineID is not null)
return machineID;
machineID = Guid.NewGuid().ToString();
registryKey?.SetValue("MachineID", machineID);
return machineID;
}
}
catch (Exception)
{
return "exception";
}
}
}
public static Version? ApplicationVersion
{
get => System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
}
public static String ProductVersion
{
get => Application.ProductVersion;
}
public static void RunUpdater(string Title, bool user = false)
{
try
{
Process.Start(new ProcessStartInfo()
{
FileName = "Updater.exe",
ArgumentList = { user ? "-user" : "-first" },
UseShellExecute = false
});
}
catch { }
}
public static void Fatal(String? title, String message)
{
if (title is not null)
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}

View file

@ -55,6 +55,7 @@ namespace FanControl
this.helpLabel = new System.Windows.Forms.Label();
this.sensorWarningLabel = new System.Windows.Forms.Label();
this.propertyGrid1 = new System.Windows.Forms.PropertyGrid();
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenu.SuspendLayout();
this.menuStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
@ -84,58 +85,59 @@ namespace FanControl
this.toolStripMenuItemStartupOnBootContext,
this.toolStripMenuItemAlwaysOnTopContext,
this.toolStripMenuItem3,
this.toolStripMenuItem5,
this.toolStripSeparator1,
this.toolStripMenuItem1});
this.contextMenu.Name = "fanModeSelectMenu";
this.contextMenu.Size = new System.Drawing.Size(257, 212);
this.contextMenu.Size = new System.Drawing.Size(211, 194);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(256, 38);
this.toolStripMenuItem2.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItem2.Text = "&Show";
this.toolStripMenuItem2.Click += new System.EventHandler(this.formShow_Event);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(253, 6);
this.toolStripSeparator3.Size = new System.Drawing.Size(207, 6);
//
// toolStripSeparatorEndOfModes
//
this.toolStripSeparatorEndOfModes.Name = "toolStripSeparatorEndOfModes";
this.toolStripSeparatorEndOfModes.Size = new System.Drawing.Size(253, 6);
this.toolStripSeparatorEndOfModes.Size = new System.Drawing.Size(207, 6);
//
// toolStripMenuItemStartupOnBootContext
//
this.toolStripMenuItemStartupOnBootContext.Name = "toolStripMenuItemStartupOnBootContext";
this.toolStripMenuItemStartupOnBootContext.Size = new System.Drawing.Size(256, 38);
this.toolStripMenuItemStartupOnBootContext.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItemStartupOnBootContext.Text = "Run On &Startup";
this.toolStripMenuItemStartupOnBootContext.Click += new System.EventHandler(this.toolStripMenuItemStartupOnBoot_Click);
//
// toolStripMenuItemAlwaysOnTopContext
//
this.toolStripMenuItemAlwaysOnTopContext.Name = "toolStripMenuItemAlwaysOnTopContext";
this.toolStripMenuItemAlwaysOnTopContext.Size = new System.Drawing.Size(256, 38);
this.toolStripMenuItemAlwaysOnTopContext.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItemAlwaysOnTopContext.Text = "&Always on Top";
this.toolStripMenuItemAlwaysOnTopContext.Click += new System.EventHandler(this.toolStripMenuItemAlwaysOnTop_Click);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(256, 38);
this.toolStripMenuItem3.Text = "Help";
this.toolStripMenuItem3.Click += new System.EventHandler(this.help_DoubleClick);
this.toolStripMenuItem3.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItem3.Text = "&Check for Updates";
this.toolStripMenuItem3.Click += new System.EventHandler(this.checkForUpdates_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(253, 6);
this.toolStripSeparator1.Size = new System.Drawing.Size(207, 6);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(256, 38);
this.toolStripMenuItem1.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItem1.Text = "&Exit";
this.toolStripMenuItem1.Click += new System.EventHandler(this.formClose_Event);
//
@ -146,7 +148,8 @@ namespace FanControl
this.controlToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(711, 44);
this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1);
this.menuStrip1.Size = new System.Drawing.Size(438, 30);
this.menuStrip1.TabIndex = 3;
this.menuStrip1.Text = "menuStrip1";
//
@ -156,7 +159,7 @@ namespace FanControl
this.fanModeSelectMenu.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.fanModeSelectMenu.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.fanModeSelectMenu.Name = "fanModeSelectMenu";
this.fanModeSelectMenu.Size = new System.Drawing.Size(249, 40);
this.fanModeSelectMenu.Size = new System.Drawing.Size(155, 28);
this.fanModeSelectMenu.SelectedIndexChanged += new System.EventHandler(this.fanModeSelectMenu_SelectedIndexChanged);
//
// controlToolStripMenuItem
@ -168,39 +171,39 @@ namespace FanControl
this.toolStripSeparator2,
this.exitToolStripMenuItem});
this.controlToolStripMenuItem.Name = "controlToolStripMenuItem";
this.controlToolStripMenuItem.Size = new System.Drawing.Size(113, 40);
this.controlToolStripMenuItem.Size = new System.Drawing.Size(72, 28);
this.controlToolStripMenuItem.Text = "&Control";
//
// toolStripMenuItemStartupOnBoot
//
this.toolStripMenuItemStartupOnBoot.Name = "toolStripMenuItemStartupOnBoot";
this.toolStripMenuItemStartupOnBoot.Size = new System.Drawing.Size(315, 44);
this.toolStripMenuItemStartupOnBoot.Size = new System.Drawing.Size(192, 26);
this.toolStripMenuItemStartupOnBoot.Text = "Run On &Startup";
this.toolStripMenuItemStartupOnBoot.Click += new System.EventHandler(this.toolStripMenuItemStartupOnBoot_Click);
//
// toolStripMenuItemAlwaysOnTop
//
this.toolStripMenuItemAlwaysOnTop.Name = "toolStripMenuItemAlwaysOnTop";
this.toolStripMenuItemAlwaysOnTop.Size = new System.Drawing.Size(315, 44);
this.toolStripMenuItemAlwaysOnTop.Size = new System.Drawing.Size(192, 26);
this.toolStripMenuItemAlwaysOnTop.Text = "&Always on Top";
this.toolStripMenuItemAlwaysOnTop.Click += new System.EventHandler(this.toolStripMenuItemAlwaysOnTop_Click);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(315, 44);
this.toolStripMenuItem4.Size = new System.Drawing.Size(192, 26);
this.toolStripMenuItem4.Text = "Help";
this.toolStripMenuItem4.Click += new System.EventHandler(this.help_DoubleClick);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(312, 6);
this.toolStripSeparator2.Size = new System.Drawing.Size(189, 6);
//
// exitToolStripMenuItem
//
this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
this.exitToolStripMenuItem.Size = new System.Drawing.Size(315, 44);
this.exitToolStripMenuItem.Size = new System.Drawing.Size(192, 26);
this.exitToolStripMenuItem.Text = "&Exit";
this.exitToolStripMenuItem.Click += new System.EventHandler(this.formClose_Event);
//
@ -219,8 +222,8 @@ namespace FanControl
this.tableLayoutPanel1.Controls.Add(this.sensorWarningLabel, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.propertyGrid1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 44);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 30);
this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
@ -228,7 +231,7 @@ namespace FanControl
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(711, 1046);
this.tableLayoutPanel1.Size = new System.Drawing.Size(438, 454);
this.tableLayoutPanel1.TabIndex = 5;
//
// label1
@ -238,10 +241,10 @@ namespace FanControl
this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.label1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.label1.ForeColor = System.Drawing.Color.Red;
this.label1.Location = new System.Drawing.Point(4, 950);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Location = new System.Drawing.Point(2, 394);
this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(703, 64);
this.label1.Size = new System.Drawing.Size(434, 40);
this.label1.TabIndex = 9;
this.label1.Text = "This application is highly experimental.\r\nUse at your own risk!";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -254,10 +257,10 @@ namespace FanControl
this.helpLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.helpLabel.Font = new System.Drawing.Font("Segoe UI", 9F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Underline))), System.Drawing.GraphicsUnit.Point);
this.helpLabel.ForeColor = System.Drawing.SystemColors.HotTrack;
this.helpLabel.Location = new System.Drawing.Point(4, 1014);
this.helpLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.helpLabel.Location = new System.Drawing.Point(2, 434);
this.helpLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.helpLabel.Name = "helpLabel";
this.helpLabel.Size = new System.Drawing.Size(703, 32);
this.helpLabel.Size = new System.Drawing.Size(434, 20);
this.helpLabel.TabIndex = 8;
this.helpLabel.Text = "https://steam-deck-tools.ayufan.dev";
this.helpLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
@ -270,10 +273,10 @@ namespace FanControl
this.sensorWarningLabel.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.sensorWarningLabel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
this.sensorWarningLabel.ForeColor = System.Drawing.Color.Red;
this.sensorWarningLabel.Location = new System.Drawing.Point(4, 854);
this.sensorWarningLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.sensorWarningLabel.Location = new System.Drawing.Point(2, 334);
this.sensorWarningLabel.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.sensorWarningLabel.Name = "sensorWarningLabel";
this.sensorWarningLabel.Size = new System.Drawing.Size(703, 96);
this.sensorWarningLabel.Size = new System.Drawing.Size(434, 60);
this.sensorWarningLabel.TabIndex = 6;
this.sensorWarningLabel.Text = "Some sensors are missing.\r\nThe fan behavior might be incorrect.\r\nWhich might resu" +
"lt in device overheating.\r\n";
@ -285,24 +288,30 @@ namespace FanControl
this.propertyGrid1.DisabledItemForeColor = System.Drawing.SystemColors.ControlText;
this.propertyGrid1.Dock = System.Windows.Forms.DockStyle.Fill;
this.propertyGrid1.HelpVisible = false;
this.propertyGrid1.Location = new System.Drawing.Point(4, 2);
this.propertyGrid1.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
this.propertyGrid1.Location = new System.Drawing.Point(2, 1);
this.propertyGrid1.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
this.propertyGrid1.Name = "propertyGrid1";
this.propertyGrid1.Size = new System.Drawing.Size(703, 850);
this.propertyGrid1.Size = new System.Drawing.Size(434, 332);
this.propertyGrid1.TabIndex = 1;
this.propertyGrid1.ToolbarVisible = false;
//
// toolStripMenuItem5
//
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
this.toolStripMenuItem5.Size = new System.Drawing.Size(210, 24);
this.toolStripMenuItem5.Text = "Help";
//
// FanControlForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(13F, 32F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.ClientSize = new System.Drawing.Size(711, 1090);
this.ClientSize = new System.Drawing.Size(438, 484);
this.Controls.Add(this.tableLayoutPanel1);
this.Controls.Add(this.menuStrip1);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MainMenuStrip = this.menuStrip1;
this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FanControlForm";
@ -348,5 +357,6 @@ namespace FanControl
private ToolStripMenuItem toolStripMenuItem3;
private ToolStripSeparator toolStripSeparator1;
private ToolStripMenuItem toolStripMenuItem4;
private ToolStripMenuItem toolStripMenuItem5;
}
}

View file

@ -19,6 +19,7 @@ namespace FanControl
Text += " v" + Application.ProductVersion.ToString();
Instance.Open(Text, true, "Global\\FanControlOnce");
Instance.RunUpdater(Text);
if (Instance.WantsRunOnStartup)
startupManager.Startup = true;
@ -147,6 +148,9 @@ namespace FanControl
private void fanLoopTimer_Tick(object sender, EventArgs e)
{
if (fanControl is null)
return;
SharedData_Update();
fanControl.Update(Visible);
}
@ -184,5 +188,10 @@ namespace FanControl
toolStripMenuItemAlwaysOnTopContext.Checked = TopMost;
Settings.Default.AlwaysOnTop = toolStripMenuItemAlwaysOnTop.Checked;
}
private void checkForUpdates_Click(object sender, EventArgs e)
{
Instance.RunUpdater(Text, true);
}
}
}

View file

@ -30,6 +30,7 @@ namespace PerformanceOverlay
SharedData_Update();
Instance.Open(TitleWithVersion, true, "Global\\PerformanceOverlay");
Instance.RunUpdater(TitleWithVersion);
if (Instance.WantsRunOnStartup)
startupManager.Startup = true;
@ -71,11 +72,11 @@ namespace PerformanceOverlay
contextMenu.Items.Add(startupItem);
}
var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };
var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate
{
System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev");
};
helpItem.Click += delegate { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
contextMenu.Items.Add(new ToolStripSeparator());

View file

@ -40,6 +40,7 @@ namespace PowerControl
public Controller()
{
Instance.RunOnce(TitleWithVersion, "Global\\PowerControl");
Instance.RunUpdater(TitleWithVersion);
if (Instance.WantsRunOnStartup)
startupManager.Startup = true;
@ -72,12 +73,11 @@ namespace PowerControl
contextMenu.Items.Add(startupItem);
}
var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate
{
System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev");
};
var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };
var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { System.Diagnostics.Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
contextMenu.Items.Add(new ToolStripSeparator());
var exitItem = contextMenu.Items.Add("&Exit");

View file

@ -24,3 +24,4 @@
- Swap `STEAM+Menu` and `STEAM+Options`. It makes more sense to switch windows with STEAM+3 horizontal lines
- If application is run with `-run-on-startup` it will self-set to run on system start
- Depend on `GetCursorPos` to detect `SAS`
- Add `Updater.exe` that can update to latest release and debug

View file

@ -41,6 +41,7 @@ namespace SteamController
Select((profile) => profile.Name).ToArray();
Instance.RunOnce(TitleWithVersion, "Global\\SteamController");
Instance.RunUpdater(TitleWithVersion);
if (Instance.WantsRunOnStartup)
startupManager.Startup = true;
@ -81,12 +82,15 @@ namespace SteamController
contextMenu.Items.Add(new ToolStripSeparator());
var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
var checkForUpdatesItem = contextMenu.Items.Add("&Check for Updates");
checkForUpdatesItem.Click += delegate { Instance.RunUpdater(TitleWithVersion, true); };
var shortcutsItem = contextMenu.Items.Add("&Shortcuts");
shortcutsItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev/docs/shortcuts.html"); };
var helpItem = contextMenu.Items.Add("&Help");
helpItem.Click += delegate { Process.Start("explorer.exe", "https://steam-deck-tools.ayufan.dev"); };
contextMenu.Items.Add(new ToolStripSeparator());
var exitItem = contextMenu.Items.Add("&Exit");

View file

@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PowerControl", "PowerContro
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExternalHelpers", "ExternalHelpers\ExternalHelpers.csproj", "{A3FD29A4-844F-42B1-80C5-0301BD053AC0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SteamController", "SteamController\SteamController.csproj", "{A5A9DCD4-4686-49A6-836A-81498226B94B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SteamController", "SteamController\SteamController.csproj", "{A5A9DCD4-4686-49A6-836A-81498226B94B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Updater", "Updater\Updater.csproj", "{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -97,6 +99,18 @@ Global
{A5A9DCD4-4686-49A6-836A-81498226B94B}.Release|x64.Build.0 = Release|Any CPU
{A5A9DCD4-4686-49A6-836A-81498226B94B}.Release|x86.ActiveCfg = Release|Any CPU
{A5A9DCD4-4686-49A6-836A-81498226B94B}.Release|x86.Build.0 = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|x64.ActiveCfg = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|x64.Build.0 = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|x86.ActiveCfg = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Debug|x86.Build.0 = Debug|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|Any CPU.Build.0 = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|x64.ActiveCfg = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|x64.Build.0 = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|x86.ActiveCfg = Release|Any CPU
{7FBC87CE-5C6E-4A8E-AF07-E310AD311073}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

158
Updater/Program.cs Normal file
View file

@ -0,0 +1,158 @@
using System.ComponentModel;
using System.Diagnostics;
using System.Reflection;
using AutoUpdaterDotNET;
using CommonHelpers;
namespace Updater
{
internal static class Program
{
public const String Title = "Steam Deck Tools";
public const String RunPrefix = "-run=";
public const String UpdatedArg = "-updated";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
bool firstRun = Environment.GetCommandLineArgs().Contains("-first");
bool userCheck = Environment.GetCommandLineArgs().Contains("-user");
bool updated = Environment.GetCommandLineArgs().Contains(UpdatedArg);
bool cmdLine = !firstRun && !userCheck;
if (updated)
{
foreach (var arg in Environment.GetCommandLineArgs())
{
if (!arg.StartsWith(RunPrefix))
continue;
var processName = arg.Substring(RunPrefix.Length);
CommonHelpers.Log.TraceLine("Running {0}", processName);
try { Process.Start(processName); } catch { }
}
return;
}
Instance.RunOnce(null, "Global\\SteamDeckToolsAutoUpdater");
var persistence = new RegistryPersistenceProvider(@"Software\SteamDeckTools\AutoUpdater");
if (userCheck || cmdLine)
{
persistence.SetRemindLater(null);
persistence.SetSkippedVersion(new Version());
}
AutoUpdater.AppTitle = Title;
AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Days;
AutoUpdater.LetUserSelectRemindLater = true;
AutoUpdater.ShowRemindLaterButton = true;
AutoUpdater.HttpUserAgent = String.Format("AutoUpdater/{0}/{1}", Instance.MachineID, Instance.ProductVersion);
AutoUpdater.PersistenceProvider = persistence;
AutoUpdater.ReportErrors = userCheck || cmdLine;
AutoUpdater.UpdateFormSize = new Size(800, 300);
AutoUpdater.ShowSkipButton = true;
AutoUpdater.Synchronous = true;
AutoUpdater.ApplicationExitEvent += Application_Exit;
AppendArg(UpdatedArg);
TrackProcess("FanControl");
TrackProcess("PowerControl");
TrackProcess("PerformanceOverlay");
TrackProcess("SteamController");
#if DEBUG
AutoUpdater.Start("https://steam-deck-tools.ayufan.dev/docs/updates/debug_zip.xml");
#else
AutoUpdater.Start("https://steam-deck-tools.ayufan.dev/docs/updates/release_zip.xml");
#endif
}
private static void TrackProcess(String processFilerName)
{
if (FindProcesses(processFilerName).Any())
AppendArg(RunPrefix + processFilerName);
}
private static void Application_Exit()
{
ExitProcess("FanControl");
ExitProcess("PowerControl");
ExitProcess("PerformanceOverlay");
ExitProcess("SteamController");
ExitProcess("Updater");
}
private static void AppendArg(string arg)
{
var setCommandLineArgs = typeof(Environment).GetMethod(
"SetCommandLineArgs", BindingFlags.Static | BindingFlags.NonPublic,
new Type[] { typeof(string[]) });
if (setCommandLineArgs is null)
return;
// append `-run:<process>` to command line args
setCommandLineArgs.Invoke(null, new object[] {
Environment.GetCommandLineArgs().Append(arg).ToArray()
});
}
private static bool ExitProcess(String processFilerName)
{
bool found = false;
foreach (var process in FindProcesses(processFilerName))
{
if (process.CloseMainWindow())
{
process.WaitForExit((int)TimeSpan.FromSeconds(10)
.TotalMilliseconds); //give some time to process message
}
if (!process.HasExited)
{
process.Kill(); //TODO show UI message asking user to close program himself instead of silently killing it
}
found = true;
}
return found;
}
private static IEnumerable<Process> FindProcesses(String processFilerName)
{
var currentProcess = Process.GetCurrentProcess();
var currentDir = Path.GetDirectoryName(currentProcess.MainModule?.FileName);
foreach (var process in Process.GetProcessesByName(processFilerName))
{
string? processFileName, processDir;
try
{
processFileName = process.MainModule?.FileName;
if (processFileName is null)
continue;
processDir = Path.GetDirectoryName(processFileName);
}
catch (Win32Exception)
{
// Current process should be same as processes created by other instances of the application so it should be able to access modules of other instances.
// This means this is not the process we are looking for so we can safely skip this.
continue;
}
//get all instances of assembly except current
if (process.Id != currentProcess.Id && currentDir == processDir)
{
yield return process;
}
}
}
}
}

83
Updater/Resources.Designer.cs generated Normal file
View file

@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Updater {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// 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", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 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 {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Updater.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// 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 {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon update {
get {
object obj = ResourceManager.GetObject("update", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap update1 {
get {
object obj = ResourceManager.GetObject("update1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

127
Updater/Resources.resx Normal file
View file

@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\update.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="update1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

36
Updater/Updater.csproj Normal file
View file

@ -0,0 +1,36 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<ApplicationIcon>Resources\update.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Content Include="Resources\update.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CommonHelpers\CommonHelpers.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

61
Updater/app.manifest Normal file
View file

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="0.1.0.0" name="PerformanceOverlay.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
<!--<requestedExecutionLevel level="requireAdministrator" uiAccess="true" />-->
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config.
Makes the application long-path aware. See https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
</windowsSettings>
</application>
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.5.31</version>
<url>https://github.com/ayufan/steam-deck-tools/releases/download/0.5.31/SteamDeckTools-0.5.31-debug.zip</url>
<changelog2>https://github.com/ayufan/steam-deck-tools/releases/tag/0.5.31</changelog2>
<mandatory>false</mandatory>
</item>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.5.31</version>
<url>https://github.com/ayufan/steam-deck-tools/releases/download/0.5.31/SteamDeckTools-0.5.31.zip</url>
<changelog2>https://github.com/ayufan/steam-deck-tools/releases/tag/0.5.31</changelog2>
<mandatory>false</mandatory>
</item>