123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
-
- Imports Microsoft.Win32
- Imports System.IO
- Imports System.Net
- Imports System.CodeDom.Compiler
- Imports fLaSh.Dissembler
- Public Class form2
- Dim wheretosave As String
- Dim uriSource As Uri
- Dim downloading As New Net.WebClient
- Dim timerID As IntPtr = 0
- Dim downloadSpeed As Integer = 0
- Dim currBytes As Long
- Dim prevBytes As Long
- Dim startTime As Long
- Dim elapsedTime As TimeSpan
- Dim downloadStarted As Boolean = False
- Sub setupEventHandlers()
- Try
- AddHandler downloading.DownloadProgressChanged, AddressOf getDownloadProgress
- AddHandler downloading.DownloadFileCompleted, AddressOf downloadHasEnded
- AddHandler SystemEvents.TimerElapsed, AddressOf downloadUpdating
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Sub downloadUpdating(ByVal sender As Object, ByVal e As Microsoft.Win32.TimerElapsedEventArgs)
- Try
- elapsedTime = TimeSpan.FromTicks((Now.Ticks - startTime))
- lblElapsedTime.Text = "Elapsed Time: " & String.Format("{0:00}:{1:00}:{2:00}", _
- elapsedTime.TotalHours, elapsedTime.Minutes, elapsedTime.Seconds)
- downloadSpeed = (currBytes - prevBytes)
- lblSpeedKbytes.Text = "Speed: " & FormatNumber(downloadSpeed / 1000, 2).ToString & " KB/s"
- prevBytes = currBytes
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Sub doDownload()
- Try
- downloading.DownloadFileAsync(uriSource, Label1.Text)
- downloadStarted = True
- btnCancel.Enabled = True
- Catch exc As Exception
- downloadStarted = False
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Sub downloadHasEnded(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
- Try
- If e.Cancelled Then
- LblStatus.Text = "Status: Canceled"
- Else
- LblStatus.Text = "Status: Finished!"
- End If
- btnCancel.Enabled = False
- If timerID.ToInt32 > 0 Then
- SystemEvents.KillTimer(timerID)
- timerID = Nothing
- End If
- Catch exc As Exception
- MessageBox.Show(e.Error.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Sub getDownloadProgress(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs)
- Try
- pbDownloadProgress.Value = e.ProgressPercentage
- lblProgress.Text = "Progress: " & e.ProgressPercentage.ToString & "%"
- lblDownloadBytes.Text = "Downloaded: " & FormatNumber(e.BytesReceived / 1000, 2).ToString & " KB"
- lblDownloadSize.Text = "Download Size: " & FormatNumber(e.TotalBytesToReceive / 1000, 2).ToString & " KB"
- currBytes = e.BytesReceived
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
- Try
- If timerID.ToInt32 > 0 Then
- SystemEvents.KillTimer(timerID)
- timerID = Nothing
- End If
- downloading.CancelAsync()
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Private Sub btnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub frmMain_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- MessageBox.Show("Attention ! Ne choisis pas la nouvelle version de minecraft mais le launcher ! C'est très important !!!", "Warning - Minecraft AutoUpdater", MessageBoxButtons.OK, MessageBoxIcon.Warning)
- Dim ofd As New OpenFileDialog
- ofd.FilterIndex = 1
- ofd.Filter = "Exe (*.exe)|*.exe"
- ofd.ShowDialog()
- TextBox1.Text = ofd.FileName
- Try
- SaveProperties(TextBox1.Text)
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- End Try
- End Sub
- Private Sub SaveProperties(ByVal sPath As String)
- Dim web As New WebClient
- Dim checkversion As String = web.DownloadString("http://pulsor.fileave.com/Version.txt")
- Try
- If Not File.Exists(sPath) Then
- Throw New Exception("Exe not found!")
- End If
- Cursor.Current = Cursors.WaitCursor
- Application.DoEvents()
- Dim oVersionResource As New VersionResource()
- oVersionResource.LoadFrom(sPath)
- '
- oVersionResource.ProductVersion = checkversion
- '
- Dim oStringFileInfo As StringFileInfo = DirectCast(oVersionResource("StringFileInfo"), StringFileInfo)
- oStringFileInfo("ProductVersion") = String.Format("{0}" & vbNullChar, oVersionResource.ProductVersion)
- oStringFileInfo("Assembly Version") = String.Format("{0}" & vbNullChar, oVersionResource.ProductVersion)
- oVersionResource.SaveTo(sPath)
- MessageBox.Show("Done!")
- Catch ex As Exception
- MessageBox.Show(ex.Message)
- Finally
- Cursor.Current = Cursors.Default
- End Try
- End Sub
- Private Sub Getlinkdownload()
- Dim web As New WebClient
- Dim getver As String = web.DownloadString("http://pulsor.fileave.com/DownloadAddress.txt")
- txtDownloadAddress.Text = getver
- End Sub
- Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- form2.CheckForIllegalCrossThreadCalls = False
- Dim thread As New System.Threading.Thread(AddressOf Getlinkdownload)
- thread.Start()
- System.Threading.Thread.Sleep(1000)
- Try
- setupEventHandlers()
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Info!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- Try
- Dim saveDLG As New SaveFileDialog
- Dim ext As String = "|Exe(*.exe)|*.exe"
- saveDLG.Filter = "All Files (*.*)|*.*" & ext '"Exe (*.exe)|*.exe"
- saveDLG.Title = "ClanLSE - Minecraft Launcher"
- If saveDLG.ShowDialog = Windows.Forms.DialogResult.OK Then
- Label1.Text = saveDLG.FileName
- End If
- uriSource = New Uri(txtDownloadAddress.Text)
- timerID = SystemEvents.CreateTimer((1000))
- doDownload()
- startTime = Now.Ticks
- currBytes = 0
- prevBytes = 0
- downloadSpeed = 0
- pbDownloadProgress.Value = 0
- LblStatus.Text = "Status: Started"
- Catch exc As Exception
- MessageBox.Show(exc.Message, " Download Button!", MessageBoxButtons.OK, _
- MessageBoxIcon.Information)
- End Try
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
- End Sub
- Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs)
- End Sub
- End Class
|