Files
2026-06-18 14:15:48 +02:00

180 lines
9.1 KiB
VB.net

Imports System.ComponentModel
Imports System.Net
Imports System.IO
Imports System.Math
Public Class Drive3
Dim fermer As Integer = 1
Dim dl As Integer = 0
Dim pourcent As Integer = 0
Private Sub Drive3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim lines1a() As String = File.ReadAllLines(théme)
If lines1a(0) = 2 Then
Me.BackColor = Color.FromArgb(64, 64, 64)
Label1.ForeColor = Color.White
Label9.ForeColor = Color.White
ElseIf lines1a(0) = 3 Then
Me.BackColor = Color.FromArgb(Form1.colorbackA, Form1.colorbackR, Form1.colorbackG, Form1.colorbackB)
Label1.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
Label9.ForeColor = Color.FromArgb(Form1.themeforecoloA, Form1.themeforecoloR, Form1.themeforecoloG, Form1.themeforecoloB)
End If
If Drive.ListBox1.SelectedItem.ToString.EndsWith(".plm") Then
If Drive.TextBox1.Text = "" Then
If File.Exists(Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", "")) = True Then
MsgBox("Le fichier que vous voulez télécharger existe déjà", MsgBoxStyle.Information)
Close()
Exit Sub
End If
Form1.Timer6.Stop()
My.Computer.Network.DownloadFile(ipsite & "/utilisateur/" & Drive.tcon & "/dirve/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"), dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
Dim lines2() As String = File.ReadAllLines(dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
File.Delete(dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(lines2(0)), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", "")))
Exit Sub
Else
If File.Exists(Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", "")) = True Then
MsgBox("Le fichier que vous voulez télécharger existe déjà", MsgBoxStyle.Information)
Close()
Exit Sub
End If
Form1.Timer6.Stop()
My.Computer.Network.DownloadFile(ipsite & "/utilisateur/" & Drive.tcon & "/dirve/" & Drive.TextBox1.Text & "/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"), dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
Dim lines2() As String = File.ReadAllLines(dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
File.Delete(dosparamètres & "\" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", ".txt"))
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(lines2(0)), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem.ToString.Replace(".plm", "")))
Exit Sub
End If
End If
If File.Exists(Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem) = True Then
MsgBox("Le fichier que vous voulez télécharger existe déjà", MsgBoxStyle.Information)
Close()
Exit Sub
Else
If Drive.TextBox1.Text = "" Then
Me.Text = Drive.ListBox1.SelectedItem
Try
Form1.Timer6.Stop()
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(ipsite & "/" & "Utilisateur" & "/" & Drive.tcon & "/" & "Dirve" & "/" & Drive.ListBox1.SelectedItem), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem))
Catch ex As Exception
Timer1.Start()
End Try
Else
Me.Text = Drive.ListBox1.SelectedItem
Try
Form1.Timer6.Stop()
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(ipsite & "/" & "Utilisateur" & "/" & Drive.tcon & "/" & "Dirve" & Drive.TextBox1.Text & "/" & Drive.ListBox1.SelectedItem), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem))
Catch ex As Exception
Timer1.Start()
End Try
End If
End If
End Sub
Private Sub téléchargerfr_DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs) Handles téléchargerfr.DownloadProgressChanged
Dim disctédossier = func_RoundTaille(e.BytesReceived)
Dim disctédossier2 = func_RoundTaille(e.TotalBytesToReceive)
Label9.Text = disctédossier & " / " & disctédossier2
Me.Text = Drive.ListBox1.SelectedItem & ": " & " " & e.ProgressPercentage & "%" & " " & disctédossier & " / " & disctédossier2
GunaProgressBar1.Value = e.ProgressPercentage
Label1.Text = e.ProgressPercentage & "%"
pourcent = e.ProgressPercentage
If e.ProgressPercentage = 10 Then
dl10()
ElseIf e.ProgressPercentage = 50 Then
dl50()
ElseIf e.ProgressPercentage = 90 Then
dl90()
End If
End Sub
Private Sub téléchargerfr_DownloadFileCompleted(sender As Object, e As AsyncCompletedEventArgs) Handles téléchargerfr.DownloadFileCompleted
Form1.Timer6.Start()
Form1.NotifyIcon1.BalloonTipTitle = "Téléchargement terminer"
fermer = 0
Form1.NotifyIcon1.BalloonTipText = "Le téléchargement de " & Drive.ListBox1.SelectedItem & " est terminer"
Form1.NotifyIcon1.ShowBalloonTip(0)
MsgBox("Le fichier: " & Drive.ListBox1.SelectedItem & " a bien été télécharger", MsgBoxStyle.Information)
Drive.ListBox1.Items.Clear()
Drive.ftp()
GunaProgressBar1.Value = 0
Label1.Text = ""
Close()
End Sub
Private Sub Drive3_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing
If fermer = 1 Then
MsgBox("Le téléchargement de " & Drive.ListBox1.SelectedItem & " est en cours merci de patienter", MsgBoxStyle.Information)
e.Cancel = True
End If
End Sub
Dim WithEvents téléchargerfr As WebClient
Sub dl10()
If dl = 0 Then
Form1.NotifyIcon1.BalloonTipTitle = "Téléchargement"
Form1.NotifyIcon1.BalloonTipText = "Le téléchargement de " & Drive.ListBox1.SelectedItem & " " & pourcent & "%"
Form1.NotifyIcon1.ShowBalloonTip(0)
dl = 1
End If
End Sub
Sub dl50()
If dl = 1 Then
Form1.NotifyIcon1.BalloonTipTitle = "Téléchargement"
Form1.NotifyIcon1.BalloonTipText = "Le téléchargement de " & Drive.ListBox1.SelectedItem & " " & pourcent & "%"
Form1.NotifyIcon1.ShowBalloonTip(0)
dl = 2
End If
End Sub
Sub dl90()
If dl = 2 Then
Form1.NotifyIcon1.BalloonTipTitle = "Téléchargement"
Form1.NotifyIcon1.BalloonTipText = "Le téléchargement de " & Drive.ListBox1.SelectedItem & " " & pourcent & "%"
Form1.NotifyIcon1.ShowBalloonTip(0)
dl = 0
End If
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Timer1.Stop()
If Drive.TextBox1.Text = "" Then
Me.Text = Drive.ListBox1.SelectedItem
Try
Form1.Timer6.Stop()
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(ipsite & "/" & "Utilisateur" & "/" & Drive.tcon & "/" & "Dirve" & "/" & Drive.ListBox1.SelectedItem), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem))
Catch ex As Exception
Timer1.Start()
End Try
Else
Me.Text = Drive.ListBox1.SelectedItem
Try
Form1.Timer6.Stop()
téléchargerfr = New WebClient
téléchargerfr.DownloadFileTaskAsync(New Uri(ipsite & "/" & "Utilisateur" & "/" & Drive.tcon & "/" & "Dirve" & Drive.TextBox1.Text & "/" & Drive.ListBox1.SelectedItem), (Drive.FolderBrowserDialog1.SelectedPath & "/" & Drive.ListBox1.SelectedItem))
Catch ex As Exception
Timer1.Start()
End Try
End If
End Sub
Public Function func_RoundTaille(ByVal LaTaille As Long) As String
Select Case LaTaille
Case Is < 1024
Return Round(LaTaille) & " Octets"
Case Is < 1048576
Return Round(LaTaille / 2 ^ 10, 3) & " Ko"
Case Is < 1073741824
Return Round(LaTaille / 2 ^ 20, 3) & " Mo"
Case Else
Return Round(LaTaille / 2 ^ 30, 3) & " Go"
End Select
End Function
End Class