UPDATE 2: YouCube 3 (based on Google Chromium) available here!

UPDATE: Source code now available!  See this post.

My YouCube demo is now interactive! :)  Based on code and ideas from Jeremiah Morrill’s excellent Win32Renderer – the main difference is [techie bit coming; skip if bored] this demo acts as an IAdviseSink for the IViewObject exposed by the HTMLDocument…  The upshot of this is it only refreshes the page when something changes, rather than regularly updating with a timer.

To obtain the actual page snapshot, IViewObject.Draw is used.  The image is copied to a WriteableBitmap and rendered as a Viewport2DVisual3D (both new in .NET 3.5).

image

For the interactivity, things become a little hairy…  Like Jeremiah’s Win32Renderer, moving the mouse over the page also moves a hidden WebBrowser control, ensuring the relevant part of the page is under the mouse.  This is nasty, but mostly grants us full browser functionality; you can hover, click links, type and select text.  Dragging scrollbars doesn’t currently have the desired effect, but you can still click them or use the keyboard (if you’re willing to take a crack at fixing this, let me know) :)

You’ll find some pages behave better than others.  For example Google Maps is pretty heavy on refreshes (you might get the browser pausing occasionally and the ‘hidden’ window appearing for a time) while Live Search Maps is actually pretty manageable (even dragging round Birds Eye View).  YouTube and Next2Friends work surprisingly well (as they’re using Flash video, not all updates make it through IViewObject / IAdviseSink… the videos will stop after a while, unless you move the mouse).

The "loading" (progress) indicator has temporarily gone.  Previously it was using the DownloadProgress event exposed by the System.Windows.Forms.WebBrowser.  It’s now using the .NET 3.5 WebBrowser, but unfortunately that doesn’t seem to offer a progress event.  I’ll post an update here if / when I look for an alternative :)

To take it for a spin (!) you can click the image above or right here for the ClickOnce application.  If you’re still running pre-RTM 3.5 SP1 be sure to upgrade first.  Also note it can potentially run very slowly on older machines..

kick it
About these ads