PSUI Radio
PSUI.ps1:
|
$erroractionpreference = 'silentlycontinue' function ButtonsName{ function RunUI($xamlpath){ [xml]$xaml = Get-Content -Path "$xamlpath\interface.xaml" # Accéder aux éléments XAML # Définir l'image de fond dynamiquement # Ajouter les événements Checked aux boutons radio pour mettre à jour la variable # Ajouter l'événement Click au bouton OK # Ajouter l'événement Click au bouton Cancel # Afficher la fenêtre RunUI($here) |
script1.ps1:
| $Global:here = (Get-Location).Path "Script1" > "$here\output.txt" |
...
interface.xaml:
| <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Exemple UI" Height="300" Width="400" Background="White"> <Grid x:Name="MainGrid"> <StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"> <RadioButton x:Name="Bouton1" Content="Bouton 1" GroupName="Options" Margin="10"/> <RadioButton x:Name="Bouton2" Content="Bouton 2" GroupName="Options" Margin="10"/> <RadioButton x:Name="Bouton3" Content="Bouton 3" GroupName="Options" Margin="10"/> <RadioButton x:Name="Bouton4" Content="Bouton 4" GroupName="Options" Margin="10"/> <RadioButton x:Name="Bouton5" Content="Bouton 5" GroupName="Options" Margin="10"/> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="10"> <Button x:Name="OkButton" Content="OK" Width="75" Margin="10"/> <Button x:Name="CancelButton" Content="Cancel" Width="75" Margin="10"/> </StackPanel> </StackPanel> </Grid> </Window> |
no more
to run script instead of script1.ps1, replace:
$global:Button1Name = "Script1"
by
$global:Button1Name = "<your script name>"
/image%2F0881799%2F20140610%2Fob_a8c7fe_logo2.jpg)
Commenter cet article