-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented update check for mod manager;
- Loading branch information
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
Public Class About | ||
Imports VMM | ||
|
||
Public Class About | ||
|
||
Private WithEvents _update_check As New ModManagerUpdateCheck | ||
|
||
Private Sub _update_check_UpdateAvailable(File As ModuleModBrowser.file_info) Handles _update_check.UpdateAvailable | ||
lbl_update.Visible = True | ||
lbl_update.Text = String.Format("Update {0} is available.", File.Version) | ||
btn_update.Visible = True | ||
End Sub | ||
|
||
Private Sub About_Load(sender As Object, e As EventArgs) Handles MyBase.Load | ||
lbl_version.Text = Version.Current | ||
End Sub | ||
|
||
Private Sub About_Shown(sender As Object, e As EventArgs) Handles MyBase.Shown | ||
lbl_update.Visible = False | ||
btn_update.Visible = False | ||
_update_check.CheckForUpdate() | ||
End Sub | ||
End Class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Imports System.ComponentModel | ||
Imports System.Net | ||
Imports Newtonsoft.Json | ||
|
||
Public Class ModManagerUpdateCheck | ||
|
||
Private WithEvents _check_update As New BackgroundWorker | ||
|
||
Public Event UpdateAvailable(File As ModuleModBrowser.file_info) | ||
|
||
Public Sub CheckForUpdate() | ||
If Not _check_update.IsBusy Then _check_update.RunWorkerAsync() | ||
End Sub | ||
|
||
Private Sub _check_update_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles _check_update.RunWorkerCompleted | ||
Dim file As ModuleModBrowser.file_info = e.Result | ||
RaiseEvent UpdateAvailable(file) | ||
End Sub | ||
|
||
Private Sub _check_update_DoWork(sender As Object, e As DoWorkEventArgs) Handles _check_update.DoWork | ||
Try | ||
Dim client As New WebClient | ||
Dim json As String = client.DownloadString("http://www.vmf.heliohost.org/file_list.php?mode=manager") | ||
Dim files As List(Of ModuleModBrowser.file_info) = JsonConvert.DeserializeObject(Of List(Of ModuleModBrowser.file_info))(json) | ||
Dim file As ModuleModBrowser.file_info = files(files.Count - 1) | ||
If Compare(file.Version, Current) Then | ||
Debug.Print("New version available.") | ||
e.Result = file | ||
End If | ||
Catch ex As Exception | ||
Debug.Print(ex.Message) | ||
End Try | ||
End Sub | ||
|
||
End Class |