add automatic in-app-updater

This commit is contained in:
2023-08-26 21:40:15 +02:00
parent 0e9667ab59
commit 0776611de4
4 changed files with 120 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ Imports System.IO
Imports ModpackUpdater.My.Resources
Imports Telerik.WinControls
Imports Telerik.WinControls.UI
Public Class Form1
@@ -19,7 +20,7 @@ Public Class Form1
Return Not String.IsNullOrEmpty(GetMinecraftProfilePath)
End Function
Private Function GetMinecraftProfilePath() As string
Private Function GetMinecraftProfilePath() As String
Return RadTextBoxControl_MinecraftProfileFolder.Text.Trim
End Function
@@ -27,7 +28,7 @@ Public Class Form1
Return Not String.IsNullOrEmpty(GetUpdateconfigPath)
End Function
Private Function GetUpdateconfigPath() As string
Private Function GetUpdateconfigPath() As String
Return RadTextBoxControl_ModpackConfig.Text.Trim
End Function
@@ -43,7 +44,7 @@ Public Class Form1
End If
End Function
Private Sub SetStatus(statusText As string, image As Image)
Private Sub SetStatus(statusText As String, image As Image)
RadLabel_Status.Text = statusText
RadLabel_Status.Image = image
End Sub
@@ -53,7 +54,7 @@ Public Class Form1
RadLabel_Status.Image = Nothing
End Sub
Private Sub LoadMinecraftProfile(folderPath As string)
Private Sub LoadMinecraftProfile(folderPath As String)
RadTextBoxControl_MinecraftProfileFolder.Text = folderPath
If IsUpdateConfigLoaded() Then
@@ -63,7 +64,7 @@ Public Class Form1
End If
End Sub
Private Sub LoadUpdateConfigFile(filePath As string)
Private Sub LoadUpdateConfigFile(filePath As String)
RadTextBoxControl_ModpackConfig.Text = filePath
If IsUpdateConfigLoaded() Then
@@ -183,4 +184,12 @@ Public Class Form1
End If
End Sub
Private Async Sub Form1_Shown(sender As Object, e As EventArgs) Handles Me.Shown
If Await AppUpdater.Check AndAlso RadMessageBox.Show(LangRes.MsgBox_UpdateAvailable, LangRes.MsgBox_UpdateAvailable_Title, MessageBoxButtons.YesNo, RadMessageIcon.Info) = DialogResult.Yes Then
SetStatus(LangRes.StatusText_InstallingAppUpdate, MySymbols.icons8_software_installer_16px)
Enabled = False
Await AppUpdater.Install()
Application.Restart()
End If
End Sub
End Class