Over the last few days I've been putting together a comparison of Silverlight and Flex. The result of that I'll publish when I'm done with it, but while doing this I came across a pretty cool flex based spring graph control (and if you read my blog you know I have some sick fascination with them). Source code and all. I'm going to port this to Silverlight over the next few days (I hope). For now, I thought I'd show a few pictures of it in action in flex. The control can be found on adobe and the authors site (Mark Shepherd).
This is a picture of the "roamer demo". The "roamer" allows drilling down into large data sets, only showing a certain amount of attached nodes to the current node. Very useful for drilling into large datasets: (note, click any of these images to be taken to the actual online demo)

The amazon roamer shows how this can be integrated into the amazon web services to navigate across similar products. As you click items, it roams to the item and brings up the similar items...

And the molecule viewer (way cool, and something I'm sure to have my son using once he starts chemistry):

Again, I'm going to port the library, and then potentially these controls over to silverlight and I'll post them here when I'm done.
dc30a7f1-f2c9-4c9a-ac95-37ca3166fb24|0|.0
Posted by
mheydt on
9/23/2008 3:50 PM |
Comments (0)
Generating video frame captures in WPF
I was using windows media center the other night on my new media center pc (ok, its an old pc, but a new install of media center), and I really liked how it goes about creating thumbnail snapshots of the videos. Vista also does this, and I thought that I'd like to try and do something similar in WPF to generate snapshots of videos stored in my p2pDlib project. After reading a few texts and also after a little googling, this had a fairly simple solution after mucking around with some not-quite-right
information that I found.
To do this, create a WPF application, and then use the media player object combined with RenderTargetBitmap, DrawingVisual and CrawingContext objects. The application I build had an image control on the main canvas, and in the Window_Loaded event would execute the following code:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
MediaPlayer player = new MediaPlayer();
player.MediaOpened += new EventHandler(player_MediaOpened);
player.Open(new Uri(@"D:\My Videos\Trailer Park Boys - S06E04 - Where In The Fuck Is Oscar Goldman.avi"));
player.Position = TimeSpan.FromSeconds(15);
player.Play();
}This code instantiates a new media player object, assigns an event handler for when the media is opened, opens a video file, positions the video 15 seconds in, and then starts play of the video.
The trick that I found to this was in having to handle the loaded event and that you apparently need to call the play method. Otherwise, you'll just get a black screen capture.
The event handler then contains the following code;
void player_MediaOpened(object sender, EventArgs e)
{
MediaPlayer player = sender as MediaPlayer;
player.Pause();
RenderTargetBitmap rtb = new RenderTargetBitmap((int)image1.Width, (int)image1.Height, 1 / 200, 1 / 200, PixelFormats.Pbgra32);
DrawingVisual dv = new DrawingVisual();
DrawingContext dc = dv.RenderOpen();
dc.DrawVideo(player, new Rect(0, 0, image1.Width, image1.Height));
dc.Close();
rtb.Render(dv);
image1.Source = BitmapFrame.Create(rtb);
}
This method retrieves the media player and then pauses the video. I'm assuming that since this method is called once the video is loaded and play begins, that we are at the specified frame. Again, I found that this is the only way to get the video to the appropriate frame.
RenderTargetBitmap is then used to make a snapshot of the media player control (it can be used to do this for any WPF control). The object is setup to be the same size as the image on the form, but you obviously make this any size that you desire.
The next trick is in creating a DrawingVisual object, which is used to get a DrawingContext object which is used to actually render the bitmap by calling it's DrawVideo method. The DrawingContext object is then closed, and the Render method called passing in the DrawingVisual object which renders the content of the media play frame to the RenderTargetBitmap. The last thing to do is then to create a BitmapFrame object from the RenderTargetBitmap object and assign that to the image on the form.
As an example of this, here is a snapshot of the window:
53e05854-c257-4c0f-b41b-c685d534bbb2|0|.0
I started playing around today with ADO.NET Data Services, and all the examples I can find use the Northwind database. I never noticed it until now, but Northwind is not installed automatically any more. And it also was not easy to find the database online.
I did find a script to do this at this site. Thanks Jon!
And for good measure, you can get the AdventureWorks database files here on CodePlex.
23601f3a-742b-485a-b131-0238b0780edd|0|.0