Customizing Vertigo’s Slide.Show

slideshow 

Slide.Show is an open source Silverlight control for publishing highly customizable photo slide shows on the Internet. It has been developed and released to the open source community by Vertigo Software. And since it’s open source, it allows people like me to extend the control for our purposes.

One such purpose that I came across while using this control was the need to allow the user to click the currently shown picture and navigate to a page which shows more details about that image.

Despite searching a lot, I couldn’t find the configuration setting which would allow me to achieve this, so I started digging into the code to add my own setting. Here is how I did it:

Note: I would appreciate zero comments on coding style, and welcome all comments on how to make improvements to this and add other customizations.

I needed to be able to specify a Url for each photo which the user will be able to navigate to when they click the title of the currently showed photo. Lets take a look at what changes I had to make to the Slideshow.js to make this happen:

Add capability to pass in Url - First thing we need to do is to be able to pass in the Url for each slide in the Data File and assign it to the relevant property. After examining the code, it turns out that the Slide Title is rendered using a TextBlock element. This element doesn’t have a Url property, but what it does have is a “Tag” property, which can store an arbitrary value.

First, you need to locate the SlideShow.SlideDescription class in the Slideshow.js file. In this class, locate a function called onSlideLoading. It is in this function that you see the title and the description being assigned to the control. Here’s what the function looks like:

code snippet

What this function is doing is that it is assigning the values that it had read from the Xml file to the TextBlock properties for Title and Description. To this function, we need to add our own code which reads a Url value (that we will pass in the Data.Xml) and assign it to the Tag property of the Title TextBlock. Here’s the change I made to the code to achieve this (red highlight):

code2

Notice that I am assuming a property called e.Url in the incoming event. This (Url) will be the name of the node in the Data.Xml when we send the Url in. Also notice that I am calling a function called setUrl, this is a function that you will have to define in the class (much like how the setTitle and setDescription functions are defined already). Here’s the setUrl function:

code3

Notice that we have assigned the Url to the Tag property of the title TextBlock. That is done. Let’s proceed.

Code to launch the Url when the title is clicked - For the second part, we will need to add an event to the Title TextBlock and then use the eventhandler for that event to launch the Url. Here’ how.

Once again, in the same class (SlideShow.SlideDescription) locate the constructor function (it is the one with a load of Xaml in it). Move down towards the end of the function where events are being registered. Here, we will register our own event. Add the lines as shown below (in red):

code4

What we are doing is that we are registering for the click event on the Title TextBlock. Note, I have also added a code snippet to make the cursor change to a hand when the mouse comes over the Title TextBlock. And, now we simply implement the Event Handler for this event. To do this, you will need to add a function called onMouseLeftButtonDown in the class, see below:

code5

And that’s it, we are done. Now all we need to do is pass in a Url attribute in the Data.Xml file, and it should work just fine - see example below:

code6 

Of course, you can modify this approach to make other areas of the slide clickable as well. I only needed the title to be clickable.



You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

12 Responses to “Customizing Vertigo’s Slide.Show”

  1. Hi Vaibhav,

    I was the project lead for Slide.Show. It’s nice to see people like yourself taking the time to show how you can customize Slide.Show. We took a lot of extra time to architect/comment the code in a way to easily add new functionality like this. Well done! Thanks!

    -Will Allan
    Sr. Software Engineer, Vertigo

  2. @will,

    Thanks for the great tool and your comments Will…

  3. [...] Customizing Vertigo's Slide.Show - Image viewing can use a lot of improvement on the web…Slide.Show may [...]

  4. Do you think you can give some hits for adding link to the image? I am not good at javascript. Should I edit the SlideImage class or still stay with SlideDescription?
    Thank you.

  5. @Xiao, the reason I didn’t try to add links to the image is because it’s counter intuitive. You would expect the slideshow to proceed to the next slide when you click an image, instead of opening a link.

  6. Oh, yeah. But for my application, I am setting the slide show is automatically changing to the next image. And for each image, I want to link to different page. I try to use silverlight instead of flash. You see what I mean? Thanks

  7. In this case, you need to locate which Xaml Element is being used to display the image and add a click event handler to that element. I did not explore that idea because I didn’t need it.

  8. In the SlideImage class, the Xaml is assigned:
    var xaml = ”;

    My guessing is, I need to add:
    this.SlideImage.addEventListener(”MouseLeftButtonDown”, SlideShow.createDelegate(this, this.onMouseLeftButtonDown));
    this.SlideImage.Cursor = “Hand”;
    at the end of constructor of SlideImage class. And do the rest like you did, correct?

  9. That looks right though I can’t be sure and I can’t tell surely without looking at the code. Please test this and let everyone know if it worked for you.

    Thanks.

  10. Sure. Just want to confirm that, the code you did, “this.titleTextBlock” is from the Xaml element, which has , right? If it is , then you need to use “this.titleTextBlock123″, correct?
    Thank you.

  11. Yes, the code is from the Xaml element.

  12. Tried few times, didn’t success.
    I did pretty much the same except doing all these in the SlideImage class and replace titleTextBlock to image for assigning value to the element.

    Any idea?

Leave a Reply