@@ -8,6 +8,7 @@ public static class UpdateMan
8
8
private static string _githubOwner ;
9
9
private static string _githubRepo ;
10
10
private static string _exeName ;
11
+ private static bool _darkMode ;
11
12
12
13
private static string _title ;
13
14
private static string _message ;
@@ -20,18 +21,16 @@ public static class UpdateMan
20
21
private static string _failed ;
21
22
private static string _install ;
22
23
23
- private static string _isUpToDate ;
24
-
25
- public static void Init ( string githubOwner , string githubRepo , string exeName )
24
+ public static void Init ( string githubOwner , string githubRepo , string exeName , bool darkMode )
26
25
{
27
26
_githubOwner = githubOwner ;
28
27
_githubRepo = githubRepo ;
29
28
_exeName = exeName ;
29
+ _darkMode = darkMode ;
30
30
}
31
31
32
32
public static void InitLang ( string title , string message , string dwnldBtnText , string whatsNewBtnText ,
33
- string updating , string downloading , string readyToInstall , string failed , string install ,
34
- string isUpToDate )
33
+ string updating , string downloading , string readyToInstall , string failed , string install )
35
34
{
36
35
_title = title ;
37
36
_message = message ;
@@ -43,11 +42,9 @@ public static void InitLang(string title, string message, string dwnldBtnText, s
43
42
_readyToInstall = readyToInstall ;
44
43
_failed = failed ;
45
44
_install = install ;
46
-
47
- _isUpToDate = isUpToDate ;
48
45
}
49
46
50
- public static async void CheckForUpdates ( bool showUpToDateDialog , bool topMost , bool darkMode , IntPtr owner )
47
+ public static async void CheckForUpdates ( bool showUpToDateDialog , bool topMost , IntPtr owner )
51
48
{
52
49
try
53
50
{
@@ -58,18 +55,18 @@ public static async void CheckForUpdates(bool showUpToDateDialog, bool topMost,
58
55
{
59
56
if ( showUpToDateDialog )
60
57
{
61
- DialogMan . ShowInfo ( _isUpToDate , darkMode : darkMode ) ;
58
+ OnIsUpToDate ( EventArgs . Empty ) ;
62
59
}
63
60
}
64
61
else
65
62
{
66
- UpdateForm updateDialog = new UpdateForm ( darkMode , _title , _message , _dwnldBtnText , _whatsNewBtnText ) ;
63
+ UpdateForm updateDialog = new UpdateForm ( _darkMode , _title , _message , _dwnldBtnText , _whatsNewBtnText ) ;
67
64
updateDialog . TopMost = topMost ;
68
65
69
66
DialogResult result = updateDialog . ShowDialog ( Form . FromHandle ( owner ) ) ;
70
67
if ( result == DialogResult . Yes )
71
68
{
72
- DownloadForm downloadBox = new DownloadForm ( UpdateChecker . GetAssetUrl ( _exeName ) , darkMode , _updating , _downloading , _readyToInstall , _failed , _install ) ;
69
+ DownloadForm downloadBox = new DownloadForm ( UpdateChecker . GetAssetUrl ( _exeName ) , _darkMode , _updating , _downloading , _readyToInstall , _failed , _install ) ;
73
70
downloadBox . TopMost = topMost ;
74
71
downloadBox . ShowDialog ( Form . FromHandle ( owner ) ) ;
75
72
}
@@ -83,9 +80,21 @@ public static async void CheckForUpdates(bool showUpToDateDialog, bool topMost,
83
80
{
84
81
if ( showUpToDateDialog )
85
82
{
86
- DialogMan . ShowInfo ( _failed , darkMode : darkMode ) ;
83
+ OnUpdateFailed ( EventArgs . Empty ) ;
87
84
}
88
85
}
89
86
}
87
+
88
+ public static void OnUpdateFailed ( EventArgs ea )
89
+ {
90
+ UpdateFailed ? . Invoke ( null , ea ) ;
91
+ }
92
+ public static event EventHandler < EventArgs > UpdateFailed ;
93
+
94
+ public static void OnIsUpToDate ( EventArgs ea )
95
+ {
96
+ IsUpToDate ? . Invoke ( null , ea ) ;
97
+ }
98
+ public static event EventHandler < EventArgs > IsUpToDate ;
90
99
}
91
100
}
0 commit comments