Référence complète des commandes — v2.0 · Toutes validées sur le testeur PFPComplete command reference — v2.0 · all validated on the PFP tester
Show-PF "Fichier sauvegardé !" -IsSuccess
-TypeTitle line. Without one, the label is derived from -TypeInfo | Success | Warning | Error.\logo.png) ou absolu. Défaut = logo du projet ($form → Propriétés → Application)Logo — path relative to the app folder (.\logo.png) or absolute. Default = the project logo ($form → Properties → Application){ Ok; Native; Error } au lieu du booléenReturns { Ok; Native; Error } instead of the booleanShow-PF, pas un remplaçant : Show-PF = bulle dans la fenêtre, Toast-PF = notification du système (visible fenêtre minimisée, conservée dans le centre de notifications). C'est le seul verbe de notification autorisé dans un bloc -Work : il ne touche aucun contrôle WinForms. Retourne $true/$false, ne lève jamais d'exception ; en cas d'échec de la voie native il replie sur le toast in-app et la cause est dans $script:PFToastError.Complements Show-PF, it does not replace it: Show-PF = a bubble inside the window, Toast-PF = a system notification (visible when minimised, kept in the Action Center). It is the only notification verb allowed inside a -Work block: it touches no WinForms control. Returns $true/$false and never throws; if the native path fails it falls back to the in-app toast and the reason is in $script:PFToastError.toast("Sauvegarde effectuée") toast("Export terminé", { type: "success", sound: false }) toast("Serveur injoignable", { type: "error", onClick: { Go-PF "Journal" } }) if (-not (Toast-PF -Message "Terminé")) { Write-PF $script:lblEtat $script:PFToastError }
Alert-PF "Action impossible" -IsError Alert-PF "Connexion lente détectée" -IsWarning Alert-PF "Traitement terminé avec succès."
$true = OUI, $false = NON / Annulerif (Ask-PF "Voulez-vous supprimer cet enregistrement ?") { # L'utilisateur a cliqué OUI Clear-PF $script:dgvData Show-PF "Supprimé !" -IsSuccess }
$null -ne $val avant d'utiliser le résultat. L'utilisateur peut cliquer Annuler.$nom = Read-PF "Entrez votre nom :" -Default "Dupont" if ($null -ne $nom) { Write-PF $script:lblBonjour "Bonjour $nom !" }
"75")Value to write. For a ProgressBar, pass an integer (e.g. "75")Start-PF -Work. Ne jamais accéder directement à $script: depuis le runspace de -Work.Write-PF $script:lblStatut "Prêt" Write-PF $script:txtLog "Ligne ajoutée`n" -Append Write-PF $script:prgAvancement "75" # ProgressBar à 75 %
$true si TOUS les contrôles sont valides.if (-not (Validate-PF -Controls @($script:txtNom, $script:txtEmail) -Highlight)) { return # Stop ici si invalide }
Clear-PF $script:txtSaisie Clear-PF $script:dgvResultats Clear-PF $script:cmbFiltres
-All = tous les éléments d'une liste (ou toutes les lignes d'une grille, en objets) · -Checked = éléments cochés d'une CheckedListBox · -Index = index de la ligne DataGridView sélectionnée (-1 si aucune) · -Field "Col" = champ nommé de la ligne courante · -Prop "BackColor" = lecture générique d'une propriété .NET.Get-PF ctrl Text (nom sans $ + propriété en 2e argument) n'existe pas : elle renvoie du vide sans erreur. Écrivez Get-PF $ctrl ou Get-PF $ctrl -Prop Text.-All = every item of a list (or every grid row, as objects) · -Checked = ticked items of a CheckedListBox · -Index = index of the selected DataGridView row (-1 if none) · -Field "Col" = named field of the current row · -Prop "BackColor" = generic read of any .NET property.Get-PF ctrl Text form (bare name + property argument) does not exist: it silently returns empty. Write Get-PF $ctrl or Get-PF $ctrl -Prop Text.$nom = Get-PF $script:txtNom # string $date = Get-PF $script:dtpDate # DateTime $ok = Get-PF $script:chkActif # bool $item = Get-PF $script:dgvListe # objet lié
-Where filtre les données à l'affichage (le bloc reçoit chaque élément dans $_) — idéal pour une barre de recherche : on refiltre la même source à chaque frappe, sans la dupliquer.Fill-PF $dgv $data -Where { $_.Nom -like "*$q*" }-Where filters the data at display time (the block receives each item as $_) — ideal for a search box: refilter the same source on each keystroke, with no duplicate.Fill-PF $dgv $data -Where { $_.Nom -like "*$q*" }$null vide le contrôle.Array of strings, hashtables, PSCustomObjects or DataRows. $null clears the control.@() de Hashtables, PSCustomObjects ou valeurs simples. Les colonnes sont créées automatiquement et auto-redimensionnées.# Liste simple Fill-PF $script:cmbVilles @("Paris", "Lyon", "Bordeaux") # DataGridView avec PSCustomObjects $data = Import-Csv "data.csv" Fill-PF $script:dgvData $data # Vider un contrôle Fill-PF $script:lstItems $null
Fill-PF, qui lui remplace tout. Sur une DataGridView liée (après Fill-PF), la ligne est ajoutée/retirée directement dans la source de données : plus besoin de variable miroir $script:. Thread-safe.Complements Fill-PF, which replaces everything. On a bound DataGridView (after Fill-PF), the row is added/removed straight in the data source: no mirror $script: variable needed. Thread-safe.Add-PF $script:lstTaches "Nouvelle tâche" Add-PF $script:cbxVilles @("Paris", "Lyon") Remove-PF $script:lstTaches "Paris" Remove-PF $script:lstTaches -Index 0 # DataGridView liée Add-PF $script:dgvClients @{ Nom="Carol"; Age=40 } Remove-PF $script:dgvClients -Index (Get-PF $script:dgvClients -Index)
@() et le scope $script:. (Note : Remplacé par Toggle-PF dans de nombreux cas en v2.0)
Lock-PF -Controls @($script:btnValider, $script:txtInput)
@($script:c1, $script:c2) ou contrôle uniqueArray of controls @($script:c1, $script:c2) or a single control# Désactiver un panel entier Toggle-PF $script:pnlFormulaire -Action Disable # Masquer plusieurs boutons d'un coup Toggle-PF @($script:btnSave, $script:btnCancel) -Action Hide
-Prop, Set-PF est purement numérique. -Prop écrit n'importe quelle propriété .NET (Visible, Enabled, BackColor, Width…), de façon gardée et thread-safe — ex. Set-PF $pnl -Prop "Visible" $false. Pour l'apparence d'un bouton, préférez Style-PF.Without -Prop, Set-PF is numeric only. -Prop writes any .NET property (Visible, Enabled, BackColor, Width…), guarded and thread-safe — e.g. Set-PF $pnl -Prop "Visible" $false. For button looks, prefer Style-PF.-Work de Start-PF / Wait-PF (gère InvokeRequired automatiquement). Le clamp Min/Max évite tout dépassement.Thread-safe: callable straight from a -Work block of Start-PF / Wait-PF (handles InvokeRequired automatically). The Min/Max clamp prevents any overflow.Set-PF $script:prgCharge -Value 75 # à 75 % Set-PF $script:prgCharge -Add -Value 10 # +10 Set-PF $script:prgCharge -Reset # → Minimum
$script: directement.ScriptBlock run in the background. Never read $script: directly inside it.$result.UI callback run on success. Receives $result.$prog.UI callback to update a ProgressBar. Receives $prog.$_shared.Data passed to the runspace through $_shared.-With pour injecter des chemins ou valeurs venant de l'UI.Start-PF -Work { param($s) for($i=0;$i-lt100;$i++){ Start-Sleep -m 50; Report-Progress $i } return "Fini !" } -OnProgress { param($p) Write-PF $script:prg $p } -Then { param($r) Show-PF $r }
$script:. Tester $_shared["_canceled"] pour arrêt propre.ScriptBlock run in a separate runspace (background thread). Never read $script: inside it. Test $_shared["_canceled"] for a clean stop.$_shared. Seul moyen de passer des valeurs UI.Data passed to the runspace through $_shared. The only way to hand over UI values.$script:_controls est inaccessible. Utiliser -With pour injecter les valeurs, lire les résultats dans -Then. Pour un accès direct aux contrôles, utiliser Sleep-PF (synchrone).$result = Wait-PF -Message "Import en cours…" -Work { param($_s) foreach ($item in $_s.Liste) { if ($_s["_canceled"]) { break } # traitement lourd ici… } return "Terminé" } -With @{ Liste = $maListe } -Then { param($r) Show-PF $r -IsSuccess }
DoEvents().Pause length in milliseconds (default: 100). The UI stays responsive throughout via DoEvents().finally).Closes and disposes the dialog. MUST be called at the end of the loop (or in a finally block).$script:_controls est accessible directement dans la boucle appelante. Le dialog est créé au premier appel et reste persistant jusqu'à -End.-End retourne aussi l'état d'annulation final.Sleep-PF -End en fin de boucle, idéalement dans un bloc finally, pour garantir la fermeture du dialog même en cas d'exception.Lock-PF try { for ($i = 1; $i -le 100; $i++) { Set-PF $script:_controls["pb"] -Value $i # ✅ thread UI direct Write-PF $script:_controls["lbl"] "Étape $i/100" # ✅ idem if (Sleep-PF -Ms 80 -Message "Traitement $i/100…") { break } } } finally { Sleep-PF -End # ferme le dialog — garanti même si exception Unlock-PF } Show-PF "Import terminé !" -IsSuccess
Start-PF (runspace + timer) : la commande tourne en arrière-plan, un timer UI vide la file ligne par ligne. Le bloc de commande tourne dans un runspace isolé — aucun accès UI direct dedans (pas de Set-PF, Fill-PF, $ctrl.Text) : passez par -Then.Same engine as Start-PF (runspace + timer): the command runs in the background and a UI timer drains the queue line by line. The command block runs in an isolated runspace — no direct UI access inside (no Set-PF, Fill-PF, $ctrl.Text): go through -Then.Watch-PF { ping "8.8.8.8" -n 10 } -Into $script:rtxLog Watch-PF { Get-ChildItem "C:\Temp" -Recurse } -Into $script:rtxLog -Then { Show-PF "Analyse terminée" -IsSuccess }
Go-PF "Configuration"
$path = Pick-PF -Mode Save -Filter "CSV|*.csv" if ($null -ne $path) { Export-PFGrid -Grid $script:dgvStocks -Path $path }
@{ "Running"="Green"; "Stopped"="Red" }Value→.NET colour table, e.g. @{ "Running"="Green"; "Stopped"="Red" }Fill-PF. Robuste au re-binding : s'abonne une seule fois à CellFormatting et relit ses règles à chaque rendu. Les noms de couleur inconnus sont ignorés sans erreur.Call it after Fill-PF. Robust to re-binding: subscribes once to CellFormatting and re-reads its rules on every render. Unknown colour names are ignored without error.Fill-PF $script:dgvServices (Get-Service) Format-PF $script:dgvServices -Column "Status" -Rules @{ "Running"="Green"; "Stopped"="Red" }
-As Auto) : collection d'objets → Export-Csv, sinon → Out-File. Précisez -As dès que le contenu compte : Json = round-trip fiable de n'importe quelle valeur (hashtable, objet imbriqué), Text = jamais reniflé en CSV. Le format est piloté par -As, pas par l'extension du fichier.By default (-As Auto): a collection of objects → Export-Csv, otherwise → Out-File. Set -As as soon as the content matters: Json = reliable round-trip of any value (hashtable, nested object), Text = never sniffed as CSV. The format is driven by -As, not by the file extension.Save-PF -Data $mesLogs -Path "log.txt" -Append
Auto, un texte contenant , ou ; est relu à tort comme du CSV. Utilisez -As Text (ou -As Json) pour un round-trip garanti. Json → objet · Csv → PSObject[] · Text → string[].In Auto, text containing , or ; is wrongly parsed as CSV. Use -As Text (or -As Json) for a guaranteed round-trip. Json → object · Csv → PSObject[] · Text → string[].$data = Load-PF "settings.csv"
$null -ne $result car l'utilisateur peut annuler la fenêtre.$folder = Pick-PF -Mode Folder -Title "Cible"
fontSize d'un Label, la valeur doit impérativement être une chaîne de caractères (ex: "11").Style-PF $script:btnSave -Type Primary
Set-IconTextPF $script:btnDel -Icon "E74D" -Text "Supprimer"