Sunday, June 29, 2008 2:29 PM
Tim Rule
WebClient and LINQ Demo
This sample illustrates a simple usage of the WebClient and a LINQ query. The WebClient makes requests to an RSS feed from Adobe's kuler API which contains color themes defined by kuler users. The themes are then used to colorize an illustration. Silverlight has a SyndicationFeed Class which is designed to work with feeds. This demo however, utilizes the WebClient to show how a xml request can be queried by LINQ.
Select various color themes in the demo below to colorize the picture.
The WebClient makes a URI request to the RSS service. The result is handled by a DownloadStringCompleted handler.
The LINQ builds and array of objects of an inferred type. There is also a swatches array object that is built from a LINQ sub query.
I've added an AnimateColor method to the Animate class used in previous blog posts. The method builds a ColorAnimationUsingKeyFrames animation with with a start and finish SplineColorKeyFrame to support weighted animations.

To make this sample image I used Microsoft Expression Designer. First I drew a simple solid color illustration. I then made a compound path with the similar colored objects. Making the compound path puts the grouped shapes into one path. This means the entire image is defined as just 5 Path elements when exported to XAML. 