Skip to content

Commit 1e90f12

Browse files
committed
Auto updater
1 parent fcc3f07 commit 1e90f12

25 files changed

+1313
-23
lines changed

SDToolkit.sln

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.32901.82
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.3.32929.385
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDToolkit", "SDToolkit\SDToolkit.csproj", "{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}"
77
EndProject
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SDToolkitUpdater", "SDToolkitUpdater\SDToolkitUpdater.csproj", "{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}"
9+
EndProject
810
Global
911
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1012
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
1517
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Debug|Any CPU.Build.0 = Debug|Any CPU
1618
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Release|Any CPU.ActiveCfg = Release|Any CPU
1719
{8A9E9DE0-C4B2-4DCF-8198-CB2CCBD58514}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{4DE1E61D-EE11-488B-A3C2-770711E3B8C7}.Release|Any CPU.Build.0 = Release|Any CPU
1824
EndGlobalSection
1925
GlobalSection(SolutionProperties) = preSolution
2026
HideSolutionNode = FALSE

SDToolkit/App.config

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<startup>
44
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
55
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
11+
</dependentAssembly>
12+
</assemblyBinding>
13+
</runtime>
614
</configuration>

SDToolkit/SDToolkit.csproj

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212
<FileAlignment>512</FileAlignment>
1313
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
1414
<Deterministic>true</Deterministic>
15+
<PublishUrl>publish\</PublishUrl>
16+
<Install>true</Install>
17+
<InstallFrom>Disk</InstallFrom>
18+
<UpdateEnabled>false</UpdateEnabled>
19+
<UpdateMode>Foreground</UpdateMode>
20+
<UpdateInterval>7</UpdateInterval>
21+
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
22+
<UpdatePeriodically>false</UpdatePeriodically>
23+
<UpdateRequired>false</UpdateRequired>
24+
<MapFileExtensions>true</MapFileExtensions>
25+
<ApplicationRevision>0</ApplicationRevision>
26+
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
27+
<IsWebBootstrapper>false</IsWebBootstrapper>
28+
<UseApplicationTrust>false</UseApplicationTrust>
29+
<BootstrapperEnabled>true</BootstrapperEnabled>
1530
</PropertyGroup>
1631
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1732
<PlatformTarget>x64</PlatformTarget>
@@ -35,16 +50,53 @@
3550
<PropertyGroup>
3651
<StartupObject>SDToolkit.Program</StartupObject>
3752
</PropertyGroup>
53+
<PropertyGroup>
54+
<ApplicationIcon>ico.ico</ApplicationIcon>
55+
</PropertyGroup>
3856
<ItemGroup>
57+
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
58+
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
59+
</Reference>
60+
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
61+
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
62+
</Reference>
3963
<Reference Include="NvAPIWrapper, Version=0.8.1.100, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
4064
<HintPath>..\packages\NvAPIWrapper.Net.0.8.1.101\lib\net45\NvAPIWrapper.dll</HintPath>
4165
</Reference>
66+
<Reference Include="RestSharp, Version=108.0.2.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
67+
<HintPath>..\packages\RestSharp.108.0.2\lib\netstandard2.0\RestSharp.dll</HintPath>
68+
</Reference>
4269
<Reference Include="System" />
70+
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
71+
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
72+
</Reference>
4373
<Reference Include="System.CodeDom, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
4474
<HintPath>..\packages\System.CodeDom.6.0.0\lib\net461\System.CodeDom.dll</HintPath>
4575
</Reference>
4676
<Reference Include="System.Core" />
4777
<Reference Include="System.Management" />
78+
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
79+
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
80+
</Reference>
81+
<Reference Include="System.Numerics" />
82+
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
83+
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
84+
</Reference>
85+
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
86+
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
87+
</Reference>
88+
<Reference Include="System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
89+
<HintPath>..\packages\System.Text.Encodings.Web.5.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
90+
</Reference>
91+
<Reference Include="System.Text.Json, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
92+
<HintPath>..\packages\System.Text.Json.5.0.0\lib\net461\System.Text.Json.dll</HintPath>
93+
</Reference>
94+
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
95+
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
96+
</Reference>
97+
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
98+
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
99+
</Reference>
48100
<Reference Include="System.Xml.Linq" />
49101
<Reference Include="System.Data.DataSetExtensions" />
50102
<Reference Include="Microsoft.CSharp" />
@@ -56,9 +108,9 @@
56108
<Reference Include="System.Xml" />
57109
</ItemGroup>
58110
<ItemGroup>
59-
<Compile Include="FaceRestoration.cs" />
60-
<Compile Include="Generator.cs" />
61-
<Compile Include="Upscaler.cs" />
111+
<Compile Include="Tools\FaceRestoration.cs" />
112+
<Compile Include="Tools\Generator.cs" />
113+
<Compile Include="Tools\Upscaler.cs" />
62114
<Compile Include="Window.cs">
63115
<SubType>Form</SubType>
64116
</Compile>
@@ -100,5 +152,20 @@
100152
<ItemGroup>
101153
<None Include="Resources\help.png" />
102154
</ItemGroup>
155+
<ItemGroup>
156+
<Content Include="ico.ico" />
157+
</ItemGroup>
158+
<ItemGroup>
159+
<BootstrapperPackage Include=".NETFramework,Version=v4.7.2">
160+
<Visible>False</Visible>
161+
<ProductName>Microsoft .NET Framework 4.7.2 %28x86 and x64%29</ProductName>
162+
<Install>true</Install>
163+
</BootstrapperPackage>
164+
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
165+
<Visible>False</Visible>
166+
<ProductName>.NET Framework 3.5 SP1</ProductName>
167+
<Install>false</Install>
168+
</BootstrapperPackage>
169+
</ItemGroup>
103170
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
104171
</Project>
File renamed without changes.
File renamed without changes.

SDToolkit/Upscaler.cs renamed to SDToolkit/Tools/Upscaler.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,6 @@ namespace SDToolkit
1212
{
1313
class Upscaler
1414
{
15-
private static string GetUpscalingAlgorithm(string algorithm)
16-
{
17-
switch (algorithm)
18-
{
19-
case "RealSR": return "realsr_ncnn_vulkan";
20-
case "SRMD": return "srmd_ncnn_vulkan";
21-
case "Waifu2x": return "waifu2x_ncnn_vulkan";
22-
}
23-
return "realsr_ncnn_vulkan";
24-
}
25-
2615
public static void Upscale(Generator.GeneratorConfig config, string[] images)
2716
{
2817
var outputNames = new string[images.Length];

SDToolkit/Window.Designer.cs

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SDToolkit/Window.cs

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

2+
using Newtonsoft.Json.Linq;
23
using NvAPIWrapper.Display;
4+
using RestSharp;
35
using System;
46
using System.Collections.Generic;
57
using System.ComponentModel;
@@ -13,13 +15,17 @@
1315
using System.Threading;
1416
using System.Threading.Tasks;
1517
using System.Windows.Forms;
18+
using System.Xml.Serialization;
19+
using static SDToolkit.Window;
1620

1721
namespace SDToolkit
1822
{
1923
public partial class Window : Form
2024
{
2125
private uint _vram = 0;
2226
private DateTime _start;
27+
private string _latestVersion;
28+
2329
public Window()
2430
{
2531
InitializeComponent();
@@ -240,9 +246,32 @@ private void SetUpscaleInfo()
240246
upscaleLabel.Text = "Final image resolution after upscaling: " + x + " x " + y + ", upscaler: " + upscaler;
241247
}
242248

249+
public class App
250+
{
251+
public string AppVersion { get; set; }
252+
}
253+
243254
private void Window_Load(object sender, EventArgs e)
244255
{
245256
SetUpscaleInfo();
257+
258+
var app = new App();
259+
var serializer = new XmlSerializer(typeof(App));
260+
using (var reader = new StreamReader("App.xml"))
261+
{
262+
app = (App)serializer.Deserialize(reader);
263+
}
264+
Text = "SDToolkit " + app.AppVersion;
265+
266+
var client = new RestClient("https://api.github.com/repos/SocketByte/SDToolkit/releases");
267+
var request = new RestRequest();
268+
request.AddHeader("Accept", "application/vnd.github+json");
269+
RestResponse response = client.Execute(request);
270+
271+
var releases = JArray.Parse(response.Content);
272+
273+
_latestVersion = releases[0]["tag_name"].ToString().Replace("v", "");
274+
246275
}
247276

248277
private void upscaleCombo_SelectedIndexChanged(object sender, EventArgs e)
@@ -263,10 +292,32 @@ private void resWBox_TextChanged(object sender, EventArgs e)
263292
private void useGFPGAN_CheckedChanged(object sender, EventArgs e)
264293
{
265294
SetUpscaleInfo();
266-
267-
268295
}
269-
}
296+
297+
private void Window_Shown(object sender, EventArgs e)
298+
{
299+
var app = new App();
300+
var serializer = new XmlSerializer(typeof(App));
301+
using (var reader = new StreamReader("App.xml"))
302+
{
303+
app = (App)serializer.Deserialize(reader);
304+
}
305+
if (_latestVersion != app.AppVersion)
306+
{
307+
var result = MessageBox.Show("A new version of SDToolkit is available: " + _latestVersion + ". \nDo you want to download the update now?", "New version available",
308+
MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
270309

310+
if (result.Equals(DialogResult.OK))
311+
{
312+
var process = new Process();
313+
process.StartInfo.FileName = "SDToolkitUpdater.exe";
314+
process.Start();
315+
316+
Environment.Exit(0);
317+
}
318+
}
319+
}
320+
}
321+
271322

272323
}

SDToolkit/Window.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@
120120
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121121
<value>36, 15</value>
122122
</metadata>
123-
<metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
124-
<value>36, 15</value>
125-
</metadata>
126123
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
127124
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
128125
<value>

SDToolkit/ico.ico

16.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)