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
|
# Déclaration de la fonction des boutons
Function Button_Click1()
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.Description = "Sélectionnez la Source"
$foldername.rootfolder = "MyComputer"
$foldername.SelectedPath = $initialDirectory
if($foldername.ShowDialog() -eq "OK")
{
$folder1 += $foldername.SelectedPath
}
return $folder
}
Function Button_Click2()
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.Description = "Sélectionnez la Destination"
$foldername.rootfolder = "MyComputer"
$foldername.SelectedPath = $initialDirectory
if($foldername.ShowDialog() -eq "OK")
{
$folder2 += $foldername.SelectedPath
}
return $folder
}
# Création de la forme
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$Form = New-Object System.Windows.Forms.Form
$Form.width = 300
$Form.height = 200
$Form.Text = IT TOOLS - Robocopy
$Form.StartPosition = "CenterScreen"
$Form.Topmost = $True
# Ajout Premier Bouton
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(30,30)
$Button.Size = New-Object System.Drawing.Size(100,40)
$Button.Text = "Source"
# Ajout Second Bouton
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Size(170,27)
$Button.Size = New-Object System.Drawing.Size(100,40)
$Button.Text = "Destination"
#$DropDownFrom = New-Object System.Windows.Forms.ComboBox
#$DropDownFrom.Location = New-Object System.Drawing.Size(140,10)
#$DropDownFrom.Size = New-Object System.Drawing.Size(130,30)
ForEach ($Item in $DropDownArray) {
$Button.Items.Add($Item) | Out-Null
}
$Form.Controls.Add($Button)
#$DropDownFromLabel = New-Object System.Windows.Forms.Label
#$DropDownFromLabel.Location = New-Object System.Drawing.Size(10,10)
#$DropDownFromLabel.Size = New-Object System.Drawing.Size(100,40)
#$DropDownFromLabel.Text = "Sélectionnez la Source"
#$Form.Controls.Add($DropDownFromLabel)
#$DropDownTo = New-Object System.Windows.Forms.ComboBox
#$DropDownTo.Location = New-Object System.Drawing.Size(140,50)
#$DropDownTo.Size = New-Object System.Drawing.Size(130,30)
ForEach ($Item in $DropDownArray) {
$Button.Items.Add($Item) | Out-Null
}
$Form.Controls.Add($Button)
#$DropDownToLabel = new-object System.Windows.Forms.Label
#$DropDownToLabel.Location = new-object System.Drawing.Size(10,50)
#$DropDownToLabel.size = new-object System.Drawing.Size(100,40)
#$DropDownToLabel.Text = "Sélectionnez la Destination"
#$Form.Controls.Add($DropDownToLabel)
$OKButton = new-object System.Windows.Forms.Button
$OKButton.Location = new-object System.Drawing.Size(100,90)
$OKButton.Size = new-object System.Drawing.Size(100,20)
$OKButton.Text = "OK"
$OKButton.Add_Click({
$Form.DialogResult = "OK"
$Form.close()
})
$form.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Size(100,120)
$CancelButton.Size = New-Object System.Drawing.Size(100,20)
$CancelButton.Text = "Cancel"
$CancelButton.Add_Click({
$Form.DialogResult = "Cancel"
$Form.close()
})
$Form.Controls.Add($CancelButton)
$Form.Add_Shown({$Form.Activate()})
$result = $Form.ShowDialog() |
Partager