In my last post about Flickrlight I mentioned creating a simple Flickr Image Browser in Silverlight. Feedback is required please.
Archive for the ‘silverlight’ category
Silverlight Flickr Image Browser
October 27th, 2008Flickrlight – Silverlight 2 compatible Flickr API
October 26th, 2008In learning Silverlight 2 I needed some self imposed tasks, one such task was to build a simple Flickr image browser, among other things. In doing so as most people would I found a .net Flicker API called FlickrNet. However when you try to add a reference to FlickrNet from my Silverlight 2 project I encountered a few issues with projects not loading. However after some research and hacking I was able to convert the FlickrNet project to Silverlight. Converting the project was the easy part but it was going to be just too hard to get the entire library working because of its reliance on a lot of calls to methods that are not available in the Silverlight Core CLR.
Therefore I have had to strip the existing FlickrNet functionality down, I have decided to christen it Flickrlight and now have a simple working demo of the Flickr Browser Application.
The code is fairly similar to what FlickrNet, for those of you who are familiar with the existing API.
1: private void btnGetPhoto_Click(object sender, RoutedEventArgs e)
2: {
3: PhotoSearchOptions pso = new PhotoSearchOptions();
4: pso.Tags = feedURL.Text;
5: Photo p = new Photo();
6: p.ApiKey = ApiKey;
7: p.Secret = SharedSecret;
8: p.OnResponseCompleted += p_OnResponseCompleted;
9: p.BeginPhotosSearch(pso);
10: }
One of the few changes is that the calls being made are Asynchronous and hence require the subscription to the Completed Event.
1: private void p_OnResponseCompleted(FlickrResponseRecievedCompleteEventArgs<FlickrBase> e)
2: {
3: Action bindToList = () => imageList.ItemsSource = ((Photos)e.ResultValue).PhotoCollection;
4: this.Dispatcher.BeginInvoke(bindToList);
5: }
At this stage all I have done was to begin to move the Search for Photos functionality, however over the next few weeks I will move some more of this functionality across. I will also make Flickrlight available on Codeplex (unless someone tells me otherwise). Seeing as this will be my first foray into the world of open source if anyone has any experience with what I should be doing here, your help will be greatly appreciated.
The Devils work, in SILVERLIGHT
October 25th, 2008Hopefully that got your attention. But its not really the devils work. Simon has this theory about why video games and how its the devils work an opinion I do not fully share. Everything in moderation I say including moderation. Anyway I digress , The ninemsn crew has posted a fantastic video of the game QUAKE being ported to SILVERLIGHT yes SILVERLIGHT.
Adam Kinney has a interview with the developer Julien Frelat about the process. I hope we get to see more in the near future.
MD5CryptoServiceProvider for Silverlight
October 23rd, 2008The Silverlight clr does not have a MD5 implementation so your on your own when it comes to “signing” calls to REST based web services, like Flickr. A quick google found a clean implementation written in managed code, targeting the compact framework. The managed MD5CryptoServiceProvider was created by GL Conseil/Flow Group SAS. It is available for download from their website, I have also made MD5CryptoServiceProvider Source file available for here for download.
How To: Convert a normal Class Library Project to a Silverlight 2.0 Class Library Project
October 23rd, 2008
So you want to add a Normal Class Library Project to a Silverlight application, you think to your self how hard could this be despite the Visual Studio Warnings. Well for the most part its fairly simple, however there are a number of problems that I faced when doing exactly that.
Thanks to Neil Mosafi’s post on converting class library project for Silverlight consumption, I found 2 methods of doing the conversion.
1.) Create a NEW Silverlight Class Library Project and then ADD your EXISTING code files to the project
2.) Hack the csproj file to change its signature (details are courtesy of Neil Mosafi’s post) VS.NET 2008 believes that its a Silverlight Project (don’t forget the changes needs to be made to both the DEBUG as well as RELEASE sections)
Initially I went about making these changes using method 2 however I kept finding a number of issues relating to duplicate references , especially with the HttpWebRequest object and a few other things.
I also needed to change all non generic collections to use their generic equivalents as all non generic collections are not included in Silverlight 2.0
The Serializable attribute is not part of the coreclr, therefore it has to go, XML Serialization is your friend. Rockford Lhotka has started work on an alternative to the Serializable attribute however its extremely limited at this stage, The Silverlight Serializer may suit your needs so do check it out.
The project I was playing with also used a little bit of XPath Navigation and some other System.XML namespace classes that are not part of the cut down version, so I have to change the code to use Linq to XML
There were a whole bunch of other things that I fixed up and was good to go when I realized that the project changes were not referencing the correct mscorlib and system.xml libraries, however the compiler did not seem to mind to much which baffled me. At this point I decided that the safer way was to go down option 1, simply because I thought it would give a much better jumping off point, lo and behold it has. I am pretty close to having it compile correctly for the Silverlight application which I intend to share.
At the end of this all my advice in converting is to go with method 1, as its just much more fool proof.



