PulsiForms PulsiForms
PulsiForms v55

PF-Script Stdlib

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

v2.0 PowerShell 5.1 Thread-safe async WinForms
🔔NotificationsNotifications
Show-PF -Message [string] [-IsWarning] [-IsError] [-IsSuccess]
-MessageREQTexte affiché dans le toastText shown in the toast
-IsSuccessswitchToast vert — succès de l'opérationGreen toast — operation succeeded
-IsWarningswitchToast orange — avertissementOrange toast — warning
-IsErrorswitchToast rouge — erreur critiqueRed toast — critical error
💡Durée fixe : 3 secondes. Disparaît automatiquement, ne bloque pas l'UI.Fixed 3-second duration. Auto-dismisses and never blocks the UI.
Exemple
Show-PF "Fichier sauvegardé !" -IsSuccess
Toast-PF -Message [string] [-Title] [-Type] [-Duration] [-Icon] [-Silent] [-OnClick] [-AppId] [-NoFallback] [-PassThru]
toast("Message")  ·  toast("Message", { title: "…", type: "success" })
-MessageREQCorps de la notification (échappé XML automatiquement)Notification body (XML-escaped automatically)
-TitlestringLigne de titre. Sans titre, le libellé est déduit de -TypeTitle line. Without one, the label is derived from -Type
-TypestringInfo | Success | Warning | Error
-DurationintMillisecondes. Windows n'a que 2 paliers : ≥ 15000 = long (~25 s), sinon court (~7 s)Milliseconds. Windows only has 2 tiers: ≥ 15000 = long (~25 s), else short (~7 s)
-IconstringLogo — chemin relatif au dossier de l'app (.\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)
-SilentswitchCoupe le son systèmeMutes the system sound
-OnClickscriptblockCode exécuté au clic — ré-injecté sur le thread UICode run on click — marshalled back onto the UI thread
-AppIdstringAppUserModelID émetteur — pilote le nom et l'icône affichés par WindowsSending AppUserModelID — drives the name and icon Windows displays
-PassThruswitchRetourne { Ok; Native; Error } au lieu du booléenReturns { Ok; Native; Error } instead of the boolean
💡Complément de Show-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.
Exemple
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 -Message [string] [-IsWarning] [-IsError]
-MessageREQTexte affiché dans la boîte de dialogueText shown in the dialog box
-IsWarningswitchTitre "Avertissement" — icône orange"Warning" title — orange icon
-IsErrorswitchTitre "Erreur" — icône rouge"Error" title — red icon
ℹ️Sans switch : titre "Information". Le titre s'adapte automatiquement au switch passé.
Exemples
Alert-PF "Action impossible" -IsError
Alert-PF "Connexion lente détectée" -IsWarning
Alert-PF "Traitement terminé avec succès."
Ask-PF -Question [string]
-QuestionREQTexte de la question affiché dans la boîte de confirmationQuestion text shown in the confirmation box
Retourne bool$true = OUI, $false = NON / Annuler
Exemple
if (Ask-PF "Voulez-vous supprimer cet enregistrement ?") {
  # L'utilisateur a cliqué OUI
  Clear-PF $script:dgvData
  Show-PF "Supprimé !" -IsSuccess
}
Read-PF -Prompt [string] [-Default [string]]
-PromptREQQuestion / libellé affiché au-dessus du champ de saisieQuestion / label shown above the input field
-DefaultstringValeur pré-remplie dans le champ (défaut : vide)Value pre-filled in the field (default: empty)
Retourne string — ou $null si Annuler
⚠️Toujours tester $null -ne $val avant d'utiliser le résultat. L'utilisateur peut cliquer Annuler.
Exemple
$nom = Read-PF "Entrez votre nom :" -Default "Dupont"
if ($null -ne $nom) {
  Write-PF $script:lblBonjour "Bonjour $nom !"
}
🎛️Contrôles UIUI controls
Write-PF $Control $Text [-Append]
$ControlREQRéférence du contrôle cible (Label, TextBox, RichTextBox, ProgressBar…)Target control reference (Label, TextBox, RichTextBox, ProgressBar…)
$TextREQValeur à écrire. Pour un ProgressBar, entrer un entier (ex: "75")Value to write. For a ProgressBar, pass an integer (e.g. "75")
-AppendswitchAjouter au contenu existant au lieu de remplacer (TextBox / RichTextBox uniquement)Append to the existing content instead of replacing (TextBox / RichTextBox only)
⚠ Obligatoire pour modifier l'UI depuis un Start-PF -Work. Ne jamais accéder directement à $script: depuis le runspace de -Work.
Exemples
Write-PF $script:lblStatut "Prêt"
Write-PF $script:txtLog "Ligne ajoutée`n" -Append
Write-PF $script:prgAvancement "75"  # ProgressBar à 75 %
Validate-PF $Control [-Required] [-Regex [string]] [-Min [double]] [-Max [double]] [-Message [string]] [-Silent]
$ControlREQLe contrôle à valider — UN SEUL (TextBox, ComboBox, NumericUpDown…). Positionnel.The control to validate — ONE only (TextBox, ComboBox, NumericUpDown…). Positional.
-RequiredswitchLe champ ne doit pas être vide. Message par défaut : « Ce champ est obligatoire. »The field must not be empty. Default message: “Ce champ est obligatoire.”
-RegexstringMotif que la valeur doit respecter. Ignoré si le champ est vide — combiner avec -Required.Pattern the value must match. Skipped when the field is empty — combine with -Required.
-MindoubleValeur numérique minimale. Une valeur non numérique est rejetée.Minimum numeric value. A non-numeric value is rejected.
-MaxdoubleValeur numérique maximale. Comme -Regex, ignorée sur un champ vide.Maximum numeric value. Like -Regex, skipped on an empty field.
-MessagestringRemplace le message par défaut. Recommandé dès qu'un formulaire a plusieurs champs.Replaces the default message. Recommended as soon as a form has several fields.
-SilentswitchValide sans rien afficher — pour gérer soi-même le retour visuel.Validates without showing anything — to handle the feedback yourself.
Retourne bool$true si le contrôle est valide. En cas d'échec, la commande affiche elle-même un toast orange (sauf -Silent).
💡Valide un contrôle par appel : enchaîner une ligne par champ, chacune avec son return, pour n'afficher qu'un message à la fois. Attention : -Regex, -Min et -Max ne détectent pas un champ vide — ajouter -Required.Validates one control per call: chain one line per field, each with its own return, so only one message shows at a time. Note: -Regex, -Min and -Max do not catch an empty field — add -Required.
Exemple
if (-not (Validate-PF $script:txtNom -Required -Message "Le nom est obligatoire.")) { return }
if (-not (Validate-PF $script:txtAge -Required -Min 0 -Max 130)) { return }

# Ici, tous les champs sont valides
Clear-PF $Control
TextBox / RichTextBox
Remet le placeholder (Tag) ou vide
DataGridView
Supprime source + colonnes
ListBox / ComboBox
Items.Clear()
NumericUpDown / TrackBar
Remet à Minimum
ProgressBar (Panel)
Value = 0
Rating / Gauge
Value = 0
Exemples
Clear-PF $script:txtSaisie
Clear-PF $script:dgvResultats
Clear-PF $script:cmbFiltres
Get-PF $Control [-All] [-Checked] [-Index] [-Prop nom] [-Field colonne]
💡-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.
⚠ La forme 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.
⚠ The 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.
TextBox / RichTextBox
string (vide si placeholder actif)
CheckBox
bool (Checked)
DateTimePicker
DateTime
TrackBar
int (Value)
Rating
nombre (Value) — décimal si demi-étoiles
Gauge
int (Value)
NumericUpDown
decimal (Value)
ListBox
object (SelectedItem)
ComboBox
SelectedItem ou Text
DataGridView
object (DataBoundItem ligne courante)
ProgressBar (Panel)
int (Value) ou $null
Exemples
$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é
Fill-PF $Control $Data [-Where { … }]
💡-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*" }
$ControlREQListBox, ComboBox ou DataGridView cibleTarget ListBox, ComboBox or DataGridView
$DataREQTableau de strings, Hashtables, PSCustomObjects ou DataRows. $null vide le contrôle.Array of strings, hashtables, PSCustomObjects or DataRows. $null clears the control.
ℹ️Accepte @() de Hashtables, PSCustomObjects ou valeurs simples. Les colonnes sont créées automatiquement et auto-redimensionnées.
Exemples
# 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
Add-PF $Control $Items
Remove-PF $Control [$Item] [-Index n]
$ControlREQListBox, ComboBox, CheckedListBox ou DataGridView liéeListBox, ComboBox, CheckedListBox or a bound DataGridView
$ItemsREQUn élément, un tableau, ou une hashtable (ligne de grille)One item, an array, or a hashtable (grid row)
$ItemobjectÉlément à retirer, par valeurItem to remove, by value
-IndexintPosition à retirer (alternative à la valeur)Position to remove (alternative to the value)
💡Complément de 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.
Exemple
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)
Lock-PF -Controls @($script:nomDuControl)
Unlock-PF -Controls @($script:nomDuControl)
⚠ Règle Stricte : Utiliser impérativement un tableau @() et le scope $script:. (Note : Remplacé par Toggle-PF dans de nombreux cas en v2.0)
Exemple
Lock-PF -Controls @($script:btnValider, $script:txtInput)
Toggle-PF $Controls -Action Show | Hide | Enable | Disable
$ControlsREQTableau de contrôles @($script:c1, $script:c2) ou contrôle uniqueArray of controls @($script:c1, $script:c2) or a single control
-ActionREQAction à appliquer à tous les contrôles fournisAction applied to every control provided
💡Idéal pour gérer l'état dynamique de l'interface sans multiplier les lignes de code redondantes.Ideal for driving dynamic UI state without piling up redundant lines of code.
Exemples
# 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
Set-PF $Control [-Value n] [-Add] [-Reset] [-Max] [-Prop nom valeur]
💡Sans -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.
$ControlREQProgressBar, TrackBar, NumericUpDown, Rating, Gauge (ou DateTimePicker : pose la date directement)ProgressBar, TrackBar, NumericUpDown, Rating, Gauge (or DateTimePicker: sets the date directly)
-ValuenValeur à appliquer, clampée automatiquement entre Minimum et Maximum. Arrondie à l'entier, sauf sur un Rating en demi-étoiles qui conserve le 0,5Value to apply, automatically clamped between Minimum and Maximum. Rounded to an integer, except on a half-star Rating which keeps the 0.5
-AddswitchIncrémente la valeur courante de -Value au lieu de la remplacerIncrements the current value by -Value instead of replacing it
-ResetswitchRemet le contrôle à son MinimumResets the control to its Minimum
-MaxswitchPousse le contrôle à son MaximumPushes the control to its Maximum
💡Thread-safe : appelable directement depuis un bloc -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.
Exemples
Set-PF $script:prgCharge -Value 75   # à 75 %
Set-PF $script:prgCharge -Add -Value 10   # +10
Set-PF $script:prgCharge -Reset          # → Minimum
Async · Sync & NavigationAsync · Sync & navigation
Start-PF -Work {...} [-Then {...}] [-Catch {...}] [-OnProgress {...}] [-With @{}]
-WorkREQScriptBlock exécuté en arrière-plan. Ne jamais y lire $script: directement.ScriptBlock run in the background. Never read $script: directly inside it.
-ThenScriptBlockCallback UI exécuté après succès. Reçoit $result.UI callback run on success. Receives $result.
-OnProgressScriptBlockCallback UI pour mettre à jour une ProgressBar. Reçoit $prog.UI callback to update a ProgressBar. Receives $prog.
-CatchScriptBlockCallback UI en cas d'erreur. Reçoit le message d'erreur.UI callback on error. Receives the error message.
-WithhashtableDonnées transmises au runspace via $_shared.Data passed to the runspace through $_shared.
⚠ Règle Runspace : Toujours utiliser -With pour injecter des chemins ou valeurs venant de l'UI.
Exemple
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 }
Wait-PF -Work {...} [-Then {...}] [-Catch {...}] [-With @{}] [-Message str] [-Title str] [-NoCancelBtn]
-WorkREQScriptBlock exécuté dans un runspace séparé (thread background). Ne jamais y lire $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.
-ThenScriptBlockCallback UI exécuté après succès. Reçoit le résultat de -Work.UI callback run on success. Receives the result of -Work.
-CatchScriptBlockCallback UI en cas d'erreur ou d'annulation. Reçoit le message d'erreur.UI callback on error or cancellation. Receives the error message.
-WithhashtableDonnées transmises au runspace via $_shared. Seul moyen de passer des valeurs UI.Data passed to the runspace through $_shared. The only way to hand over UI values.
-MessagestringTexte affiché dans le dialog de progression (défaut : "Opération en cours…")Text shown in the progress dialog (default: "Opération en cours…")
-TitlestringTitre de la barre du dialog (défaut : "Veuillez patienter")Dialog title bar (default: "Veuillez patienter")
-NoCancelBtnswitchMasque le bouton Annuler (opération non interruptible)Hides the Cancel button (non-interruptible operation)
⚠ Même règle que Start-PF : -Work s'exécute dans un runspace isolé — $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).
Retourne le résultat de -Work, ou $null si annulé / erreur
Exemple
$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 }
Sleep-PF [-Ms int] [-Message str] [-Title str] [-NoCancelBtn] [-End]
-MsintDurée de la pause en millisecondes (défaut : 100). Pendant ce délai, l'UI reste réactive via DoEvents().Pause length in milliseconds (default: 100). The UI stays responsive throughout via DoEvents().
-MessagestringTexte du dialog. Peut être changé à chaque appel — le label se met à jour en live.Dialog text. Can change on every call — the label updates live.
-TitlestringTitre de la barre du dialog (défaut : "Veuillez patienter"). Utilisé uniquement à la création.Dialog title bar (default: "Veuillez patienter"). Used at creation only.
-NoCancelBtnswitchMasque le bouton Annuler.Hides the Cancel button.
-EndswitchFerme et dispose le dialog. À appeler obligatoirement en fin de boucle (ou dans un bloc finally).Closes and disposes the dialog. MUST be called at the end of the loop (or in a finally block).
ℹ️Contrairement à Wait-PF (runspace séparé), Sleep-PF reste sur le thread UI : $script:_controls est accessible directement dans la boucle appelante. Le dialog est créé au premier appel et reste persistant jusqu'à -End.
Retourne $true si Annuler cliqué, $false sinon. -End retourne aussi l'état d'annulation final.
⚠️Toujours appeler 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.
Exemple — boucle avec ProgressBar
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
Watch-PF { commande } -Into $RichTextBox [-Then {…}] [-Append] [-NoFollow] [-NoColor]
{ commande }REQBloc exécuté en arrière-plan (cmdlet, exécutable, pipeline). Position 0.Block run in the background (cmdlet, executable, pipeline). Position 0.
-IntoREQRichTextBox cible (un TextBox multiligne fonctionne aussi, sans couleur)Target RichTextBox (a multiline TextBox also works, without colour)
-ThenscriptblockExécuté sur le thread UI à la fin — Set-PF / Fill-PF y sont autorisésRun on the UI thread at the end — Set-PF / Fill-PF are allowed here
-AppendswitchAjoute à la suite au lieu de vider le contrôleAppends instead of clearing the control
-NoFollowswitchDésactive le défilement automatiqueDisables auto-scrolling
-NoColorswitchDésactive la coloration rouge des erreursDisables red error colouring
💡Même moteur que 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 runspaceno direct UI access inside (no Set-PF, Fill-PF, $ctrl.Text): go through -Then.
Exemple
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 -TabName [string]
-TabNameREQNom (ou fragment) de l'onglet cible. Insensible à la casse.Name (or fragment) of the target tab. Case-insensitive.
Exemple
Go-PF "Configuration"
💾Persistance & DataPersistence & data
Connect-PFData -Provider Excel|Csv -Path [string] [-Sheet str] [-Delimiter car]
-ProviderREQExcel (.xlsx) ou CsvExcel (.xlsx) or Csv
-PathREQChemin du fichier sourceSource file path
-Sheetopt(Excel) feuille — vide = 1re feuille(Excel) sheet — empty = first sheet
-Delimiteropt(CSV) séparateur, 1 car — vide = auto(CSV) delimiter, 1 char — empty = auto
💡Read-PFData $src renvoie des objets prêts pour Fill-PF. Write-PFData $src $data écrit, Get-PFSchema $src liste les colonnes. Ou renseignez le fichier dans l'encadré Source de données des propriétés d'une DataGridView : elle se remplit seule à l'ouverture. Join-PFData $a $b -On "Cle" -Add "Col" associe deux sources par une clé commune (jointure façon LookUp).Read-PFData $src returns objects ready for Fill-PF. Write-PFData $src $data writes, Get-PFSchema $src lists columns. Or set the file in the Data source box of a DataGridView's properties: it fills itself on open. Join-PFData $a $b -On "Key" -Add "Col" links two sources on a shared key (LookUp-style join).
Exemple
$src = Connect-PFData -Provider Excel -Path "C:/Data/contacts.xlsx" -Sheet "Contacts"
Fill-PF $DgvContacts (Read-PFData $src)
Fill-PF $DgvContacts (Read-PFData $src -Where { $_.Actif -eq $true })
Write-PFData $src (Get-PF $DgvContacts -All)
# Jointure relationnelle (façon LookUp) : enrichir chaque commande du nom de son service
Join-PFData $cmds $services -On "ServiceId" -RightKey "Id" -Add "Nom"
Export-PFGrid -Grid $Control -Path [string]
-GridREQLe contrôle DataGridView à exporterThe DataGridView control to export
-PathREQChemin complet du fichier CSV de destinationFull path of the destination CSV file
ℹ️Exporte uniquement les colonnes visibles. Encodage UTF8 avec BOM pour compatibilité Excel.
Exemple
$path = Pick-PF -Mode Save -Filter "CSV|*.csv"
if ($null -ne $path) {
  Export-PFGrid -Grid $script:dgvStocks -Path $path
}
Format-PF $Control -Column "nom" -Rules @{…}
$ControlREQLe DataGridView cibleThe target DataGridView
-ColumnREQNom de la colonne dont la valeur pilote la couleur de la ligneName of the column whose value drives the row colour
-RulesREQTable valeur→couleur .NET, ex. @{ "Running"="Green"; "Stopped"="Red" }Value→.NET colour table, e.g. @{ "Running"="Green"; "Stopped"="Red" }
💡À appeler après 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.
Exemple
Fill-PF $script:dgvServices (Get-Service)
Format-PF $script:dgvServices -Column "Status" -Rules @{ "Running"="Green"; "Stopped"="Red" }
Save-PF -Data $obj -Path [string] [-Append] [-As Auto|Json|Csv|Text]
💡Par défaut (-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.
Exemple
Save-PF -Data $mesLogs -Path "log.txt" -Append
Load-PF -Path [string] [-As Auto|Json|Csv|Text]
💡En 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[].
Retourne un tableau d'objets (CSV) ou de strings (TXT).
Exemple
$data = Load-PF "settings.csv"
Pick-PF [-Mode Open|Save|Folder] [-Filter [string]] [-Multi]
⚠️Toujours tester $null -ne $result car l'utilisateur peut annuler la fenêtre.
Exemple
$folder = Pick-PF -Mode Folder -Title "Cible"
🎨Style & ApparenceStyle & appearance
Style-PF $Control -Type Primary | Secondary | Danger | Search
⚠ Note : Si vous modifiez manuellement le fontSize d'un Label, la valeur doit impérativement être une chaîne de caractères (ex: "11").
Exemple
Style-PF $script:btnSave -Type Primary
Set-IconPF $Control -Code [int] [-Size [int]] [-Text [string]] [-Position Left|Right|Top|Bottom]
Set-IconTextPF $IconCtrl $TextCtrl -Code [int] -Text [string] [-IconSize [int]]
-CodeintPoint de code du glyphe MDL2, en notation hexadécimale : 0xE74D. C'est un nombre, pas une chaîne.MDL2 glyph code point, in hexadecimal notation: 0xE74D. It is a number, not a string.
-TextstringLibellé. Sur Set-IconPF, l'icône et le libellé tiennent dans LE MÊME contrôle.Label. With Set-IconPF, icon and label sit in THE SAME control.
-SizeintTaille du glyphe (défaut 14). -IconSize sur Set-IconTextPF (défaut 13).Glyph size (default 14). Named -IconSize on Set-IconTextPF (default 13).
-PositionstringPlace de l'icône par rapport au libellé : Left, Right, Top ou Bottom. Défaut : Left.Icon placement relative to the label: Left, Right, Top or Bottom. Default: Left.
💡Deux commandes, deux usages : Set-IconPF prend un contrôle (icône + libellé dans le même bouton) ; Set-IconTextPF en prend deux — l'icône sur le premier, le texte sur le second. L'icône utilise la police "Segoe MDL2 Assets" par défaut, pour une compatibilité maximale Win10/11.Two commands, two uses: Set-IconPF takes one control (icon + label in the same button); Set-IconTextPF takes two — icon on the first, text on the second. The icon uses the "Segoe MDL2 Assets" font by default, for maximum Win10/11 compatibility.
Exemple
# Icone + libelle dans le meme bouton
Set-IconPF $script:btnDel -Code 0xE74D -Text "Supprimer"

# Icone sur un controle, libelle sur un autre
Set-IconTextPF $script:btnIcone $script:lblDel -Code 0xE74D -Text "Supprimer"
Index des Commandes