summaryrefslogtreecommitdiffstats
path: root/win/Handbrake/frmUpdate.vb
blob: bc74c9d36e888390fb97cb87787a53e3d6f1ce0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Imports System.IO

Public Class frmUpdate

    Private Sub frmUpdate_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Settings.StartupUpdate = 1 Then
            lbl_startupStatus.Text = "On"
        Else
            lbl_startupStatus.Text = "Off"
        End If

        Version.Text = My.Settings.HandbrakeGUIVersion
        cliVersion.Text = My.Settings.HandbrakeCLIVersion
    End Sub

    Private Sub Dest_browse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dest_browse.Click
        Dim file_path As String = Application.StartupPath
        Try
            ' Download the update file
            ' open the file for reading and read the first 2 lines for GUI and CLI versions
            Dim wc As New System.Net.WebClient()
            wc.DownloadFile("http://download.m0k.org/handbrake/windows/update.txt", file_path & "\update.txt")
            wc.Dispose()
            Dim versionStream As StreamReader = File.OpenText(file_path & "\update.txt")
            Dim windowsGUI As String = versionStream.ReadLine()
            Dim windowsCLI As String = versionStream.ReadLine()
            versionStream.Close()

            ' Set the Latest Text label to the first line of the file
            lbl_latest.Text = windowsGUI
            lbl_encoderVersion.Text = windowsCLI

            ' If the version is now the same as the one shown here, Display the update label
            If (windowsGUI <> My.Settings.HandbrakeGUIVersion Or windowsCLI <> My.Settings.HandbrakeCLIVersion) Then
                MessageBox.Show("A new version is available. Please visit the project website to download the update.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
            End If


        Catch ex As Exception
            ' Handdle any errors that may occur
            MessageBox.Show("Unable to check for updates. The server may be unavailible at the moment. Please try again later!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand)
        End Try


    End Sub

    Private Sub btn_close_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_close.Click
        Me.Close()
    End Sub

End Class