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