Skip to content

Commit

Permalink
Added auto updater
Browse files Browse the repository at this point in the history
Added a utility program that automatically checks for updates.
  • Loading branch information
WilliamRagstad committed Apr 1, 2020
1 parent 9cac240 commit 6274c6a
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 57 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ _ReSharper*/
*.DotSettings.user
*.pfx
*.exe
CSGO Font Manager/ProtectedSettings.cs
16 changes: 7 additions & 9 deletions CSGO Font Manager/CSGO Font Manager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="JsonManager.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ProtectedSettings.cs" />
<Compile Include="Settings.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
Expand All @@ -115,11 +121,6 @@
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
Expand All @@ -141,17 +142,14 @@
<ItemGroup>
<None Include="Resources\Thumbnail.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Thumbnail %282%29.png" />
</ItemGroup>
<ItemGroup>
<Content Include="fonmanager_icon.ico" />
<None Include="Resources\fonmanager_icon-5.png" />
<None Include="Resources\add_retro.png" />
<None Include="Resources\remove_retro.png" />
<Content Include="Resources\updater.exe" />
<Content Include="stableVersion.txt" />
<None Include="Resources\FontReg.exe" />
<None Include="Resources\drop your font here.png" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
Expand Down
2 changes: 1 addition & 1 deletion CSGO Font Manager/Form1.Designer.cs

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

24 changes: 24 additions & 0 deletions CSGO Font Manager/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ public partial class Form1 : Form
public static string FontManagerFolder = HomeFolder + @"Font Manager\";
public static string FontsFolder = FontManagerFolder + @"Fonts\";
public static string DataPath = FontManagerFolder + @"Data\";

private static string SettingsFile = DataPath + "settings.json";
private static string UpdaterFile = DataPath + "updater.exe";

public static Settings Settings;
public static JsonManager<Settings> SettingsManager;
Expand Down Expand Up @@ -91,6 +93,7 @@ private void AutoFocusRunningInstance()

private void checkForUpdates()
{
/*
string versionPattern = @"(\d+\.)(\d+\.?)+";
// Get new version
Expand Down Expand Up @@ -137,6 +140,24 @@ private void checkForUpdates()
Settings.HideNewVersions = VersionNumber;
}
}
*/

// Call updater.exe
string fmExe = System.Reflection.Assembly.GetExecutingAssembly().Location;
var processInfo = new ProcessStartInfo
{
UseShellExecute = false,
RedirectStandardError = true,
RedirectStandardOutput = true,
CreateNoWindow = true,
FileName = UpdaterFile,
Arguments = $"\"{ProtectedSettings.Token}\" \"{VersionNumber}\" \"{fmExe}\""
};
Process p = Process.Start(processInfo);
p.WaitForExit();

string output = p.StandardOutput.ReadLine();
string err = p.StandardError.ReadLine();
}

private static void SetupFolderStructure()
Expand All @@ -146,6 +167,9 @@ private static void SetupFolderStructure()
Directory.CreateDirectory(FontManagerFolder);
Directory.CreateDirectory(FontsFolder);
Directory.CreateDirectory(DataPath);

// Extract updater
File.WriteAllBytes(UpdaterFile, Properties.Resources.updater);
}
else
{
Expand Down
38 changes: 4 additions & 34 deletions CSGO Font Manager/Properties/Resources.Designer.cs

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

17 changes: 4 additions & 13 deletions CSGO Font Manager/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@
<data name="FontReg" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\FontReg.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="add_retro1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\add_retro.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Thumbnail2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Thumbnail (2).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="fontmanager" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\fontmanager.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand All @@ -142,16 +136,13 @@
<data name="add_retro" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\add_retro.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="drophere" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\drop your font here.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="remove_retro" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\remove_retro.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="fonmanager_icon-5" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\fonmanager_icon-5.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="remove_retro1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<data name="remove_retro" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\remove_retro.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="updater" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\updater.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
Binary file removed CSGO Font Manager/Resources/Thumbnail (2).png
Binary file not shown.
Binary file removed CSGO Font Manager/Resources/drop your font here.png
Binary file not shown.
Binary file not shown.

0 comments on commit 6274c6a

Please sign in to comment.