14 Oct |
|
PoshBoard binds events to different kinds of controls, these events transform Silvelright items on your page via PowerShell script result...
Events are able to invoke script-based commands when user interacts with your portal. As for now, 3 controls propose events (this will be extended in future updates), and every Silverlight object are possible targets for updates. The "event-enabled" controls are :
Of course every controls will potentially manage every kind of events managed by Silverlight and WPF, but I decided to keep it simple for the first release.
PBElement object exposes a property called Events. It's a List of PBEvent object. A PBEvent object has 5 properties :
We will now go a bit deeper in this, specially on Script, Target and References properties because -Source and -Name are properties easy to understand.
Sample 1: basic event creationIn this example we will create a basic layout with a grid that contains a button and a textbox. When you click on the button, a Get-Process script is invoked and the result appears in the textbox. You can see here that I added an event to the button.
add-pbevent -input $button -name click -script "Get-Process" -target $outputbox I invoke the "click" event, I add "Get-Process" as script code and specify that the control $outputbox is my target for script result. The result will depend of the target type. PoshBoard analyzes your dynamic controls and adapt the script result : if I put a Chart object as a target, PoshBoard would take your returning PBElement object and update the chart with the ChartSeries in your PBelement object. Sample 2 : Chart target with multiline event scriptHere's another example with this basic tehcnique. Here I need to put a script on several line, longer than a simple "get-process". You're able to use a string variable in PowerShell to put multiline scripts : As you can see, PoshBoard uses now the $script variable in -Script parameter. I just defined a chart as a target instead of the textbox, and PoshBoard knows that the script return a "chart" PBElement, and uses it's content (properties, chartseries) to update the target. Of course, if your event's script doesn't return a PBElement of type "Chart", an error will occur. In the next post, we'll discover more advanced event handling, dynamic script modification with Referencesproperty and other way to use / reuse part of the main code in your events.
Only registered users can write comments!
Powered by !JoomlaComment 3.26
3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved." |
|||||
| Last Updated on Thursday, 15 October 2009 09:31 |



