-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.Updates.cs
More file actions
67 lines (60 loc) · 2.11 KB
/
Main.Updates.cs
File metadata and controls
67 lines (60 loc) · 2.11 KB
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
62
63
64
65
using BeanModManager.Services;
using System;
using System.Diagnostics;
using System.Windows.Forms;
namespace BeanModManager
{
public partial class Main : Form
{
private void HandleUpdateCheckerProgress(string message)
{
if (_isInitialLoadInProgress)
return;
UpdateStatus(message);
}
private async System.Threading.Tasks.Task CheckForAppUpdatesAsync()
{
try
{
await _updateChecker.CheckForUpdatesAsync().ConfigureAwait(false);
}
catch
{
}
}
private void UpdateChecker_UpdateAvailable(object sender, UpdateChecker.UpdateAvailableEventArgs e)
{
SafeInvoke(() =>
{
var result = MessageBox.Show(
$"A new version of Bean Mod Manager is available!\n\n" +
$"Current version: {e.CurrentVersion}\n" +
$"Latest version: {e.LatestVersion}\n\n" +
$"{(!string.IsNullOrEmpty(e.ReleaseNotes) ? $"Release notes:\n{e.ReleaseNotes.Substring(0, Math.Min(200, e.ReleaseNotes.Length))}...\n\n" : "")}" +
$"Would you like to open the download page?",
"Update Available",
MessageBoxButtons.YesNo,
MessageBoxIcon.Information);
if (result == DialogResult.Yes)
{
try
{
Process.Start(new ProcessStartInfo
{
FileName = e.ReleaseUrl,
UseShellExecute = true
});
}
catch
{
MessageBox.Show(
$"Failed to open the download page.\n\nPlease visit: {e.ReleaseUrl}",
"Error",
MessageBoxButtons.OK,
MessageBoxIcon.Warning);
}
}
});
}
}
}