Question Fenêtre WindowsForms
- Romain
- Auteur du sujet
- Hors Ligne
- Nouveau membre
-
Réduire
Plus d'informations
- Messages : 4
- Remerciements reçus 0
il y a 5 ans 1 mois #27693
par Romain
Fenêtre WindowsForms a été créé par Romain
Bonjour
Je débute avec WindowsForm et je bloque sur un problème qui paraît simple mais que je n'arrive pas à résoudre.
J'ai une partie de mon script qui copie et colle différents dossiers.
Je voudrais afficher une fenêtre avec le message : \"Copie des éléments. Veuillez patienter...\" pendant l’exécution de cette partie du script. La fenêtre doit s'afficher automatiquement quand la copie commence et s'éteindre une fois la copie terminée sans aucune intervention.
Voici mon script :
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
[System.Windows.Forms.Application]::EnableVisualStyles();
$file = (get-item 'C:UsersrcarlierDesktopImagesloader (1).gif')
$img = [System.Drawing.Image]::Fromfile($file);
# Creation de la form principale
$form = New-Object Windows.Forms.Form
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
$form.StartPosition = \"CenterScreen\"
$form.Text = \"Script de récuperation\"
$form.Width = 375
$form.Height = 270
$form.Opacity = 0.9
#Creation de l'image
$pictureBox = new-object Windows.Forms.PictureBox
$pictureBox.Width = $img.Size.Width;
$pictureBox.Height = $img.Size.Height;
$pictureBox.Image = $img;
$pictureBox.location = New-Object System.Drawing.Point(120,80);
#Création du label
$label_prez = New-Object System.Windows.Forms.Label
$label_prez.AutoSize = $true
$label_prez.Location = New-Object System.Drawing.Point(15,40)
$label_prez.Size = New-Object System.Drawing.Size(100,100)
$label_prez.Text = \"Copie des éléments en cours. Veuillez patienter... \"
$Label1Font = New-Object System.Drawing.Font(\"Tahoma\",10,[System.Drawing.FontStyle]::Bold)
$label_prez.Font = $Label1Font
#Partie avec la copie
#OUVERTURE FENETRE AVEC MESSAGE
#Comment faire pour afficher ma fenêtre pendant la copie ?????
robocopy.exe $DistUserProfile $favoritesOutlook2Path \"*.pst\" /s /R:2 /XD \"$ExcludeFromBackup\" /log+:\"$envUserName.log\" /XD C:$Recycle.bin
#COPIE DU BUREAU
If (-not (test-path -path $EmplacementSauvegardeDesktop)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Desktop}
robocopy.exe $DistUserProfileDesktop $EmplacementSauvegardeDesktop /S /E /R:2 /w:3 /log+:\"$envUserName.log\" /XD $EmplacementSauvegarde
#COPIE LES IMAGES
If (-not (test-path -path $EmplacementSauvegardePictures)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Pictures}
robocopy.exe $DistUserProfilePictures $EmplacementSauvegardePictures /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES DOCUMENTS
If (-not (test-path -path $EmplacementSauvegardeDocuments)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Documents}
robocopy.exe $DistUserProfileDocuments $EmplacementSauvegardeDocuments /S /E /R:2 /w:3 /log+:\"$envUserName.log\" /XD C:%USERPROFILE%DocumentsMy Music
#COPIE LES TELECHARGEMENTS
If (-not (test-path -path $EmplacementSauvegardeDownloads)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Downloads}
robocopy.exe $DistUserProfileDownloads $EmplacementSauvegardeDownloads /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES MUSIQUES
If (-not (test-path -path $EmplacementSauvegardeMusic)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Music}
robocopy.exe $DistUserProfileMusic $EmplacementSauvegardeMusic /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES LIENS
If (-not (test-path -path $EmplacementSauvegardeLinks)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Links}
robocopy.exe $DistUserProfileLinks $EmplacementSauvegardeLinks /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#################################################################################################### ###########################
#FERMETURE FENETRE AVEC MESSAGE
#Ajout à la fenêtre Windowsform
$form.controls.add($pictureBox)
$form.controls.add($label_prez)
$form.ShowDialog()
Je débute avec WindowsForm et je bloque sur un problème qui paraît simple mais que je n'arrive pas à résoudre.
J'ai une partie de mon script qui copie et colle différents dossiers.
Je voudrais afficher une fenêtre avec le message : \"Copie des éléments. Veuillez patienter...\" pendant l’exécution de cette partie du script. La fenêtre doit s'afficher automatiquement quand la copie commence et s'éteindre une fois la copie terminée sans aucune intervention.
Voici mon script :
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")
[System.Windows.Forms.Application]::EnableVisualStyles();
$file = (get-item 'C:UsersrcarlierDesktopImagesloader (1).gif')
$img = [System.Drawing.Image]::Fromfile($file);
# Creation de la form principale
$form = New-Object Windows.Forms.Form
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
$form.StartPosition = \"CenterScreen\"
$form.Text = \"Script de récuperation\"
$form.Width = 375
$form.Height = 270
$form.Opacity = 0.9
#Creation de l'image
$pictureBox = new-object Windows.Forms.PictureBox
$pictureBox.Width = $img.Size.Width;
$pictureBox.Height = $img.Size.Height;
$pictureBox.Image = $img;
$pictureBox.location = New-Object System.Drawing.Point(120,80);
#Création du label
$label_prez = New-Object System.Windows.Forms.Label
$label_prez.AutoSize = $true
$label_prez.Location = New-Object System.Drawing.Point(15,40)
$label_prez.Size = New-Object System.Drawing.Size(100,100)
$label_prez.Text = \"Copie des éléments en cours. Veuillez patienter... \"
$Label1Font = New-Object System.Drawing.Font(\"Tahoma\",10,[System.Drawing.FontStyle]::Bold)
$label_prez.Font = $Label1Font
#Partie avec la copie
#OUVERTURE FENETRE AVEC MESSAGE
#Comment faire pour afficher ma fenêtre pendant la copie ?????
robocopy.exe $DistUserProfile $favoritesOutlook2Path \"*.pst\" /s /R:2 /XD \"$ExcludeFromBackup\" /log+:\"$envUserName.log\" /XD C:$Recycle.bin
#COPIE DU BUREAU
If (-not (test-path -path $EmplacementSauvegardeDesktop)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Desktop}
robocopy.exe $DistUserProfileDesktop $EmplacementSauvegardeDesktop /S /E /R:2 /w:3 /log+:\"$envUserName.log\" /XD $EmplacementSauvegarde
#COPIE LES IMAGES
If (-not (test-path -path $EmplacementSauvegardePictures)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Pictures}
robocopy.exe $DistUserProfilePictures $EmplacementSauvegardePictures /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES DOCUMENTS
If (-not (test-path -path $EmplacementSauvegardeDocuments)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Documents}
robocopy.exe $DistUserProfileDocuments $EmplacementSauvegardeDocuments /S /E /R:2 /w:3 /log+:\"$envUserName.log\" /XD C:%USERPROFILE%DocumentsMy Music
#COPIE LES TELECHARGEMENTS
If (-not (test-path -path $EmplacementSauvegardeDownloads)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Downloads}
robocopy.exe $DistUserProfileDownloads $EmplacementSauvegardeDownloads /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES MUSIQUES
If (-not (test-path -path $EmplacementSauvegardeMusic)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Music}
robocopy.exe $DistUserProfileMusic $EmplacementSauvegardeMusic /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#COPIE LES LIENS
If (-not (test-path -path $EmplacementSauvegardeLinks)) {New-Item -ItemType Directory -path $EmplacementSauvegarde -name Links}
robocopy.exe $DistUserProfileLinks $EmplacementSauvegardeLinks /S /E /R:2 /w:3 /log+:\"$envUserName.log\"
#################################################################################################### ###########################
#FERMETURE FENETRE AVEC MESSAGE
#Ajout à la fenêtre Windowsform
$form.controls.add($pictureBox)
$form.controls.add($label_prez)
$form.ShowDialog()
Pièces jointes :
Connexion ou Créer un compte pour participer à la conversation.
- Philippe
- Hors Ligne
- Modérateur
-
Réduire
Plus d'informations
- Messages : 1778
- Remerciements reçus 21
il y a 5 ans 1 mois #27697
par Philippe
Réponse de Philippe sur le sujet Re:Fenêtre WindowsForms
la réponse
ici
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.059 secondes
- Vous êtes ici :
-
Accueil
-
forum
-
PowerShell
-
Entraide pour les initiés
- Fenêtre WindowsForms