Skip to content

Commit 5da3c1a

Browse files
committedFeb 18, 2020
Add .NET Core WinForms sample
1 parent 0f0465a commit 5da3c1a

9 files changed

+560
-0
lines changed
 

‎NetSparkle.sln

+22
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetSparkle.UI.WPF", "src\Ne
2828
EndProject
2929
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetSparkle.Samples.NetCore.WPF", "src\NetSparkle.Samples.NetCore.WPF\NetSparkle.Samples.NetCore.WPF.csproj", "{4DD4076B-C086-4A11-B850-898CC9991D90}"
3030
EndProject
31+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetSparkle.Samples.NetCore.WinForms", "src\NetSparkle.Samples.NetCore.WinForms\NetSparkle.Samples.NetCore.WinForms.csproj", "{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}"
32+
EndProject
3133
Global
3234
GlobalSection(SharedMSBuildProjectFiles) = preSolution
3335
NetSparkleUtilities\NetSparkleUtilities.projitems*{74635a21-2bad-4522-ab95-e3e5703cd301}*SharedItemsImports = 4
@@ -239,6 +241,26 @@ Global
239241
{4DD4076B-C086-4A11-B850-898CC9991D90}.Release|x64.Build.0 = Release|Any CPU
240242
{4DD4076B-C086-4A11-B850-898CC9991D90}.Release|x86.ActiveCfg = Release|Any CPU
241243
{4DD4076B-C086-4A11-B850-898CC9991D90}.Release|x86.Build.0 = Release|Any CPU
244+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
245+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|Any CPU.Build.0 = Debug|Any CPU
246+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|ARM.ActiveCfg = Debug|Any CPU
247+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|ARM.Build.0 = Debug|Any CPU
248+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
249+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
250+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|x64.ActiveCfg = Debug|Any CPU
251+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|x64.Build.0 = Debug|Any CPU
252+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|x86.ActiveCfg = Debug|Any CPU
253+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Debug|x86.Build.0 = Debug|Any CPU
254+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|Any CPU.ActiveCfg = Release|Any CPU
255+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|Any CPU.Build.0 = Release|Any CPU
256+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|ARM.ActiveCfg = Release|Any CPU
257+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|ARM.Build.0 = Release|Any CPU
258+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
259+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|Mixed Platforms.Build.0 = Release|Any CPU
260+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|x64.ActiveCfg = Release|Any CPU
261+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|x64.Build.0 = Release|Any CPU
262+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|x86.ActiveCfg = Release|Any CPU
263+
{0088BDC7-D50B-4AD4-8EE6-D2B7DA150778}.Release|x86.Build.0 = Release|Any CPU
242264
EndGlobalSection
243265
GlobalSection(SolutionProperties) = preSolution
244266
HideSolutionNode = FALSE

‎src/NetSparkle.Samples.NetCore.WinForms/Form1.Designer.cs

+93
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Drawing;
3+
using System.IO;
4+
using System.Reflection;
5+
using System.Windows.Forms;
6+
using NetSparkle;
7+
using NetSparkle.Enums;
8+
9+
namespace SampleApplication
10+
{
11+
public partial class Form1 : Form
12+
{
13+
private Sparkle _sparkleUpdateDetector;
14+
15+
public Form1()
16+
{
17+
InitializeComponent();
18+
19+
var appcastUrl = "https://deadpikle.github.io/NetSparkle/files/sample-app/appcast.xml";
20+
// set icon in project properties!
21+
string manifestModuleName = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.FullyQualifiedName;
22+
var icon = System.Drawing.Icon.ExtractAssociatedIcon(manifestModuleName);
23+
_sparkleUpdateDetector = new Sparkle(appcastUrl, icon)
24+
{
25+
UIFactory = new NetSparkle.UI.WinForms.UIFactory(),
26+
//ShowsUIOnMainThread = true,
27+
//UseNotificationToast = true
28+
};
29+
// TLS 1.2 required by GitHub (https://developer.github.com/changes/2018-02-01-weak-crypto-removal-notice/)
30+
_sparkleUpdateDetector.SecurityProtocolType = System.Net.SecurityProtocolType.Tls12;
31+
//_sparkleUpdateDetector.CloseApplication += _sparkleUpdateDetector_CloseApplication;
32+
_sparkleUpdateDetector.StartLoop(true, true);
33+
}
34+
35+
private void _sparkleUpdateDetector_CloseApplication()
36+
{
37+
Application.Exit();
38+
}
39+
40+
private async void AppBackgroundCheckButton_Click(object sender, EventArgs e)
41+
{
42+
// Manually check for updates, this will not show a ui
43+
var result = await _sparkleUpdateDetector.CheckForUpdatesQuietly();
44+
if (result.Status == UpdateStatus.UpdateAvailable)
45+
{
46+
// if update(s) are found, then we have to trigger the UI to show it gracefully
47+
_sparkleUpdateDetector.ShowUpdateNeededUI();
48+
}
49+
50+
}
51+
52+
private void ExplicitUserRequestCheckButton_Click(object sender, EventArgs e)
53+
{
54+
_sparkleUpdateDetector.CheckForUpdatesAtUserRequest();
55+
}
56+
}
57+
}

‎src/NetSparkle.Samples.NetCore.WinForms/Form1.resx

+312
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<UseWindowsForms>true</UseWindowsForms>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<None Remove="NetSparkle_DSA.pub" />
11+
<None Remove="software-update-available.ico" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<Content Include="software-update-available.ico" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<EmbeddedResource Include="NetSparkle_DSA.pub" />
20+
</ItemGroup>
21+
22+
<ItemGroup>
23+
<ProjectReference Include="..\NetSparkle.UI.WinForms\NetSparkle.UI.WinForms.csproj" />
24+
<ProjectReference Include="..\NetSparkle\NetSparkle.csproj" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<Compile Update="Form1.cs">
29+
<SubType>Form</SubType>
30+
</Compile>
31+
<Compile Update="Form1.Designer.cs">
32+
<DependentUpon>Form1.cs</DependentUpon>
33+
</Compile>
34+
</ItemGroup>
35+
36+
<ItemGroup>
37+
<EmbeddedResource Update="Form1.resx">
38+
<DependentUpon>Form1.cs</DependentUpon>
39+
</EmbeddedResource>
40+
</ItemGroup>
41+
42+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup />
4+
<ItemGroup>
5+
<Compile Update="Form1.cs">
6+
<SubType>Form</SubType>
7+
</Compile>
8+
</ItemGroup>
9+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<DSAKeyValue><P>2IX45gCGAGjNXBg3/spd03M2oMsmghmul/H5ePY9AN9URjAOYUcwfi3kQ/KM8i2eD1V/cBKkMJX4xx3kpt39n2Vt+7tyWfXjzMb+3qPapPHMMJL5DDS9cw6FgG3H0tT/LSm7Qn7JLA6w8FOiVIjC+x61u5WqFK0I0vFnc8T1YZs=</P><Q>xXaw/HrlbsRqg7WD5g1xlkVblys=</Q><G>P2bv3DOTGnyjVnDC5j6Pwd4U6VtRzhPsww9COnwlRWmyNFcf0F/3H5S9YJrO7P+CgIvef30eqUYPHUauLbZ2UK0rItwepz45SfysLvVUb6PU6z/j7gEYiGO/lKd13GfhxmL1mS+XasDSw5brRMxePidiom8H/AB7VVQgELcgutQ=</G><Y>mxJD6rwuJe532PpS9HKjlhvcY1ssBEOFf3HmiYot4d670y0+5nICF3YO8vLxndHA4RqgU/Hux9KtKKg/2hi7c/88j5YyTDWX86n8aPIxHWklKsreP24ul87uuktfhDlhltpfd8AlXxn2SpxQ1Fy/Ktid3E1+uDb64HKf9a35CwE=</Y><Seed>q/C5yP0VC0Y0ZUPzSD5+O5Rt5X8=</Seed><PgenCounter>sg==</PgenCounter></DSAKeyValue>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using SampleApplication;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using System.Windows.Forms;
7+
8+
namespace NetSparkle.Samples.NetCore.WinForms
9+
{
10+
static class Program
11+
{
12+
/// <summary>
13+
/// The main entry point for the application.
14+
/// </summary>
15+
[STAThread]
16+
static void Main()
17+
{
18+
Application.SetHighDpiMode(HighDpiMode.SystemAware);
19+
Application.EnableVisualStyles();
20+
Application.SetCompatibleTextRenderingDefault(false);
21+
Application.Run(new Form1());
22+
}
23+
}
24+
}
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.