-
Notifications
You must be signed in to change notification settings - Fork 86
/
Copy pathForm1.cs
61 lines (54 loc) · 2.17 KB
/
Form1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using System;
using System.Drawing;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using NetSparkleUpdater;
using NetSparkleUpdater.Enums;
using NetSparkleUpdater.SignatureVerifiers;
namespace NetSparkleUpdater.Samples.NetCore.WinForms
{
public partial class Form1 : Form
{
private SparkleUpdater _sparkleUpdateDetector;
public Form1()
{
InitializeComponent();
var appcastUrl = "https://netsparkleupdater.github.io/NetSparkle/files/sample-app/appcast.xml";
// set icon in project properties!
string manifestModuleName = System.Reflection.Assembly.GetEntryAssembly().ManifestModule.FullyQualifiedName;
var icon = System.Drawing.Icon.ExtractAssociatedIcon(manifestModuleName);
_sparkleUpdateDetector = new SparkleUpdater(appcastUrl, new DSAChecker(Enums.SecurityMode.Strict))
{
UIFactory = new NetSparkleUpdater.UI.WinForms.UIFactory(icon),
//RelaunchAfterUpdate = true,
//ShowsUIOnMainThread = true,
//UseNotificationToast = true
};
//_sparkleUpdateDetector.CloseApplication += _sparkleUpdateDetector_CloseApplication;
StartSparkle();
}
private async void StartSparkle()
{
await _sparkleUpdateDetector.StartLoop(true, true);
}
private void _sparkleUpdateDetector_CloseApplication()
{
Application.Exit();
}
private async void AppBackgroundCheckButton_Click(object sender, EventArgs e)
{
// Manually check for updates, this will not show a ui
var result = await _sparkleUpdateDetector.CheckForUpdatesQuietly();
if (result.Status == UpdateStatus.UpdateAvailable)
{
// if update(s) are found, then we have to trigger the UI to show it gracefully
_sparkleUpdateDetector.ShowUpdateNeededUI();
}
}
private async void ExplicitUserRequestCheckButton_Click(object sender, EventArgs e)
{
await _sparkleUpdateDetector.CheckForUpdatesAtUserRequest();
}
}
}