Skip to content

Commit b5bf87a

Browse files
committed
V 1.5.2 - ViVeTool-GUI now throws an Error instead of crashing if no Network is available
1 parent ad8ded6 commit b5bf87a

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

vivetool-gui/GUI.vb

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,40 @@ Public Class GUI
119119
'Check for Updates
120120
AutoUpdater.Start("https://raw.githubusercontent.com/PeterStrick/ViVeTool-GUI/master/UpdaterXML.xml")
121121

122-
'Populate the Build Combo Box
123-
PopulateBuildComboBox()
122+
'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
123+
PopulateBuildComboBox_Check()
124+
End Sub
125+
126+
''' <summary>
127+
''' Check for Internet Connectivity before trying to populate the Build COmbo Box
128+
''' </summary>
129+
Private Sub PopulateBuildComboBox_Check()
130+
If CheckForInternetConnection() = True Then
131+
'Populate the Build Combo Box
132+
PopulateBuildComboBox()
124133

125-
'Set Ready Label
126-
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.")
134+
'Set Ready Label
135+
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.")
136+
Else
137+
Invoke(Sub()
138+
'First, disable the Combo Box
139+
RDDL_Build.Enabled = False
140+
RDDL_Build.Text = "Network Error"
141+
142+
'Second, change the Status Label
143+
RLE_StatusLabel.Text = "Network Functions disabled. Press F12 to manually change a Feature."
144+
145+
'Third, Show an error message
146+
Dim RTD As New RadTaskDialogPage With {
147+
.Caption = " A Network Exception occurred",
148+
.Heading = "A Network Exception occurred",
149+
.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.",
150+
.Icon = RadTaskDialogIcon.ShieldWarningYellowBar
151+
}
152+
RTD.CommandAreaButtons.Add(RadTaskDialogButton.Close)
153+
RadTaskDialog.ShowDialog(RTD)
154+
End Sub)
155+
End If
127156
End Sub
128157

129158
''' <summary>
@@ -620,4 +649,20 @@ Public Class GUI
620649
Private Sub RB_ManuallySetFeature_Click(sender As Object, e As EventArgs) Handles RB_ManuallySetFeature.Click
621650
SetManual.ShowDialog()
622651
End Sub
652+
653+
''' <summary>
654+
''' Basic Internet Connectivity Check by trying to check if github.com is accessible
655+
''' </summary>
656+
''' <returns></returns>
657+
Public Shared Function CheckForInternetConnection() As Boolean
658+
Try
659+
Using client = New WebClient()
660+
Using stream = client.OpenRead("http://www.github.com")
661+
Return True
662+
End Using
663+
End Using
664+
Catch
665+
Return False
666+
End Try
667+
End Function
623668
End Class

vivetool-gui/My Project/AssemblyInfo.vb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
3131
' by using the '*' as shown below:
3232
' <Assembly: AssemblyVersion("1.0.*")>
3333

34-
<Assembly: AssemblyVersion("1.5.1.0")>
35-
<Assembly: AssemblyFileVersion("1.5.1.0")>
34+
<Assembly: AssemblyVersion("1.5.2.0")>
35+
<Assembly: AssemblyFileVersion("1.5.2.0")>

0 commit comments

Comments
 (0)