Question modification d'une variable précédente

Plus d'informations
il y a 10 ans 2 mois #21621 par Laurent
Bonjour à tous,

Mon projet avance bien.

Cette fenêtre fonctionne parfaitement mais je souhaite que lorsque [code:1].\..\SCRIPT\\"Firefox.ps1\" -Wait [/code:1] contenu dans l'événement de mon bouton est terminé cela modifie la variable label \"as\" pour montrer visuellement que le logiciel est installé hors actuellement la variable contenu dans l'événement n'effectue aucun changement car elle garde la variable précédente contenu dans le début du script [code:1]$labelas = \"\"[/code:1] je souhaite donc qu'après un clic sur le bouton cela change la variable en [code:1]$labelas = \"\"[/code:1] .

Comment changer donc cette variable $labelas pour que cela s'affiche dans mon interface graphique ?

Un grand merci à celui qui me sauvera la vie.


[code:1]#################################################################
# Chargement des Librairies
#################################################################
[Reflection.Assembly]::LoadWithPartialName(\"PresentationFramework\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"PresentationCore\"«»)
[Reflection.Assembly]::LoadWithPartialName(\"WindowsBase\"«»)
#################################################################



$labelas = \"\"




[xml]$xaml = @\"
<Window
xmlns=\"schemas.microsoft.com/winfx/2006/xaml/presentation\";
xmlns:«»x=\"schemas.microsoft.com/winfx/2006/xaml\";
xmlns:d=\"schemas.microsoft.com/expression/blend/2008\";
xmlns:mc=\"schemas.openxmlformats.org/markup-compatibility/2006\";
xmlns:local=\"clr-namespace:WpfApplication1\"
Title=\"MainWindow\" Height=\"350\" Width=\"525\">
<Grid>
<Button x:Name=\"button\" Content=\"Button\" HorizontalAlignment=\"Left\" Margin=\"416,272,0,0\" VerticalAlignment=\"Top\" Width=\"75\"/>
<Label x:Name=\"label4\" Content=\"Label1\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"47,54,0,0\" VerticalAlignment=\"Top\" Width=\"155\"/>
<Label x:Name=\"label1\" Content=\"Label2\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"47,88,0,0\" VerticalAlignment=\"Top\" Width=\"63\"/>
<Label x:Name=\"label2\" Content=\"Label3\" HorizontalAlignment=\"Left\" Height=\"40\" Margin=\"47,133,0,0\" VerticalAlignment=\"Top\" Width=\"84\"/>
<Label x:Name=\"as\" Content=\"$labelas\" HorizontalAlignment=\"Left\" Height=\"29\" Margin=\"10,54,0,0\" VerticalAlignment=\"Top\" Width=\"32\" FontFamily=\"Wingdings\"/>
<Label x:Name=\"as1\" Content=\"\" HorizontalAlignment=\"Left\" Height=\"33\" Margin=\"10,97,0,0\" VerticalAlignment=\"Top\" Width=\"32\" FontFamily=\"Wingdings\"/>
<Label x:Name=\"as2\" Content=\"\" HorizontalAlignment=\"Left\" Height=\"38\" Margin=\"10,135,0,0\" VerticalAlignment=\"Top\" Width=\"32\" FontFamily=\"Wingdings\"/>

</Grid>


</Window>
\"@


$reader=(New-Object System.Xml.XmlNodeReader $xaml)
$Window=[Windows.Markup.XamlReader]::Load( $reader )


#Connecter les controles
$button1 = $Window.FindName('button')

#Events
$button1.Add_Click({




.\..\SCRIPT\\"Firefox.ps1\" -Wait

$labelas = \"\"

.\..\SCRIPT\\"7zip.ps1\" -Wait





})







$Window.ShowDialog() | Out-Null


#$Window.ShowDialog()[/code:1]<br><br>Message édité par: laurenzo34000, à: 25/03/16 10:57

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

Plus d'informations
il y a 10 ans 1 mois #21637 par Laurent
J'ai trouvé la solution


Code WPF
[code:1]&lt;TextBlock x:Name=\&quot;zip\&quot; HorizontalAlignment=\&quot;Left\&quot; Height=\&quot;32\&quot; Margin=\&quot;80,87,0,0\&quot; TextWrapping=\&quot;Wrap\&quot; VerticalAlignment=\&quot;Top\&quot; Width=\&quot;27\&quot; FontSize=\&quot;29.333\&quot;&gt;&lt;Run Foreground=\&quot;Red\&quot; FontFamily=\&quot;Wingdings 2\&quot; Text=\&quot;S\&quot;/&gt;&lt;Run Foreground=\&quot;Red\&quot; FontFamily=\&quot;Wingdings 2\&quot; Text=\&quot; \&quot;/&gt;&lt;/TextBlock&gt;[/code:1]

Pour changer la couleur le texte d'un textblock ou d'un label

Il faut connecter le controle

[code:1]$zip = $Window.FindName('zip')[/code:1]




Puis modifier ce que l'on souhaite changer dans cet exemple le style de caractère, le texte et la couleur du texte


[code:1]$zip.FontFamily =(\&quot;Wingdings 2\&quot;«»)
$zip.Text = (\&quot;R\&quot;«»)
$zip.Foreground = (\&quot;Green\&quot;«»)[/code:1]

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

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