Skip to content

Commit

Permalink
Auto updater
Browse files Browse the repository at this point in the history
  • Loading branch information
SocketByte committed Oct 19, 2022
1 parent fcc3f07 commit 1e90f12
Show file tree
Hide file tree
Showing 25 changed files with 1,313 additions and 23 deletions.
10 changes: 8 additions & 2 deletions SDToolkit.sln
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32901.82
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDToolkit", "SDToolkit\SDToolkit.csproj", "{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDToolkitUpdater", "SDToolkitUpdater\SDToolkitUpdater.csproj", "{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Release|Any CPU.Build.0 = Release|Any CPU
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 9 additions & 1 deletion SDToolkit/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
73 changes: 70 additions & 3 deletions SDToolkit/SDToolkit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,21 @@
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
Expand All @@ -35,16 +50,53 @@
<PropertyGroup>
<StartupObject>SDToolkit.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>ico.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NvAPIWrapper, Version=0.8.1.100, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<HintPath>..\packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll</HintPath>
</Reference>
<Reference Include="RestSharp, Version=108.0.2.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.108.0.2\lib\netstandard2.0\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.CodeDom, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.CodeDom.6.0.0\lib\net461\System.CodeDom.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.5.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.5.0.0\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -56,9 +108,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="FaceRestoration.cs" />
<Compile Include="Generator.cs" />
<Compile Include="Upscaler.cs" />
<Compile Include="Tools\FaceRestoration.cs" />
<Compile Include="Tools\Generator.cs" />
<Compile Include="Tools\Upscaler.cs" />
<Compile Include="Window.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -100,5 +152,20 @@
<ItemGroup>
<None Include="Resources\help.png" />
</ItemGroup>
<ItemGroup>
<Content Include="ico.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
File renamed without changes.
File renamed without changes.
11 changes: 0 additions & 11 deletions SDToolkit/Upscaler.cs → SDToolkit/Tools/Upscaler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,6 @@ namespace SDToolkit
{
class Upscaler
{
private static string GetUpscalingAlgorithm(string algorithm)
{
switch (algorithm)
{
case "RealSR": return "realsr_ncnn_vulkan";
case "SRMD": return "srmd_ncnn_vulkan";
case "Waifu2x": return "waifu2x_ncnn_vulkan";
}
return "realsr_ncnn_vulkan";
}

public static void Upscale(Generator.GeneratorConfig config, string[] images)
{
var outputNames = new string[images.Length];
Expand Down
2 changes: 2 additions & 0 deletions SDToolkit/Window.Designer.cs

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

57 changes: 54 additions & 3 deletions SDToolkit/Window.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

using Newtonsoft.Json.Linq;
using NvAPIWrapper.Display;
using RestSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
Expand All @@ -13,13 +15,17 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;
using static SDToolkit.Window;

namespace SDToolkit
{
public partial class Window : Form
{
private uint _vram = 0;
private DateTime _start;
private string _latestVersion;

public Window()
{
InitializeComponent();
Expand Down Expand Up @@ -240,9 +246,32 @@ private void SetUpscaleInfo()
upscaleLabel.Text = "Final image resolution after upscaling: " + x + " x " + y + ", upscaler: " + upscaler;
}

public class App
{
public string AppVersion { get; set; }
}

private void Window_Load(object sender, EventArgs e)
{
SetUpscaleInfo();

var app = new App();
var serializer = new XmlSerializer(typeof(App));
using (var reader = new StreamReader("App.xml"))
{
app = (App)serializer.Deserialize(reader);
}
Text = "SDToolkit " + app.AppVersion;

var client = new RestClient("https://api.github.com/repos/SocketByte/SDToolkit/releases");
var request = new RestRequest();
request.AddHeader("Accept", "application/vnd.github+json");
RestResponse response = client.Execute(request);

var releases = JArray.Parse(response.Content);

_latestVersion = releases[0]["tag_name"].ToString().Replace("v", "");

}

private void upscaleCombo_SelectedIndexChanged(object sender, EventArgs e)
Expand All @@ -263,10 +292,32 @@ private void resWBox_TextChanged(object sender, EventArgs e)
private void useGFPGAN_CheckedChanged(object sender, EventArgs e)
{
SetUpscaleInfo();


}
}

private void Window_Shown(object sender, EventArgs e)
{
var app = new App();
var serializer = new XmlSerializer(typeof(App));
using (var reader = new StreamReader("App.xml"))
{
app = (App)serializer.Deserialize(reader);
}
if (_latestVersion != app.AppVersion)
{
var result = MessageBox.Show("A new version of SDToolkit is available: " + _latestVersion + ". \nDo you want to download the update now?", "New version available",
MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

if (result.Equals(DialogResult.OK))
{
var process = new Process();
process.StartInfo.FileName = "SDToolkitUpdater.exe";
process.Start();

Environment.Exit(0);
}
}
}
}


}
3 changes: 0 additions & 3 deletions SDToolkit/Window.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>36, 15</value>
</metadata>
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>36, 15</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
Binary file added SDToolkit/ico.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions SDToolkit/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="NvAPIWrapper.Net" version="0.8.1.101" targetFramework="net472" />
<package id="RestSharp" version="108.0.2" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
<package id="System.CodeDom" version="6.0.0" targetFramework="net472" />
<package id="System.Memory" version="4.5.4" targetFramework="net472" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Encodings.Web" version="5.0.0" targetFramework="net472" />
<package id="System.Text.Json" version="5.0.0" targetFramework="net472" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
</packages>
14 changes: 14 additions & 0 deletions SDToolkitUpdater/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Loading

0 comments on commit 1e90f12

Please sign in to comment.