Form7.vb 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. Imports System.Net
  2. Imports System.IO
  3. Public Class Form7
  4. Dim WithEvents WC As New WebClient
  5. Dim appPath As String = Application.StartupPath()
  6. Dim ver As String
  7. Private IsFormBeingDragged As Boolean = False
  8. Private MouseDownX As Integer
  9. Private MouseDownY As Integer
  10. Dim z As String
  11. Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
  12. End Sub
  13. Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
  14. ProgressBar1.Value = e.ProgressPercentage
  15. If ProgressBar1.Value = 100 Then
  16. Threading.Thread.Sleep(50)
  17. ver = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\download.wtc")
  18. ver = Replace(ver, vbNewLine, "")
  19. ver = Replace(ver, vbCrLf, "")
  20. Label1.Text = "檔案下載完成"
  21. Threading.Thread.Sleep(1000)
  22. If My.Computer.FileSystem.FileExists(appPath & "\system\data\" & ver & ".exe") Then
  23. Shell(appPath & "\system\data\" & ver & ".exe")
  24. End If
  25. Threading.Thread.Sleep(1000)
  26. Try
  27. If My.Computer.FileSystem.DirectoryExists(appPath & "\" & ver) Then
  28. My.Computer.FileSystem.CopyDirectory(appPath & "\" & ver, appPath & "\system\minecraft\" & ver)
  29. Threading.Thread.Sleep(500)
  30. End If
  31. Catch ex As Exception
  32. End Try
  33. Timer1.Enabled = True
  34. Threading.Thread.Sleep(500)
  35. Dim iCount As Integer
  36. For iCount = 90 To 10 Step -10
  37. Me.Opacity = iCount / 100
  38. Threading.Thread.Sleep(50)
  39. Next
  40. Me.Close()
  41. End If
  42. End Sub
  43. Private Sub Form7_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  44. For counter = 10 To 90 Step +20
  45. Me.Opacity = counter / 100
  46. Me.Refresh()
  47. Threading.Thread.Sleep(50)
  48. Next
  49. Me.Opacity = 100
  50. If My.Computer.FileSystem.FileExists(appPath & "\system\data\download.wtc") Then
  51. Try
  52. Threading.Thread.Sleep(50)
  53. ver = My.Computer.FileSystem.ReadAllText(appPath & "\system\data\download.wtc")
  54. ver = Replace(ver, vbNewLine, "")
  55. ver = Replace(ver, vbCrLf, "")
  56. If My.Computer.FileSystem.FileExists(appPath & "\system\data\" & ver & ".exe") Then
  57. My.Computer.FileSystem.DeleteFile(appPath & "\system\data\" & ver & ".exe")
  58. End If
  59. Label1.Text = "正在下載檔案…"
  60. Label3.Text = ver
  61. WC.DownloadFileAsync(New Uri("http://hkwtc.no-ip.org:8080/hkwtcbs/dreammelody/download/jardownload/" & ver & ".exe"), appPath & "\system\data\" & ver & ".exe")
  62. Threading.Thread.Sleep(50)
  63. Timer1.Enabled = True
  64. Catch ex As Exception
  65. MsgBox(ex.Message)
  66. End Try
  67. End If
  68. End Sub
  69. Private Sub Form7_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
  70. If e.Button = MouseButtons.Left Then
  71. IsFormBeingDragged = True
  72. MouseDownX = e.X
  73. MouseDownY = e.Y
  74. End If
  75. End Sub
  76. Private Sub Form7_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
  77. If e.Button = MouseButtons.Left Then
  78. IsFormBeingDragged = False
  79. End If
  80. End Sub
  81. Private Sub Form7_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
  82. If IsFormBeingDragged Then
  83. Dim temp As Point = New Point()
  84. temp.X = Me.Location.X + (e.X - MouseDownX)
  85. temp.Y = Me.Location.Y + (e.Y - MouseDownY)
  86. Me.Location = temp
  87. temp = Nothing
  88. End If
  89. End Sub
  90. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
  91. Try
  92. If My.Computer.FileSystem.DirectoryExists(appPath & "\system\minecraft\" & ver) Then
  93. File.Delete(appPath & "\system\data\download.wtc")
  94. Do Until My.Computer.FileSystem.DirectoryExists(appPath & "\" & ver) = False
  95. My.Computer.FileSystem.DeleteDirectory(appPath & "\" & ver, FileIO.DeleteDirectoryOption.DeleteAllContents)
  96. Loop
  97. Timer1.Enabled = False
  98. End If
  99. Catch ex As Exception
  100. End Try
  101. End Sub
  102. Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
  103. End Sub
  104. End Class