summaryrefslogtreecommitdiffstats
path: root/win/Handbrake/frmUpdate.vb
blob: 23d85534d9887b4359b015e8c624a0009c2ad8c3 (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
52
53
54
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 Then
                lbl_update.Visible = True
            ElseIf windowsCLI <> My.Settings.HandbrakeCLIVersion Then
                lbl_update.Visible = True
            End If


        Catch ex As Exception
            ' Handdle any errors that may occur
            MessageBox.Show("ERROR: Unable to check for updates. The server may be unavailible at the moment. Please try again later!")
            MessageBox.Show(ex.ToString) ' Debug output
        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