Form4.vb 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. Imports System.Net
  2. Public Class Form4
  3. Dim WithEvents WC As New WebClient
  4. Dim appPath As String = Application.StartupPath()
  5. Private IsFormBeingDragged As Boolean = False
  6. Private MouseDownX As Integer
  7. Private MouseDownY As Integer
  8. Dim z As String
  9. Private Sub Form4_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  10. For counter = 10 To 90 Step +20
  11. Me.Opacity = counter / 100
  12. Me.Refresh()
  13. Threading.Thread.Sleep(50)
  14. Next
  15. Me.Opacity = 100
  16. Try
  17. Label1.Text = "便攜版 Java下載進行中…"
  18. WC.DownloadFileAsync(New Uri("http://hkwtc.no-ip.org:8080/hkwtcbs/DreamMelody/Download/java.exe"), appPath & "\system\java.exe")
  19. Catch ex As Exception
  20. Label1.Text = ex.Message
  21. End Try
  22. End Sub
  23. Private Sub WC_DownloadProgressChanged(ByVal sender As Object, ByVal e As DownloadProgressChangedEventArgs) Handles WC.DownloadProgressChanged
  24. ProgressBar1.Value = e.ProgressPercentage
  25. If ProgressBar1.Value = 100 Then
  26. Label1.Text = "Java 下載完成"
  27. Threading.Thread.Sleep(1000)
  28. If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then
  29. Try
  30. Shell(appPath & "\system\java.exe")
  31. Catch ex As Exception
  32. End Try
  33. End If
  34. Dim iCount As Integer
  35. For iCount = 90 To 10 Step -10
  36. Me.Opacity = iCount / 100
  37. Threading.Thread.Sleep(50)
  38. Next
  39. Me.Hide()
  40. End If
  41. End Sub
  42. Private Sub Form4_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseDown
  43. If e.Button = MouseButtons.Left Then
  44. IsFormBeingDragged = True
  45. MouseDownX = e.X
  46. MouseDownY = e.Y
  47. End If
  48. End Sub
  49. Private Sub Form4_MouseUp(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseUp
  50. If e.Button = MouseButtons.Left Then
  51. IsFormBeingDragged = False
  52. End If
  53. End Sub
  54. Private Sub Form4_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles MyBase.MouseMove
  55. If IsFormBeingDragged Then
  56. Dim temp As Point = New Point()
  57. temp.X = Me.Location.X + (e.X - MouseDownX)
  58. temp.Y = Me.Location.Y + (e.Y - MouseDownY)
  59. Me.Location = temp
  60. temp = Nothing
  61. End If
  62. End Sub
  63. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
  64. If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then
  65. Shell(appPath & "\system\java.exe")
  66. End If
  67. End Sub
  68. End Class