Im using powershell w/WPF. I have the following example code that produces a button that animates by moving to the right when clicked, I am trying to figure out the best way of approaching clicking it a second time to animate in reverse back to the original position.
ButtonTest.ps1:
Add-Type -AssemblyName PresentationFramework, System.Drawing, System.Windows.Forms, WindowsFormsIntegration, presentationCore[xml]$xaml='<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" WindowStartupLocation="CenterScreen" WindowStyle="None" Background="Transparent" AllowsTransparency="True" Width="500" Height="300"><Window.Resources><ControlTemplate x:Key="NoMouseOverButtonTemplate" TargetType="Button"><Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}"><ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/></Border><ControlTemplate.Triggers><Trigger Property="IsEnabled" Value="False"><Setter Property="Background" Value="{x:Static SystemColors.ControlLightBrush}"/><Setter Property="Foreground" Value="{x:Static SystemColors.GrayTextBrush}"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Window.Resources><Canvas><Button Name="MovableButton" Canvas.Left="70" Canvas.Top="0" FontSize="12" FontFamily="Calibri" FontWeight="Light" BorderBrush="#111111" Foreground="#EEEEEE" Background="#111111" Height="18" Width="70" Template="{StaticResource NoMouseOverButtonTemplate}">ClickMe<Button.Triggers><EventTrigger RoutedEvent="PreviewMouseUp"><BeginStoryboard><Storyboard><DoubleAnimation Name="ButtonAnimation" From="70" To="207" Duration="0:0:0.25" Storyboard.TargetProperty="(Canvas.Left)" AutoReverse="False"/></Storyboard></BeginStoryboard></EventTrigger></Button.Triggers></Button></Canvas></Window>'$reader=(New-Object System.Xml.XmlNodeReader $xaml)$window=[Windows.Markup.XamlReader]::Load($reader)$Button1=$Window.FindName("MovableButton")$Button1.Add_Click({ write-host ButtonClicked})$window.Show()$appContext=New-Object System.Windows.Forms.ApplicationContext[void][System.Windows.Forms.Application]::Run($appContext)