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+
}

0 commit comments

Comments
 (0)
Please sign in to comment.