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
| #fenêtre
$WinCollab = New-Object System.Windows.Forms.Form
$WinCollab.Text = 'UTILISATEUR'
$WinCollab.AutoSize = $true #wrap to content
$WinCollab.Height = 1 #Autosize agrandira la fenêtre
$WinCollab.FormBorderStyle = 3 #fenêtre à taille fixe
$WinCollab.StartPosition = 'CenterScreen'
#Variables taille Libellé
$ValSizeX = 150
$ValSizeY = 20
#Variables localisation x Libellé
$LocationLabX = 20
$SizeXLib = 110
$SizeYLib = 20
################### PARTIE TYPE DE CONTRAT ###################
# Objet : Intitulé.
$LibCtt = New-Object System.Windows.Forms.GroupBox
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$LibCtt.Location = New-Object Drawing.Point($LocationLabX,25)
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$LibCtt.Size = New-Object System.Drawing.Size($SizeXLib,$SizeYLib)
#$LibCtt.AutoSize = $True
# Texte affiché
$LibCtt.Text = "CDI? :"
# Police du texte
$LibCtt.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",9,[System.Drawing.FontStyle]::Underline)
#Attache le contrôle et les boutons à la fenêtre
$WinCollab.controls.add($LibCtt)
# Objet : Bouton radio 'Oui'
$ValCtto = New-Object System.Windows.Forms.RadioButton
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$ValCtto.Location = New-Object System.Drawing.Point((($LibCtt.Location.X)-10),(($LibCtt.Location.Y)-230))
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$ValCtto.Size = New-Object System.Drawing.Size(45,$ValSizeY)
# Bouton cochée sur 'Non' par défaut
$ValCtto.Checked = $True
# Valeur de la boite de dialogue
$ValCtto.Text = "Oui"
# Objet : Bouton radio 'Non'
$ValCttn = New-Object System.Windows.Forms.RadioButton
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$ValCttn.Location = New-Object System.Drawing.Point((($LibCtt.Location.X)+40),(($LibCtt.Location.Y)-230))
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$ValCttn.Size = New-Object System.Drawing.Size(45,$ValSizeY)
# Bouton cochée sur 'Non' par défaut
$ValCttn.Checked = $False
# Valeur de la boite de dialogue
$ValCttn.Text = "Non"
#Action si la case est Non cochée
$ValCttn_CheckedChanged =
{
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$LibCtt.Size = New-Object System.Drawing.Size(($SizeXLib+80),($SizeYLib+55))
#Valeur Y lié à la position verticale
#$ValYLoc = $ValYLoc + 2.4
# Objet : Intitulé.
$LibSORTIE = New-Object System.Windows.Forms.Label
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$LibSORTIE.Location = New-Object Drawing.Point(10,50)
#$LibSORTIE.Location = New-Object Drawing.Point($LocationLabX,(($LibCtt.Location.Y)*$ValYLoc))
# Objet nommé
$LibSORTIE.Name = "LabSortie"
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$LibSORTIE.Size = New-Object System.Drawing.Size(($SizeXLib-10),$SizeYLib)
# Texte affiché
$LibSORTIE.Text = "DATE SORTIE :"
# Police du texte
$LibSORTIE.Font = New-Object System.Drawing.Font("Microsoft Sans Serif",9,
[System.Drawing.FontStyle]([System.Drawing.FontStyle]::Bold -bor [System.Drawing.FontStyle]::Underline))
#Attache le contrôle et les boutons à la fenêtre
#$WinCollab.controls.add($LibSORTIE)
# Objet : Fenêtre de saisie
$ValSORTIE = New-Object System.Windows.Forms.TextBox
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$ValSORTIE.Location = New-Object System.Drawing.Point(110,45)
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$ValSORTIE.Size = New-Object System.Drawing.Size(($ValSizeX-80),$ValSizeY)
# Objet nommé
$ValSORTIE.Name = "ValSortie"
# Valeur de la boite de dialogue
$ValSORTIE.Text = $VarDate
#Attache le contrôle et les boutons à la fenêtre
#$WinCollab.Controls.Add($ValSORTIE)
$LibCtt.Controls.AddRange(@($ValCttn,$ValCtto,$LibSORTIE,$ValSORTIE))
$WinCollab.Controls.AddRange(@($LibCtt))
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$LabelREF.Location = New-Object Drawing.Point($LocationLabX,(($LibCtt.Location.Y)*($ValYLoc+1.3)))
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$BtnValider.Location = New-Object Drawing.Point(120,(($LibCtt.Location.Y)*($ValYLoc+5)))
}
#Action si la case Oui est cochée
$ValCtto_CheckedChanged =
{
#Valeur Y lié à la position verticale
$ValYLoc = $ValYLoc - 1
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$LibCtt.Size = New-Object System.Drawing.Size(($SizeXLib),($SizeYLib+23))
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$LabelREF.Location = New-Object Drawing.Point($LocationLabX,(($LibCtt.Location.Y)*($ValYLoc+1)))
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$BtnValider.Location = New-Object Drawing.Point(120,(($LibCtt.Location.Y)*($ValYLoc+4)))
#$WinCollab.Controls.Add($ValSORTIE)
#Suppression de la fenêtre Date de sortie si non nécessaire
$LibCtt.Controls.RemoveByKey("LabSortie")
$LibCtt.Controls.RemoveByKey("ValSortie")
}
#Execution du script qui masque ou non la date de sortie
$ValCtto.add_click($ValCtto_CheckedChanged)
$ValCttn.add_click($ValCttn_CheckedChanged)
# On crée un groupe de bouton
$LibCtt.Controls.AddRange(@($ValCttn,$ValCtto))
#Attache le contrôle et les boutons à la fenêtre
$WinCollab.Controls.AddRange(@($LibCtt))
################### FIN PARTIE TYPE DE CONTRAT ###################
$ValYLoc = $ValYLoc + 2
#Creation Bouton 'Valider'
$BtnValider = New-Object System.Windows.Forms.Button
# Position de la fenêtre (x,y) x = horizontal, y = vertical
$BtnValider.Location = New-Object Drawing.Point(120,(($LibCtt.Location.Y)*($ValYLoc+4)))
# Taille de la fenêtre (x,y) x = largeur, y = hauteur
$BtnValider.Size = New-Object System.Drawing.Size(75,23)
$BtnValider.Text = 'VALIDER'
$WinCollab.controls.add($BtnValider)
$BtnValider.Add_Click(
{
New-Variable -Name selection -Value $($BtnValider.Text) -Scope Script -Force
$WinCollab.Close()
})
#Affiche le tout.
$WinCollab.ShowDialog()
$Msgbox::MsgBox($ValSORTIE.Text, "OKOnly,Information,SystemModal", "RESUME") |
Partager