22Imports System.IO
33Imports System.Net
44Imports System.Text
5- Imports System.Text.RegularExpressions
65Imports DiskImageTool.DiskImage
76Imports BootSectorOffsets = DiskImageTool.DiskImage.BootSector.BootSectorOffsets
87Imports BootSectorSizes = DiskImageTool.DiskImage.BootSector.BootSectorSizes
@@ -444,9 +443,8 @@ Public Class MainForm
444443 Private Sub CheckForUpdates()
445444 Dim DownloadVersion As String = ""
446445 Dim DownloadURL As String = ""
446+ Dim Body As String = ""
447447 Dim UpdateAvailable As Boolean = False
448- Dim Regex As Regex
449- Dim Match As Match
450448
451449 Cursor.Current = Cursors.WaitCursor
452450 Try
@@ -456,21 +454,27 @@ Public Class MainForm
456454 Dim Reader As New StreamReader(Response.GetResponseStream)
457455 Dim ResponseText = Reader.ReadToEnd
458456
459- Regex = New Regex( """tag_name"":""v(\d+\.\d+(?:\.\d+)?(?:\.\d+)?)""" )
460- Match = Regex.Match(ResponseText)
461- If Match.Success Then
462- If Match.Groups.Count > 1 Then
463- DownloadVersion = Match.Groups.Item( 1 ).Value
457+ Dim json As Dictionary( Of String , Object ) = CompactJson.Serializer.Parse( Of Dictionary( Of String , Object ))(ResponseText)
458+
459+ If json.ContainsKey( "tag_name" ) Then
460+ DownloadVersion = json.Item( "tag_name" ).ToString
461+ If DownloadVersion.StartsWith( "v" , StringComparison.CurrentCultureIgnoreCase) Then
462+ DownloadVersion = DownloadVersion.Remove( 0 , 1 )
464463 End If
465464 End If
466465
467- Regex = New Regex( """browser_download_url"":""([^""]+)""" )
468- Match = Regex.Match(ResponseText)
469- If Match.Success Then
470- If Match.Groups.Count > 1 Then
471- DownloadURL = Match.Groups.Item( 1 ).Value
466+ If json.ContainsKey( "assets" ) Then
467+ Dim assets() As Dictionary( Of String , Object ) = CompactJson.Serializer.Parse( Of Dictionary( Of String , Object )())(json.Item( "assets" ).ToString)
468+ If assets.Length > 0 Then
469+ If assets( 0 ).ContainsKey( "browser_download_url" ) Then
470+ DownloadURL = assets( 0 ).Item( "browser_download_url" ).ToString
471+ End If
472472 End If
473473 End If
474+
475+ If json.ContainsKey( "body" ) Then
476+ Body = json.Item( "body" ).ToString
477+ End If
474478 Catch
475479 MsgBox( "An error occured while checking for updates. Please try again later." , MsgBoxStyle.Exclamation)
476480 Exit Sub
@@ -482,11 +486,17 @@ Public Class MainForm
482486 End If
483487
484488 If UpdateAvailable Then
485- Dim Msg = "A New version Of " & My.Application.Info.Title & " Is available." & vbCrLf & vbCrLf & "Do you wish to download it at this time?"
489+ Dim Msg = My.Application.Info.Title & " v" & DownloadVersion & " Is available."
490+ If Body <> "" Then
491+ Msg = Msg & vbCrLf & vbCrLf & "Whats New" & vbCrLf & New String ( "—" , 6 ) & vbCrLf & Body & vbCrLf
492+ End If
493+ Msg = Msg & vbCrLf & vbCrLf & "Do you wish to download it at this time?"
486494 If MsgBox(Msg, MsgBoxStyle.Question + MsgBoxStyle.YesNo + MsgBoxStyle.DefaultButton2) = MsgBoxResult.Yes Then
487495 Dim Dialog As New SaveFileDialog With {
488496 .Filter = "Zip Archive|*.zip" ,
489- .FileName = Path.GetFileName(DownloadURL)
497+ .FileName = Path.GetFileName(DownloadURL),
498+ .InitialDirectory = GetDownloadsFolder(),
499+ .RestoreDirectory = True
490500 }
491501 Dialog.ShowDialog()
492502 If Dialog.FileName <> "" Then
0 commit comments