Combined power of SharePoint and JQuery part1: Changing the SharePoint Image Picker

Wow… long time since i blogged. Thank god I’m going to the Dutch DevDays to see Scott Hanselman’s session called “How to make your blog suck less” :)

So here is an update of mine about how to use JQuery in SharePoint to do some fancy tricks. I’ll post some more of these tricks later on and I’ll try to be more active as a blogger again. (In which I’ll probably fail)

Have you ever tried to change some of SharePoint’s default controls like the image picker?

Well I have. My customer wanted a image picker that worked exactly like the normal one except for 1 change. It shouldn’t show the selected image as an image but it should only show the URL of the selected image. I tried to change this at server side first by inheriting from the default SharePoint image picker control. This was a rather annoying job as i didn’t seem to get the right result this way. you cannot extend the rich image picker from sharepoint but only the default image picker that doesn’t have the image library function behind it.

When i was looking at the html that was rendered by SharePoint i thought it would be easier to change the html with jquery as with serverside code and this is the result. just save this source to a .js file and include it into your masterpage or aspx page and all selected images in the image picker will be changed to only show the url of the image.

///<reference path="jquery-1.3.2.min-vsdoc.js" />

 

$(document).ready(function() {

    HideImages();

});

 

function HideImages() {

    $("span[id $= '_RichImageField_ImageFieldDisplay']").each(function() {

        var url = $(this).find("img").attr("src");

        $(this).find("a").hide();

        $(this).append("<span class='imgurl'>" + url + "</span>");

        $(this).find("a").each(function() {

            $(this).find("img").each(function() {

                $(this).load(function() {

                    $(this).parent().hide();

                    var imgurl = $(this).attr("src");

                    $(this).parent().parent().find(".imgurl").text(imgurl);

                });

            });

        });

    });

}

It’s as easy as that.

More JQuery fun to post in the future.

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Creating an MVC based website with reusable widgets

After the Asp.net MVC Framework was released i was pretty impressed of how it worked but one of my main problems was how to handle the data on the page that is not the main goal of the specific page.

In ASP.NET MVC every page has its specific controller and views that can handle the data for the page that is requested. for example when you’re building a web shop you’ll probably have a ProductController that handles everything that has to do with the Products in your shop. But when you are browsing a web shop product page you would also like to see other data that has nothing to do with products, for example your shopping basket, current login state etc. Should you add this logic to the ProductController? imo you shouldn’t since the Products controller only responsibility should be the products. So how should we handle this in the MVC framework?

My first idea that came to mind to solve this problem was doing an Ajax request to for example, the shopping basket controller on your view when you would like a shopping basket added to your page. This can be in some situations the best way to do it but in some cases you might not want to use Ajax since then this content can’t be indexed by search engines for example.

An example how to use Ajax widgets is found here: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=310

My main goal was to be able to add widgets to a page without the controller of that page knowing about these widgets. I found some solutions to this called partial requests found here: http://blog.codeville.net/2008/10/14/partial-requests-in-aspnet-mvc/

These partial requests weren’t my favorites also since i didn’t want to put this logic in the view so i developed my own CMS like solution for this problem.

My idea was that a page can have several page zones and page zones contain widgets. widgets and complete page zones should be reusable by other pages so i stored these in my CMS database. how my database is build up you can see in the image below

image

A widget should be able to render itself so i made an abstract BaseWidget class that has a Render Method. A widget can also be a call to a different controller so i made a SubController class that inherits from BaseWidget. The SubController Widget has an Controller, Action and ID so it can call the controller it belongs to.

   1: public abstract class SubControllerWidget : BaseWidget

   2: {

   3:     public string Controller { get;  set; }

   4:     public string Action { get;  set; }

   5:     public object ID { get; set; }

   6: 

   7:     public SubControllerWidget(string Controller, string Action) : base()

   8:     {

   9:         this.Controller = Controller;

  10:         this.Action = Action;

  11:         this.ID = null;

  12:     }

  13: 

  14:     public SubControllerWidget(string Controller, string Action, object ID)

  15:         : base()

  16:     {

  17:         this.Controller = Controller;

  18:         this.Action = Action;

  19:         this.ID = ID;

  20:     }

  21: 

  22:     public override void Render(System.Web.Mvc.ViewContext vc)

  23:     {

  24:         vc.RouteData.Values["controller"] = Controller;

  25:         vc.RouteData.Values["action"] = Action;

  26:         vc.RouteData.Values["id"] = ID;

  27:         IHttpHandler handler = new MvcHandler(vc.RequestContext);

  28:         handler.ProcessRequest(System.Web.HttpContext.Current);

  29:     }

  30: 

  31:     public abstract void SetSettings(WidgetSettings settings);

  32: }

To build a specific widget just inherit a widget from SubControllerWidget and you are ready to go. Set the Controller, Action and ID to call and that specific controller will be called.

To add these page zones and widgets to the pages dynamically i’ve created a CMSController that overrides the OnActionExecuted method so it can insert the page zones and widgets to the model that’s been send to the View.

   1: protected override void OnActionExecuted(ActionExecutedContext filterContext)

   2: {

   3:     if (ViewData.Model == null)

   4:     {

   5:         ViewData.Model = new CMSViewModel();

   6:     }

   7:     string controller = filterContext.RequestContext.RouteData.Values["controller"] != null ? filterContext.RequestContext.RouteData.Values["controller"].ToString() : "";

   8:     string controllerAction = filterContext.RequestContext.RouteData.Values["action"] != null ? filterContext.RequestContext.RouteData.Values["action"].ToString() : "";

   9:     string controllerActionid = filterContext.RequestContext.RouteData.Values["id"] != null ? filterContext.RequestContext.RouteData.Values["id"].ToString() : "";

  10:     IList<PageZone> zones = _cmsRep.GetPageZonesForPage(controller, controllerAction, controllerActionid);

  11: 

  12:     CMSViewModel page = (CMSViewModel)ViewData.Model;

  13:     if (page.PageZones == null)

  14:     {

  15:         page.PageZones = zones;

  16:     }

  17:     else

  18:     {

  19:         foreach (PageZone zone in zones)

  20:         {

  21:             page.PageZones.Add(zone);

  22:         }

  23:     }

  24: 

  25: 

  26:     base.OnActionExecuted(filterContext);

  27: }

 

So now all widgets beloning to a page will be retrieved from the CMSRepository and are added to the CMSViewModel so now it’s the View’s turn to render all widgets.

In my master page I’ve added the following line that is responsible for rendering all widgets:

<% Html.RenderPageZones(Model); %>

For that to work I’ve created a few html extension methods to render the page zones.

   1: public static class HtmlCMSExtensions

   2: {

   3:     public static void RenderPageZones(this HtmlHelper html, CMSViewModel page)

   4:     {

   5:         if (page != null && page.PageZones != null)

   6:         {

   7:             foreach (PageZone zone in page.PageZones)

   8:             {

   9:                 html.RenderPartial("PageZone", zone);

  10:             }

  11:         }

  12:     }

  13: 

  14:     public static void RenderWidgetsInZone(this HtmlHelper html, PageZone zone)

  15:     {

  16:         if (zone != null && zone.Widgets != null)

  17:         {

  18:             foreach (IWidget widget in zone.Widgets)

  19:             {

  20:                 widget.Render(html.ViewContext);

  21:             }

  22:         }

  23:     }

  24: }

In my PageZone view i’ve added the other html extension method called RenderWidgetsInZone so all widgets are rendered by itself.

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VanDerCruijsen.MVC.CMS.Model.PageZone>" %>

<div id="<%= Html.Encode(Model.Name) %>">

name:<%
   1: = Html.Encode(Model.Name)

%>

<%
   1:  Html.RenderWidgetsInZone(Model);

%>

</div>

This is the way I use to create widgets on my ASP.NET MVC pages. If you have any recommendations or better ways how to do it please let me know.

When I have the time I’m going to build an admin controller to be able to add widgets and pagezones via the webinterface since now the only option is to add them in the database by hand.

My sources aren’t really cleaned up so if you want a working source/solution please send me mail or leave a comment.

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

My article about the ASP.NET MVC Framework published in the Dutch .Net Magazine

Hello everyone,

It’s been a while since my last post (again :( ) but I’ve been quite busy testing out the new ASP.NET MVC Framework. I have to say i really like it. Currently I’m building my own little CMS framework on top of the MVC framework so it becomes easier to use widgets or other non main data items on your pages. As soon as it’s in a show able form I’ll  post it on my blog.

I’ve also written an article about the ASP.NET MVC framework for the Dutch .Net Magazine (in Dutch) so if you are a reader of the magazine check out page 22 of the June 2009 release (#25) :)

The Title of my article is: “Volledige controle over je webapplicatie met het ASP.NET MVC Framework” (“Total control over your web app using the ASP.NET MVC Framework”)

The article will also come online sometime but the official site (also used to sign up for the free magazine) www.dotnetmag.nl is still showing #23 as the newest one.

When the pdf is put online I’ll add the link to this post.

I’ve focused on writing about how to build an ASP.NET MVC application using TDD because I think this is one of the major advantages over the “old” way of building web applications in ASP.NET.

If you have any feedback or comments about the article please let me know!

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

ASP.NET MVC framework 1.0 released

After the announcement of silverlight 3.0 i was chatting with a colleague about how cool it would be if asp.net MVC framework would also be released at mix.

My colleague started searching and came up with this link:

http://www.microsoft.com/downloads/details.aspx?FamilyID=53289097-73ce-43bf-b6a6-35e00103cb4b&displaylang=en

Pretty cool huh? I haven’t seen any official press releases from Microsoft but since you can download it it seems that it has been released! 

My guess is that it will be announced on MIX today or tomorrow but I couldn’t wait to share it with you already J 

Geert van der Cruijsen  

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

MIX 09 Keynote: Introducing Silverlight 3.0 (Beta available NOW!!!)

When I came home about an hour ago I turned on my mediacenter pc to listen to some mp3's when I thought.. Hey wasn't MIX 09 starting today? Maybe I can check out some video's already like I could with the pdc.

When I browsed to http://live.visitmix.com/ the Keynote was played LIVE in silverlight :) Scott Guthrie was already talking about StackOverflow.com and after that he started talking about Silverlight 3.0

Silverlight 3.0 is going to bring us some pretty cool stuff like Hardware 3d acceleration and multitouch support. These functions ofcourse are pretty cool but are they really usefull? one of the most important things Scott also announced was SEO optimization for Silverlight 3.0.

In Silverlight 3.0 you will be able to store points in your applications from where you can browse from and to by using your forward / back buttons but you're also able to create a bookmark and ofcourse the most important part is that it can be indexed by search websites so they can link to specific locations in the silverlight 3.0 app.

Another cool thing in Silverlight 3.0 is that if you build an application using some external libraries that the libraries can and will be downloaded only when they are used. and when you use the same library in a different silverlight app it will use your already downloaded version instead of pulling it from the server again saving bandwidth.

Sketchflow is a new feature build in Blend 3.0 which will enable you to create sketches of your design rapidly by dragging and dropping wiggely controls (pencil drawn looking controls) on a screen. You can also create a flow of the application fluently by creating several screens and connecting them together. After this you can add functionality to some navigation buttons (without writing code) to navigate from 1 screen to another. After this you can change your sketches to real working code and you’re done!

Multi Tier Data is another new feature which is working like a proxy representation of your data on the server inside your silverlight app. You can databind your controls to the proxy data and if you update the data it will automatically be synced with the server. It’s also possible for the server to push changes in the data to the client so you don’t have to poll the server anymore.

Scott rounded up his presentation telling that the current silverlight 3.0 package is smaller than the current silverlight 2.0 package and the beta 1 is released today! You can download it at:
http://silverlight.net/getstarted/silverlight3/default.aspx

Scott didn’t say anything about a final release date but he did mention later this year (so probably q4)

I really like the changes and can’t wait to start playing with SL 3.0

Geert van der Cruijsen

 

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Silverlight Design Pattern: the Model View ViewModel (MVVM)

Hi There,

The Customer where I'm currently working at asked me if i could build him a Silverlight 2 app. I've been playing around with Silverilght quite a bit but i haven't really used any design patterns so i came to the idea to search the web if there are any specific Silverlight design patterns.

The only really big pattern i found was the MVVM Model View Viewmodel pattern. This isn't a completly new design pattern (Martin fowler calls it the Presentation Model Pattern)

If you know the MVC pattern which you probably do know this is somewhat alike. The model is your layer which connects to the data and the view is ofcourse xaml based in silverlight. So what does the ViewModel do? The viemodel is used to build specific models for each view in your silverlight app so you can have full advantage of the strong databinding in Silverlight.

There are quite some resources about this pattern which i'll link down here:

I'll be using this pattern at my current assignment and afterwards i'll blog about the results :)

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Set file level permissions in SharePoint using Workflow Foundation

Hello Everyone, 

On my current project we are building a customer facing SharePoint application which has to store files. These files are uploaded with biztalk so we have to set the permissions manually so only the user who the file belongs to has rights to open te file.

We are storing the username of the owner of the file in the metadata of the sharepoint item and we are going to use this to set the permissions after the file is uploaded to sharepoint by Biztalk.

After adding the file we've set up a SharePoint Workflow to move the files to a specific location and we've come up with the idea to also change the permissions in this workflow. How we did this? here's the code to change the permissions of a SharePoint SPItem in the workflow:

   1:  workflowProperties.Item.BreakRoleInheritance(false);
   2:   
   3:  workflowProperties.Item.File.MoveTo(currentFolder + "/" + workflowProperties.Item.File.Name);
   4:   
   5:  SPRoleDefinitionCollection rolecollection = web.RoleDefinitions;
   6:  SPRoleAssignmentCollection roleAssignments = workflowProperties.Item.RoleAssignments;
   7:   
   8:  SPUser user = web.EnsureUser("aspnetsqlmembershipprovider:"+workflowProperties.Item.Properties["Username"].ToString());
   9:  SPRoleAssignment roleAssignment = new SPRoleAssignment(user as SPPrincipal);
  10:  SPRoleDefinitionBindingCollection roleDefBindings = roleAssignment.RoleDefinitionBindings;
  11:  roleDefBindings.Add(rolecollection.GetByType(SPRoleType.Reader));
  12:  roleAssignments.Add(roleAssignment);

 

We are using an aspnetsqlmembershipprovider to store the external users so thats why we add this to the sharepoint username.

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Moved to new Hosting: Digitalibiz.com

Hi All,

Long time since i’ve written my last post… well here’s my excuse: Ofcourse december is filled with the holidays etc but i also went on vacation back to Thailand again in January for 3 weeks. I had a great time there but nothing techie to write about around there :)

After i came back i wanted to switch hosting providers because my old one (www.sohosted.com) didn’t support mssql and for some things I’m working on i want to do with mssql and Linq. I’ve been experimenting with the asp.net mvc framework again and i have to say i really like it. (I hope i have time to write more on that subject soon on this blog)

My new hosting provider is Digitalibiz (www.digitalibiz.com) and the main reason i went to them is because 1 they are cheap and 2 they have mssql support and 3 they allow multiple domains on 1 account.

When you are reading this message the dns is finally changed to my new hosting so i can get rid of the old one. Tnx people at Sohosted for the good hosting i had there for multiple years but it was time to move on. I hope Digitalibiz will be as good as they were.

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Silverlight 2 and Flash 10 put to the test

Today a colleague of mine send me a link of a very cool site: http://www.shinedraw.com/

The guy who build the site is a webdeveloper with 6 years experience in building flash apps and 1 year of Silverlight experience. On his blog are a lot of apps build both in Flash and Silverlight. Some examples are: loading a big external image into the silverlight / flash app and a fps stress test.

http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-image/

http://www.shinedraw.com/mathematics/flash-vs-silverlight-fps-meter-stress-test/

It's very cool to see that the output of both platforms is almost equal, though in most test Silverlight is performing a bit better then Flash 10.

Also if you look at the code that is used in both examples you have to say that programming in Silverlight is a more pleasant experience.

Both platforms have strengths and weaknesses. Microsoft has visual studio which is far out the best IDE out there. Adobe on the other had has the best tools for designers.

The battle for best rich internet platform rages on!

 

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Silverlight 2 Control Toolkit ready for download

Yesterday Microsoft released the first version of the Silverlight Extended controls suite on Codeplex.

This control suite contains a number of special controls that are now available for the public to download and use in their own projects.

an example of what kind of controls are included in the toolkit:

  • TreeView
  • Charts
  • Expander
  • AutoComplete
  • NumericUpDown

On the codeplex site there are online demos of all controls which are included in the toolkit and the controls are also documented in the wiki on the page.

 Example of how the Treeview looks and how you use it:

 

Example of the AutoCompleteBox and how to use it in your xaml code: 

 

You can check out the online demos at codeplex: Controls demo and the Charting Demo

I really think Microsoft did a great job at offering these controls to the community and it will make developing in silverlight easier for everyone.

I liked the Charting part the most and i really look forward in using that in my projects in the future. Just look at how nice these controls look and how easy you can fit them into your project:

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Silverlight 2 Release Candidate Available

Last night Microsoft released the first release candidate for Silverlight 2.0.

 

There are a few new controls added in this release: the Combobox, passwordbox and the progressbar.

you can download the new silverlight release candidate at: http://silverlight.net/GetStarted/sl2rc0.aspx

on Scott Guthries weblog there is a nice explanation on how these new controls work.

New Silverlight controls

the new silverlight Controls (Combobox, passwordbox and the progressbar)

 

note that only the developer tools and runtime are released and not regular silverlight runtime. This is done so developers have time to upgrade their applications before silverlight 2.0 RC1 is actually released to the public.

Happy coding!

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Add documents from a Base64Binary xml element to SharePoint with Biztalk 2006

On my current project we wanted to add documents which come in as attachment through a webservice to a sharepoint document library to store them.

We used Biztalk 2006 to receive the file, get the different files from the xml and then send them to SharePoint. In this blogpost I’ll explain how to do this with a small POC I made.

First off we started with a receive port which is able to receive the xml message (the binary port on the picture) we receive this message into a BinaryMessage message which is linked to the following schema

An example message is looking like this: (where the <document> should have the attachments as a base64binary string.

After receiving the message we want to loop through all the messages in the document so I created a foreach to read all the document elements from the xml.

The code to build the loop is the following:

InitializeLoop :

iteration = 1;

documentCount = xpath(BinaryFile,"count(/*[local-name()='BinaryFileToSharePointTest' and namespace-uri()='']/*[local-name()='Document' and namespace-uri()=''])");

first I set the iteration variable to 1 and I set the documentCount to the amount of document elements that are in the incoming xml file.

Message assignment

BinaryFileWithMetadata = BinaryFile;

binaryMessageCreator = new BinaryToSharePoint.Helper.BinaryMessageCreator();

selectXpath = "string(/*[local-name()='BinaryFileToSharePointTest' and namespace-uri()='']/*[local-name()='Document' and namespace-uri()='']["+ System.Convert.ToString(iteration)+"]/text())";

base64String = xpath(BinaryFile,selectXpath);

binaryMessageCreator.CreateBinaryMessage(BinaryFileWithMetadata,base64String);

configProperties = new VdCruijsenNet.Utilities.Sharepoint.ConfigPropertiesXML();

configProperties.AddProperty("Title","test");

BinaryFileWithMetadata(WSS.ConfigPropertiesXml) = configProperties.ToString();

BinaryFileWithMetadata(WSS.Filename) = "bestandsnaamTest "+System.Convert.ToString(iteration)+".pdf";

In the message assignment we first Create the new outgoing message for each of the documents in the incoming xml file. Then we select the base64binary string with an xpath expression and send it to the binaryMessageCreator.

The binaryMessageCreator creates a new System.Xml.Document (which isn’t a xml file but biztalk doesn’t know that :) from the base64binary string. For the source of the BinaryStreamFactory see below:

After creating the new Message of the type System.Xml.Document, which is actually a byte[] containing the file we add a filename and some metadata which can be stored in SharePoint we send the message with the send shape to sharepoint.

The SendPort is a “Windows SharePoint service” sendport which can automatically add the file to a sharepoint document library.

 

Sendport

Receiveport

As you can see it’s pretty easy to get the binary files from an xml file in Biztalk after you know how you can do it.

Happy Coding

Geert van der Cruijsen

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Upgraded my weblog to Blogengine.net 1.4.5

4 days ago Blogengine.net 1.4.5 was released. A good time for me to upgrade to the newest version since i wanted to split my weblog up to a part to store my messages about my private life and my posts about software development.

Upgrading to 1.4.5 was pretty easy except 1 error i ran into. I’m using blogengine.net together with mysql since my provider doesn’t have mssql and I didn’t really like the xml based blogging. After setting everything up i kept on running into System.Threading.SemaphoreFullExceptions. After posting this on the Blogengine.net codeplex site some people mentioned this was a bug in the mysql.data.dll version 5.1.6 and if you upgrade to 5.2.2 everything should work fine again. So i did and you can see the results now.

I’ve also upgraded the layout of my weblog and added a http://life.vdcruijsen.net section to store my weblog about my life when I’m not developing software but am going out on vacation, trips or have something else to blog about.

Tnx to the Blogengine.net team for this great piece of software!

Geert van der Cruijsen

 

Share on Facebook
Kick It on DotNetKicks.com
Shout it
Post on Twitter

Comparison of Microsoft Silverlight 2 and Adobe Flex by an Adobe Evangelist

I've found a nice read on a comparison between Microsoft's Silverlight and Adobe Flex by an Adobe Evangelist who took a 3 day Silverlight 2 training.

The weblog post starts of with summarizing the good and bad things of Silverlight but it's also nice to read the comments where a big discussion starts between Microsoft employees, Adobe employees and other developers/designers that have to choose between these 2 technologies.

Things he likes about Silverlight:

  • “The first thing I really like is the concept of threading. Being able to spawn off complex tasks without choking the main thread is pretty cool. You could, for example, show a really smooth animation when you are loading a bunch of data in a separate thread.”
  • “A Silverlight application can directly communicate with the HTML document it is hosted on by simply setting a parameter.”
  • “Being able to code in either C# or VB.NET is also a great feature. Especially since these two languages are pretty familiar to people developing for the Windows platform. I’m not one of them, but I found that C# is similar to ActionScript. Next to those languages you also have XAML, which does more or less the same things as MXML.”
  •  

    after that he tells us the things he doesn't like about Silverlight:

  • Code in XAML and C# is really verbose.”
  • “Styling controls is an absolute nightmare! I honestly think that this is going to be Silverlight’s Achilles’ heel!”
  • “Another thing that I really couldn’t grasp is the lack of HTML tag support in text fields.”
  • “I know the Expression tools are still in beta, but it has to be said that all the tools (including Visual Studio, which is no longer in beta) felt extremely buggy and incomplete.”
  • “Over these three days, I got a strong feeling that Silverlight was created by people who don’t know anything about designers.”
  •  

    In my opinion Silverlight and Adobe Air/Flex can both be big and good in their own things and eventually they will start growing towards each other as .Net and Java are also doing. Adobe has its huge designers userbase while Microsoft has a very big developers userbase. I think Adobe will stay the best thing to use for really nice fancy looking webtools while Silverlight will focus itself on the real rich internet Applications instead of websites which will stay the big focus of Adobe.

    I do agree with him that styling can be pretty hard for designers which aren't used to set all those properties and maybe Silverlight is a bit TOO extensible for them. As an example he shows how to change the rotation of an object in Silverlight and Flex:

    Microsoft Silverlight Adobe Flex

    <Button>
    <Button.RenderTransform>
    <RotateTransform Angle="45"/>
    </Button.RenderTransform>
    </Button>

    <Button rotation="45"/>

    I can see a designer will like the simple rotation property but Microsoft gives us (developers) the option to do all kinds of transformation on the object which is more extensible then the way it's done in Flex.

    About the point where he is complaining about how buggy everything is, I think this changed in a good way from Silverlight 2 Beta 1 to Beta 2 and I'm sure that everything will be really stable at the final release. (of course Visual studio isn't in beta… but the Silverlight developer tools are so that's why Visual studio isn't always that stable while building Silverlight applications at the moment)

    I do think Microsoft will have a hard time to get designers to change to Silverlight from their loved environment which they already know but only time will tell.

    http://www.webkitchen.be/2008/07/17/silverlight-the-good-the-bad-and-the-ugly/

    Geert van der Cruijsen

    Share on Facebook
    Kick It on DotNetKicks.com
    Shout it
    Post on Twitter

    Last.Fm Radio Stream Player Gadget 0.5 Released!

    Update 08-06-2010: the last.fm gadget does not work anymore. Last.fm changed their client server protocols and therefore the gadget is not working anymore. I’m not using Last.fm anymore so i’m not planning on updating the gadget in the future

     

     

    Last week my mailbox was flooded by mails of people who were telling me my Windows Vista Sidebar gadget to play Last.fm radio was broken.

    I tested it myself and concluded that this was indeed the case. Last.fm changed their website last week and my guess is that they also changed their streaming service.

    After a full night of debugging I found out what was the problem and I fixed it in a new version which can be now downloaded from the download area.

    If you are interested in what was changed read on. The change was fairly simple, the protocol uses 2 handshakes to connect to the service. The first handshake is to connect to the scrobbling service. The second handshake is used to connect to the streaming service. Before last week requesting the mp3 stream was done by sending the sessionid of the first handshake. Now… it seems you have to send the sessionid you get with the second handshake. It took some time to figure this out but now everything seems to work fine again.

    Protocol example:

    Handshake 1 request:

    http://ws.audioscrobbler.com/radio/handshake.php?version=1.4.2.58376&platform=win32&platformversion=Windows%20Vista&username=geertvdcruijsen&passwordmd5=
    4d9309866b98863c3c3336e50392831b&language=en&player=winamp

    Handshake 1 response from last.fm:

    session=bbe5e763d1e1deb988595cecf1c21e9d stream_url=http://87.117.229.85:80/last.mp3?Session=bbe5e763d1e1deb988595cecf1c21e9d subscriber=0 framehack=0base_url=ws.audioscrobbler.com base_path=/radio info_message= fingerprint_upload_url=http://ws.audioscrobbler.com/fingerprint/upload.php permit_bootstrap=0

    Handshake 2 request:

    http://post.audioscrobbler.com/?hs=true&p=1.2&c=tst&v=1.3.1.1&u=geertvdcruijsen
    &t=1217017120&a=2a060e72c7aae132e8fad06b741be806

    Handshake 2 response from last.fm:

    OK 7e5b82460d2a45e382b81c437ae6a87a http://post.audioscrobbler.com:80/np_1.2 http://87.117.229.205:80/protocol_1.2

    Tune to the right radio channel:

    http://ws.audioscrobbler.com/radio/adjust.php?session=bbe5e763d1e1deb988595cecf1c21e9d&url=lastfm://artist/muse

    Response to channel change request from last.fm:

    response=OK url=lastfm://artist/muse stationname= Muse’s Similar Artists discovery=true

    Request metadata of stream:

    http://ws.audioscrobbler.com/radio/xspf.php?sk=bbe5e763d1e1deb988595cecf1c21e9d
    &discovery=0&desktop=1.3.1.1&time=1217017120321

    I was happy to receive the mails of complaints because this is proof people are actually using my gadget :) Hopefully all problems are fixed now so happy listening!

    Geert van der Cruijsen

    Share on Facebook
    Kick It on DotNetKicks.com
    Shout it
    Post on Twitter