WPF and PowerShell: Updating a window in real time!

As you will see the last WPF and PowerShell example is a little over complicated when used with the currently released version of Library-PresentationInterface, but I will likely update the library at some point and then scripts like this could then be made more concise.

To make the script easier to read I will list the few basic steps taken by the script.

  1. Generate a special collection class that can inform any WPF window displaying it when it is updated. When a window displays a normal collection any updates will likely not be noticed. This part may eventually be added to the library.
  2. Create two collections and make the first element of the first collection the string "Loading…" and the second element of the first collection the second collection.
  3. Display a window to display the content of the collections. The first collection becomes the tag of the window. A TextBlock is bound to the first element of the first collection(i.e. "Loading…") and a ListBox is bound the content of the second collection.
  4. Add the numbers 1 to 5 to the second collection pausing one second between each number.
  5. Wait for the user to close the window.

I have used a modified version of this script to monitor the log file of an IRC chat room in real time, effectively making the resulting window another chat window(minus the ability to respond). Any amount of information could be added like other chat rooms, RSS feeds, or any other information you can get your hands on, and any filters can be added to that information.

Requirements:

  • New-CAssembly
  • Library-PresentationInterface

WPF Example Script 4

Advertisements

~ by lunaticexperimentalist on April 28, 2008.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: