Skip to content

Commit

Permalink
Add Updater.exe that can update to latest release and debug
Browse files Browse the repository at this point in the history
  • Loading branch information
ayufan committed Dec 11, 2022
1 parent 275ce48 commit 2259e17
Show file tree
Hide file tree
Showing 18 changed files with 623 additions and 59 deletions.
1 change: 1 addition & 0 deletions CommonHelpers/CommonHelpers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
65 changes: 55 additions & 10 deletions CommonHelpers/Instance.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand Down Expand Up @@ -125,7 +121,7 @@ public static void Open(String title, bool useKernelDrivers, String? runOnce = n
}
}

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);

Expand All @@ -135,9 +131,58 @@ public static void RunOnce(String title, String mutexName, int runOnceTimeout =
}
}

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)
{
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (title is not null)
MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(1);
}

Expand Down
84 changes: 47 additions & 37 deletions FanControl/FanControlForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions FanControl/FanControlForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public FanControlForm()

Text += " v" + Application.ProductVersion.ToString();
Instance.Open(Text, true, "Global\\FanControlOnce");
Instance.RunUpdater(Text);

if (Instance.WantsRunOnStartup)
startupManager.Startup = true;
Expand Down Expand Up @@ -147,6 +148,9 @@ private void SharedData_Update()

private void fanLoopTimer_Tick(object sender, EventArgs e)
{
if (fanControl is null)
return;

SharedData_Update();
fanControl.Update(Visible);
}
Expand Down Expand Up @@ -184,5 +188,10 @@ private void toolStripMenuItemAlwaysOnTop_Click(object sender, EventArgs e)
toolStripMenuItemAlwaysOnTopContext.Checked = TopMost;
Settings.Default.AlwaysOnTop = toolStripMenuItemAlwaysOnTop.Checked;
}

private void checkForUpdates_Click(object sender, EventArgs e)
{
Instance.RunUpdater(Text, true);
}
}
}
Loading

0 comments on commit 2259e17

Please sign in to comment.