Question Afficher puis modifier un windowsForm

Plus d'informations
il y a 6 ans 10 mois #23623 par martinez
Bonjour,
Je dois travailler sur de l'affichage, j'affiche donc une Form, je la complète au fur et à mesure que je complète les informations.
Le problème est que je dois le faire pas script et sans intervention humaine.
Le but et d'afficher la progression avant d'arriver au résultat pour que l'utilisateur comprenne que le script travail. Le script pouvant tourner pendant 5 minutes, il est important de pouvoir avoir plus qu'une progress bar, mais une véritable liaison en temps réel.
Le but est de faire :
Traitement 1 en cours.
Puis
Traitement 1 fini OK ou non OK
Traitement 2 en cours
Etc..
Merci d’avance pour votre aide
Test simple ajouter un label après avoir créer une interface
Function windowsForm{
# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Windows.Forms\")
[void][System.Reflection.Assembly]::LoadWithPartialName(\"System.Drawing\")

# Creation de la form principale
$form = New-Object Windows.Forms.Form
# Pour bloquer le resize du form et supprimer les icones Minimize and Maximize
$form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form.MaximizeBox = $False
$form.MinimizeBox = $False
# Choix du titre
$form.Text = \"Hello world... oui pas très innovant, je sais !\"
# Choix de la taille
$form.Size = New-Object System.Drawing.Size(400,370)
# Affichage de la Windows

return $form
}

function Ajout_Label{
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(10,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = \"Please enter the information in the space below:\"
return $label
}

$form1 = WindowsForm
$form1.ShowDialog()
$label1 = Ajout_Label $form1
$form1.Controls.Add($label1)

$form1.Refresh()<br><br>Message édité par: martinez_pat, à: 15/05/17 10:17

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 6 ans 10 mois #23628 par Laurent Dardenne
Salut,
le showDialog() place ta fenêtre en modale .
L'ajout du contrôle ne se fait qu'une fois quitter la fenêtre.

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 6 ans 10 mois #23629 par martinez
Peut-on exécuter sans appuie d'un bouton pour lancer les taches?

function Test-affichage{
Param()

$Label1 = Set_Label -y 220 -x 40 -Text \&quot;Program 1 en cours \&quot;
$form.Controls.Add($label1 )
Start-Sleep -Seconds 5
#Function X
$Label1.Text = \&quot;Program 1 Fini \&quot;
$Label2 = Set_Label -y 260 -x 40 -Text \&quot;Program 2 en cours \&quot;
$form.Controls.Add($label2 )
Start-Sleep -Seconds 5
#Function X
$Label2.Text = \&quot;Program 2 Fini\&quot;

}

function Set_Label{
Param($Text,
$y,
$x)
$label_const = New-Object System.Windows.Forms.Label
$label_const.Location = New-Object System.Drawing.Point($x,$y)
$label_const.Size = New-Object System.Drawing.Size(150,40)
$label_const.Text = $Text
return $label_const
}



# Chargement des assemblies
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Windows.Forms\&quot;)
[void][System.Reflection.Assembly]::LoadWithPartialName(\&quot;System.Drawing\&quot;)
$start_button = New-Object System.Windows.Forms.Button
# 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.Text = \&quot;Nouveau windows form\&quot;
$form.Size = New-Object System.Drawing.Size(400,400)

$start_button_OnClick = {


$cpt =Test-affichage -test $cpt


}
$timer=New-Object System.Windows.Forms.Timer

$start_button.TabIndex = 2
$start_button.Name = 'button1'
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = 310
$System_Drawing_Size.Height = 70
$start_button.Size = $System_Drawing_Size
$start_button.UseVisualStyleBackColor = $True

$start_button.Text = 'Start'
$start_button.Font = New-Object System.Drawing.Font(\&quot;Verdana\&quot;,12,0,3,0)

$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 45
$System_Drawing_Point.Y = 12
$start_button.Location = $System_Drawing_Point
$start_button.DataBindings.DefaultDataSourceUpdateMode = 0
$start_button.add_Click($start_button_OnClick)

$form.Controls.Add($start_button)

$form.ShowDialog()
$form.refresh()

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 6 ans 10 mois #23630 par Laurent Dardenne
martinez_pat écrit:

Peut-on exécuter sans appuie d'un bouton pour lancer les taches?

Oui, il faut placer le code dans le bon event .

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 6 ans 10 mois #23632 par martinez
Merci

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.068 secondes
Propulsé par Kunena