Animated GIF

Jul 12, 2014 at 12:41 AM
Does anyone know if it is possible to display an animated gif or png file in a new-stackpanel or a new-grid?

I found the new-image commandlet, and I can load the image but it does not animate.

Any help would be appreciated.
Jul 13, 2014 at 7:12 AM
The simplest thing, honestly, is to use the browser control
New-WebBrowser -Source
stackpanel {
TextBox -Name Source
button "Load" -On_Click { $Browser.Source = $Source.Text }
webbrowser -Name Browser
} -Width 300 -Height 300 -show
The alternative is to read the frames from the gif and create a frameAnimation yourself (or grab some code from someone who already did that, like

See here, in C# for a "simple" example of the code required:
Jul 17, 2014 at 1:33 AM
Hi Jaykul,

Thanks for your response!
I will give it a shot...
Aug 29, 2014 at 11:47 PM
Edited Aug 29, 2014 at 11:48 PM

The loading a gif in the browser didn't work like i expected. I am trying to popup a window with some sort of an activity indicator while a process is running.
New-ProgressBar seems too tricky to use.

I did manage to take a couple of the RenderTransform examples together, but I can't seem to get the animation to occur within a stackpanel or a uniform grid. The animation always shows up in its own independent window, followed by a new window with the grid.
New-UniformGrid -Width 200 -Height 200 {
new-rectangle -width 10 -height 50 -fill red -show -RenderTransform {
    New-RotateTransform -CenterX 5 -CenterY 100 } -On_Loaded {
    $da = New-DoubleAnimation -From 0 -To 360 -Duration ([Timespan]::FromMilliseconds(350)) -RepeatBehavior Forever;
     start-animation -InputObject $this.RenderTransform -Property Angle -animation $da
     New-Rectangle 'Yellow'
     New-Rectangle 'Green'
     New-Rectangle 'Red'
 } -show
Aug 30, 2014 at 12:39 AM
Edited Aug 30, 2014 at 12:39 AM
I think what you want is: New-ProgressBar -IsIndeterminate
StackPanel -Name Panel -Margin 2 {
   Label "Full Name:"
   # The On_TextChanged thing is just to enable the submit button after the user's typed at least two things with a space...
   TextBox -name "Name" -Height 24 -On_TextChanged { $submit.IsEnabled = $this.Text.split(" ").Length -ge 2 }

   # IsDefault so they can click with ENTER
   # IsEnabled:$false so it starts disabled
   Button "Click Me" -Name submit -IsEnabled:$false -IsDefault -On_Click {
      # You could just use Add-ChildControl, but I want it at the top:
      $This.Parent.Children.Insert(0, (New-ProgressBar -IsIndeterminate -Height 16) )

      # Let's simulate some work by waiting a couple seconds:
      Register-PowerShellCommand -In "0:0:2" -Run -Once {
         # And then stop looking like we're working
} -On_Loaded { $name.Focus() } -Show
Aug 31, 2014 at 3:05 AM
Thanks! That is what I needed -- a progress bar that keeps going until the window is closed:
$MyProcess = start-process notepad.exe -Passthru
new-stackpanel -height 100 -width 100 { 
      new-label "Hello" ; New-ProgressBar -IsIndeterminate -Height 16; 
      new-button "Finish" -Width 100 -VerticalAlignment Bottom -HorizontalAlignment Right -On_Click {
      (get-process -ID $MyProcess.Id).CloseMainWindow();
Get-ParentControl |Set-UIValue -passThru | close-control }} -show