Announcing the release of PowerBoots 0.1
This release of PowerBoots is the most exciting release software I’ve cranked out in awhile. It finally has almost all of the features that I have thought of so far (we’re still missing proper support for attached properties).
- You can create pretty much any WPF element, including ones I haven’t thought of adding yet (use Add-BootsFunction to add a new assembly or a single type).
- You can create graphical user interfaces from PowerShell 1.0 all the way to the latest PowerShell 2.0 CTP.
- You can create your WPF GUIs
-Asyncin their own threads, or inline in PoshConsole, or as synchronous dialogs that return values when they close. - You can capture screenshots of your UIs (eg: generate .jpg charts from Visifire). You can even do so without displaying them!
- You can take advantage of XAML Data Templates to generate graphical representations of any objects in the PowerShell pipeline.
- You can add to, or modify your running GUIs from the command line.
You can read the “and much much more” between the lines right?
Breaking Changes and New Features
The big new thing in this release is that I’ve added a compiled module (PoshWpf) which contains several cmdlets, and gives us some major new functionality in exchange for a break in the syntax. The syntax change is pretty simple, really, and the new threading functionality (and PowerShell 1.0 support for the cmdlets) is awesome (if I do say so myself) .
New-BootsWindow replaces Out-Boots
New-BootsWindow is a compiled cmdlet, and in addition to all of the features already present in the now deprecated Out-Boots, it features a few important new features. Incidentally, I’ve actually left the old Out-Boots function in the code, just in case, but I’ve renamed it to Out-BootsWindow, and changed the “Boots” alias to point at the new New-BootsWindow.
ScriptBlock Content
The biggest change to your scripts is going to be a change from piping objects into Out-Boots, to creating your objects in a scriptblock parameter to New-BootsWindow. This allows the script to create the UI elements entirely within the new thread. Since we’ve switched the “Boots” alias to point to New-BootsWindow, anything you used to write like this: ... | Boots you should now be able to write like this: Boots { ... } and get the same result. Additionally, to make the syntax of our little DSL just a little bit slicker, I now allow you to pass scriptblocks for just about everything (particularly for the main content parameters). An example that looked like this, before:
StackPanel -Margin 10 -Children $(
TextBlock "The Question" -FontSize 42 -FontWeight Bold -Foreground "#FF0088"
TextBlock -FontSize 24 -Inlines $(
Hyperlink $(
Bold "Q. "
"Can PowerBoots do async threads?"
) -NavigateUri "_" -On_RequestNavigate { $global:Answer[0].Visibility = "Visible" }
)
TextBlock -FontSize 16 -Inlines $(
Span -FontSize 24 -FontWeight Bold -Inlines "A. "
"Not this way!"
) -OV global:Answer -Visibility Collapsed
) | Out-BootsWindow
Can actually end up like this, now (and produce the same output):
Boots {
StackPanel -Margin 10 {
TextBlock "The Question" -FontSize 42 -FontWeight Bold -Foreground "#FF0088"
TextBlock -FontSize 24 {
Hyperlink {
Bold "Q. "
"Can PowerBoots do async threads?"
} -NavigateUri " " -On_RequestNavigate { $global:Answer[0].Visibility = "Visible" }
}
TextBlock -FontSize 16 {
Span "A. " -FontSize 24 -FontWeight Bold
"Oh yes we can!"
} -OV global:Answer -Visibility Collapsed
}
}
The Async Parameter
If you specify -Async, the new popup window is spawned in a new thread, and all of it’s events etc. are handled on that separate thread. This is actually what happens anyway when you run New-BootsWindow from a host that’s not running in STA mode, but if you don’t specify -Async, we fake the synchronous result so that you can use Write-Output within a dialog to prompt and get a result “returned” from New-BootsWindow. The cool thing about -Async is that not only can you continue using your console, you can run additional windows, and you can even use the new Invoke-BootsWindow cmdlet to run scripts within that window’s thread so you can change the GUI content, etc.
The Passthru Parameter
The -Passthru parameter causes the New-BootsWindow to output the window object that it has created to the pipeline. It’s really only useful when you also specify the -Async parameter, since otherwise the window will be closed before you can use it. Furthermore, because it’s a UI element, you can’t really do very much directly on the Window object without the use of our other cmdlets
The BootsWindow Collection
When you create a New-BootsWindow, the PowerBoots module (or snapin, for v1 users) tracks the window for you, so you can get ahold of it again later to run scripts against it, take screenshots, close it, etc. To enable this we have three new cmdlets:
Get-BootsWindowreturns the windows, and supports filtering by title or index.Remove-BootsWindowwill clear the list of windows that have already been closed, when called without parameters, or will close (and remove) windows that are still running if you pass a specific window, index, or window title.Invoke-BootsWindowlets you run scriptblocks in a specific window’s thread
Export-BootsImagelets you take a screen capture of the contents of a window (or of a specific control)
Add and Remove Templates
There are three new cmdlets for managing XAML source files. Add, Remove, and Get BootsTemplate. These allow you to specify additional XAML files (beyond the default.xaml), and those templates are always automatically loaded into each new window, so you can specify styles, resources, data templates and even new WPF Templates (I’ll throw up an example using the ones from WPF Themes later this weekend).
Download and Source now hosted on CodePlex
Well, that’s enough for the highlights for now. I’ve included the first blush efforts of a ps1xml format and data types files (which get loaded automatically with the module on PowerShell 2, but not v1), and I haven’t yet written up the help files for the compiled cmdlets. Look for more help and examples and maybe even some cleaned up sample videos over the weekend. Please file any problems you have as bugs on Boots.CodePlex.com, where you can find the latest release.
I do want to point out that I’ve left the version number at 0.1 … I really want to add some explicit support for attached properties, and I’m sure I’ve missed a bug or two somewhere along the line lets consider this another solid beta release.
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=0b00377a-7c0c-4703-abb8-4effc7afedbd)
more great work for you. I think boots is going to be a killer app in the powershell ecosystem.