Skip to content

Commit

Permalink
V 1.5.2 - ViVeTool-GUI now throws an Error instead of crashing if no …
Browse files Browse the repository at this point in the history
…Network is available
  • Loading branch information
PeterStrick committed Mar 11, 2022
1 parent ad8ded6 commit b5bf87a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
53 changes: 49 additions & 4 deletions vivetool-gui/GUI.vb
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,40 @@ Public Class GUI
'Check for Updates
AutoUpdater.Start("https://raw.githubusercontent.com/PeterStrick/ViVeTool-GUI/master/UpdaterXML.xml")

'Populate the Build Combo Box
PopulateBuildComboBox()
'Populate the Build Combo Box, but first check if the PC is connected to the Internet, otherwise the GUI will crash without giving any helpful Information on WHY
PopulateBuildComboBox_Check()
End Sub

''' <summary>
''' Check for Internet Connectivity before trying to populate the Build COmbo Box
''' </summary>
Private Sub PopulateBuildComboBox_Check()
If CheckForInternetConnection() = True Then
'Populate the Build Combo Box
PopulateBuildComboBox()

'Set Ready Label
Invoke(Sub() RLE_StatusLabel.Text = "Ready. Select a build from the Combo Box to get started, or alternatively press F12 to manually change a Feature.")
'Set Ready Label
Invoke(Sub() RLE_StatusLabel.Text = "Ready. Select a build from the Combo Box to get started, or alternatively press F12 to manually change a Feature.")
Else
Invoke(Sub()
'First, disable the Combo Box
RDDL_Build.Enabled = False
RDDL_Build.Text = "Network Error"

'Second, change the Status Label
RLE_StatusLabel.Text = "Network Functions disabled. Press F12 to manually change a Feature."

'Third, Show an error message
Dim RTD As New RadTaskDialogPage With {
.Caption = " A Network Exception occurred",
.Heading = "A Network Exception occurred",
.Text = "ViVeTool-GUI is unable to populate the Build Combo Box, if the Device isn't connected to the Internet, or if the GitHub API is unreachable." & vbNewLine & vbNewLine & "You are still able to manually change a Feature ID by pressing F12.",
.Icon = RadTaskDialogIcon.ShieldWarningYellowBar
}
RTD.CommandAreaButtons.Add(RadTaskDialogButton.Close)
RadTaskDialog.ShowDialog(RTD)
End Sub)
End If
End Sub

''' <summary>
Expand Down Expand Up @@ -620,4 +649,20 @@ Public Class GUI
Private Sub RB_ManuallySetFeature_Click(sender As Object, e As EventArgs) Handles RB_ManuallySetFeature.Click
SetManual.ShowDialog()
End Sub

''' <summary>
''' Basic Internet Connectivity Check by trying to check if github.com is accessible
''' </summary>
''' <returns></returns>
Public Shared Function CheckForInternetConnection() As Boolean
Try
Using client = New WebClient()
Using stream = client.OpenRead("http://www.github.com")
Return True
End Using
End Using
Catch
Return False
End Try
End Function
End Class
4 changes: 2 additions & 2 deletions vivetool-gui/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.5.1.0")>
<Assembly: AssemblyFileVersion("1.5.1.0")>
<Assembly: AssemblyVersion("1.5.2.0")>
<Assembly: AssemblyFileVersion("1.5.2.0")>

0 comments on commit b5bf87a

Please sign in to comment.