@@ -8,6 +8,7 @@ public static class UpdateMan
88 private static string _githubOwner ;
99 private static string _githubRepo ;
1010 private static string _exeName ;
11+ private static bool _darkMode ;
1112
1213 private static string _title ;
1314 private static string _message ;
@@ -20,18 +21,16 @@ public static class UpdateMan
2021 private static string _failed ;
2122 private static string _install ;
2223
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 )
2625 {
2726 _githubOwner = githubOwner ;
2827 _githubRepo = githubRepo ;
2928 _exeName = exeName ;
29+ _darkMode = darkMode ;
3030 }
3131
3232 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 )
3534 {
3635 _title = title ;
3736 _message = message ;
@@ -43,11 +42,9 @@ public static void InitLang(string title, string message, string dwnldBtnText, s
4342 _readyToInstall = readyToInstall ;
4443 _failed = failed ;
4544 _install = install ;
46-
47- _isUpToDate = isUpToDate ;
4845 }
4946
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 )
5148 {
5249 try
5350 {
@@ -58,18 +55,18 @@ public static async void CheckForUpdates(bool showUpToDateDialog, bool topMost,
5855 {
5956 if ( showUpToDateDialog )
6057 {
61- DialogMan . ShowInfo ( _isUpToDate , darkMode : darkMode ) ;
58+ OnIsUpToDate ( EventArgs . Empty ) ;
6259 }
6360 }
6461 else
6562 {
66- UpdateForm updateDialog = new UpdateForm ( darkMode , _title , _message , _dwnldBtnText , _whatsNewBtnText ) ;
63+ UpdateForm updateDialog = new UpdateForm ( _darkMode , _title , _message , _dwnldBtnText , _whatsNewBtnText ) ;
6764 updateDialog . TopMost = topMost ;
6865
6966 DialogResult result = updateDialog . ShowDialog ( Form . FromHandle ( owner ) ) ;
7067 if ( result == DialogResult . Yes )
7168 {
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 ) ;
7370 downloadBox . TopMost = topMost ;
7471 downloadBox . ShowDialog ( Form . FromHandle ( owner ) ) ;
7572 }
@@ -83,9 +80,21 @@ public static async void CheckForUpdates(bool showUpToDateDialog, bool topMost,
8380 {
8481 if ( showUpToDateDialog )
8582 {
86- DialogMan . ShowInfo ( _failed , darkMode : darkMode ) ;
83+ OnUpdateFailed ( EventArgs . Empty ) ;
8784 }
8885 }
8986 }
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 ;
9099 }
91100}
0 commit comments