1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
| Public Class Form1
'Inherits System.Windows.Forms.Form
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.AllowDrop = True
If My.Settings.collection1.Count > 1 Then
'My.Settings.Reset()
For Each i In My.Settings.collection1
If Not i = "a" Then
Dim MyButton = New Button
MyButton.Text = My.Computer.FileSystem.GetName(i)
MyButton.AccessibleDescription = i
MyButton.Height = 125
Dim fileNames = My.Computer.FileSystem.GetName(i)
Dim isExtension As String = Mid(Mid(fileNames, Len(fileNames) - 3), 1)
If isExtension = ".xls" Or isExtension = "xlsx" Then
MyButton.BackgroundImage = My.Resources.Logo_Microsoft_Excel_2013
ElseIf isExtension = ".doc" Or isExtension = "docx" Then
MyButton.BackgroundImage = My.Resources.Logo_Microsoft_Word_2013
ElseIf isExtension = ".pdf" Then
MyButton.BackgroundImage = My.Resources.logo_pdf
ElseIf InStr(isExtension, ".") > 0 Then
MyButton.BackgroundImage = My.Resources.FileLogo_TextFile
Else
MyButton.BackgroundImage = My.Resources.folder_256
End If
MyButton.BackgroundImageLayout = ImageLayout.None
MyButton.BackColor = Color.White
MyButton.TextAlign = ContentAlignment.BottomCenter
Me.FlowLayoutPanel1.Controls.Add(MyButton)
AddHandler MyButton.Click, AddressOf Me.Button
End If
Next
End If
End Sub
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
' fichierTexte.Dispose()
End Sub
Private Sub Button(ByVal sender As System.Object, ByVal e As System.EventArgs)
On Error Resume Next
Process.Start(CType(CType(sender, System.Windows.Forms.Button).AccessibleDescription, String))
End Sub
Private Sub Form1_DragDrop(sender As Object, e As DragEventArgs) Handles MyBase.DragDrop
Dim files() As String = e.Data.GetData(DataFormats.FileDrop)
For Each path In files
Dim fileNames = My.Computer.FileSystem.GetName(path)
Dim isExtension As String = Mid(Mid(fileNames, Len(fileNames) - 3), 1)
My.Settings.collection1.Add(path)
Dim button1 As New Button
button1.Text = fileNames
button1.AccessibleDescription = path
button1.Height = 125
If isExtension = ".xls" Or isExtension = "xlsx" Then
button1.BackgroundImage = My.Resources.Logo_Microsoft_Excel_2013
ElseIf isExtension = ".doc" Or isExtension = "docx" Then
button1.BackgroundImage = My.Resources.Logo_Microsoft_Word_2013
ElseIf isExtension = ".pdf" Then
button1.BackgroundImage = My.Resources.logo_pdf
ElseIf InStr(isExtension, ".") > 0 Then
button1.BackgroundImage = My.Resources.FileLogo_TextFile
Else
button1.BackgroundImage = My.Resources.folder_256
End If
button1.BackgroundImageLayout = ImageLayout.None
button1.BackColor = Color.White
button1.TextAlign = ContentAlignment.BottomCenter
Me.FlowLayoutPanel1.Controls.Add(button1)
AddHandler button1.Click, AddressOf Me.Button
Next
End Sub
Private Sub Form1_DragEnter(sender As Object, e As DragEventArgs) Handles MyBase.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
End If
End Sub
Private Sub Form1_SizeChanged(sender As Object, e As EventArgs) Handles MyBase.SizeChanged
Me.FlowLayoutPanel1.Width = Me.Width - 5
Me.FlowLayoutPanel1.Height = Me.Height - 35
Me.FlowLayoutPanel1.Refresh()
'Me.Button1.Left = Me.Width / 2 - 46
'Me.Button1.Top = Me.Height - 80
End Sub
'Private Sub Button2_Click(sender As Object, e As EventArgs)
' On Error Resume Next
' Process.Start(Me.Button2.AccessibleDescription)
'End Sub
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs)
My.Settings.collection1.Clear()
My.Settings.collection1.Add("a")
Me.FlowLayoutPanel1.Controls.Clear()
End Sub
Private Sub Form1_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Form3.Left = MousePosition.X - mousex
Form3.Top = MousePosition.Y - mousey
'Me.Location = New Point(MousePosition.X, MousePosition.Y)
End If
End Sub
Dim mousex As Integer
Dim mousey As Integer
Private Sub Form1_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
mousex = Windows.Forms.Cursor.Position.X - Me.Left 'Sets variable mousex
mousey = Windows.Forms.Cursor.Position.Y - Me.Top 'Sets variable
End Sub
Private Sub FlowLayoutPanel1_MouseDown(sender As Object, e As MouseEventArgs) Handles FlowLayoutPanel1.MouseDown
mousex = Windows.Forms.Cursor.Position.X - Me.Left 'Sets variable mousex
mousey = Windows.Forms.Cursor.Position.Y - Me.Top 'Sets variable
End Sub
Private Sub FlowLayoutPanel1_MouseMove(sender As Object, e As MouseEventArgs) Handles FlowLayoutPanel1.MouseMove
If e.Button = Windows.Forms.MouseButtons.Left Then
Form3.Left = MousePosition.X - mousex
Form3.Top = MousePosition.Y - mousey
'Me.Location = New Point(MousePosition.X, MousePosition.Y)
End If
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim nom As String
nom = InputBox("Veuillez indiquer le nom de la fenêtre", "Nom de la fenêtre")
Form3.Label1.Text = nom
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
If ColorDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
Form3.BackColor = ColorDialog1.Color
End If
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
End Sub
End Class |
Partager