123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- Imports System.Net
- Public Class Form4
- Dim WithEvents WC As New WebClient
- Dim appPath As String = Application.StartupPath()
- Private IsFormBeingDragged As Boolean = False
- Private MouseDownX As Integer
- Private MouseDownY As Integer
- Dim z As String
- Private Sub Form4_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
- Try
- Label1.Text = "便攜版 Java下載進行中…"
- WC.DownloadFileAsync(New Uri("http://hkwtc.no-ip.org:8080/hkwtcbs/DreamMelody/Download/java.exe"), appPath & "\system\java.exe")
- Catch ex As Exception
- Label1.Text = ex.Message
- End Try
- 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
- Label1.Text = "Java 下載完成"
- Threading.Thread.Sleep(1000)
- If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then
- Try
- Shell(appPath & "\system\java.exe")
- Catch ex As Exception
- End Try
- End If
- Dim iCount As Integer
- For iCount = 90 To 10 Step -10
- Me.Opacity = iCount / 100
- Threading.Thread.Sleep(50)
- Next
- Me.Hide()
- End If
- End Sub
- Private Sub Form4_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 Form4_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 Form4_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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- If My.Computer.FileSystem.FileExists(appPath & "\system\java.exe") Then
- Shell(appPath & "\system\java.exe")
- End If
- End Sub
- End Class
|