123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- Imports System.Net
- Imports System.IO
- Public Class Form7
- Dim WithEvents WC As New WebClient
- Dim appPath As String = Application.StartupPath()
- Dim ver As String
- Private IsFormBeingDragged As Boolean = False
- Private MouseDownX As Integer
- Private MouseDownY As Integer
- Dim z As String
- Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
- End Sub
- Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
- ProgressBar1.Value = e.ProgressPercentage
-
- If ProgressBar1.Value = 100 Then
- Threading.Thread.Sleep(50)
- ver = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\download.wtc")
- ver = Replace(ver, vbNewLine, "")
- ver = Replace(ver, vbCrLf, "")
- Label1.Text = "檔案下載完成"
- Threading.Thread.Sleep(1000)
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\" & ver & ".exe") Then
- Shell(appPath & "\system\data\" & ver & ".exe")
- End If
- Threading.Thread.Sleep(1000)
- Try
- If My.Computer.FileSystem.DirectoryExists(appPath & "\" & ver) Then
- My.Computer.FileSystem.CopyDirectory(appPath & "\" & ver, appPath & "\system\minecraft\" & ver)
- Threading.Thread.Sleep(500)
-
- End If
- Catch ex As Exception
- End Try
-
- Timer1.Enabled = True
- Threading.Thread.Sleep(500)
- Dim iCount As Integer
- For iCount = 90 To 10 Step -10
- Me.Opacity = iCount / 100
- Threading.Thread.Sleep(50)
- Next
- Me.Close()
- End If
- End Sub
- Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- For counter = 10 To 90 Step +20
- Me.Opacity = counter / 100
- Me.Refresh()
- Threading.Thread.Sleep(50)
- Next
- Me.Opacity = 100
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\download.wtc") Then
- Try
- Threading.Thread.Sleep(50)
- ver = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\download.wtc")
- ver = Replace(ver, vbNewLine, "")
- ver = Replace(ver, vbCrLf, "")
- If My.Computer.FileSystem.FileExists(appPath & "\system\data\" & ver & ".exe") Then
- My.Computer.FileSystem.DeleteFile(appPath & "\system\data\" & ver & ".exe")
- End If
- Label1.Text = "正在下載檔案…"
- Label3.Text = ver
- WC.DownloadFileAsync(New Uri("http://hkwtc.no-ip.org:8080/hkwtcbs/dreammelody/download/jardownload/" & ver & ".exe"), appPath & "\system\data\" & ver & ".exe")
- Threading.Thread.Sleep(50)
- Timer1.Enabled = True
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End If
- End Sub
- Private Sub Form7_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
- If e.Button = MouseButtons.Left Then
- IsFormBeingDragged = True
- MouseDownX = e.X
- MouseDownY = e.Y
- End If
- End Sub
- Private Sub Form7_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
- If e.Button = MouseButtons.Left Then
- IsFormBeingDragged = False
- End If
- End Sub
- Private Sub Form7_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
- If IsFormBeingDragged Then
- Dim temp As Point = New Point()
- temp.X = Me.Location.X + (e.X - MouseDownX)
- temp.Y = Me.Location.Y + (e.Y - MouseDownY)
- Me.Location = temp
- temp = Nothing
- End If
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Try
- If My.Computer.FileSystem.DirectoryExists(appPath & "\system\minecraft\" & ver) Then
- File.Delete(appPath & "\system\data\download.wtc")
- Do Until My.Computer.FileSystem.DirectoryExists(appPath & "\" & ver) = False
- My.Computer.FileSystem.DeleteDirectory(appPath & "\" & ver, FileIO.DeleteDirectoryOption.DeleteAllContents)
- Loop
- Timer1.Enabled = False
- End If
- Catch ex As Exception
- End Try
- End Sub
- Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
- End Sub
- End Class
|