Silverlight in mojoPortal for mere mortals

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
1/11/2009 5:17:31 PM
Gravatar
Total Posts 18

Silverlight in mojoPortal for mere mortals

Hello, all!

Well, everybody is talking about Silverlight these days, so I would like to put couple of cents here and share with you extremely simple techique how it could be useful to mojoLovers.

I will talk about Slide Show/Image Gallery only, but the same technique may be usefull in other cases also.

I googled the Web looking for nice and attractive Image Gallery for my project kaskad-dc.spb.ru (that is powered by mojoPortal of cause! ) and found Vertigo SlideShow control (live example, manual and download instructions) here: www.vertigo.com/SlideShow.aspx

Briefly speaking this is Open Source control for Silverlight 1.0 (pure JavaScript, that's amazing!) that was developed by commercial organisation with huge creativity and with the cutting edge quality. I was really imressed and I would like to thank them in public.

Since it is Open Source and since it is free I did following:

1. I put files Silverlight.js and SlideShow.js in /ClientScript folder of the site. (They both are provided with SlideShow release)

2. I followed simple 3-step Quick Start Guide to configure SlideShow control.

You may see the result here: kaskad-dc.spb.ru/gallery.aspx

 

If you love it, take a deep breath - I will jump 2 steps further and continue with some boring C# implementation details.

 

"Better is the worst enemy of good", so after first couple hours of joy and excitement I have realised, that publishing of real images in real site is a little bit boring task. Since currently I am playing with Silverlight version 2, then after some googling I found Vertigo SlideShow2 control developed with C# specially for this newer version. New control is able to play video as well, so one can mix images with something more exciting.

It is Open Source and free also, so deployment steps were following:

1. I put file Vertigo.SlideShow.xap in /ClientBin folder of the site.

2. I followed 3-step configuration process which is even easier and more flexible for second version.

3. I realilsed, that Html Content feature of mojoPortal is more than enough to embed SlideShow2 control into web-page, because it is just <object> tag with some specific parameters.

Ta-daaa! You may see the result here: kaskad-dc.spb.ru/gallery.aspx

 

The most significant drawback of Silverlight 2 is it's "cross platform" "compatibility" with different OSes and browsers. I personally live with FireFox and Ubuntu, so I had to install Moonlight from the Mono project. But this is not enough! Full XAP support will be ready on September, 2009 only (the best wishes to the guys!)

I have decided to expand cross-platform-cross-browser abilities of SlideShow and mix them in single mojoPortal feature.

  • Basically, if visitor uses Windows, I display SlideShow2 - if he loves Ms, he for sure will download and install Silverlight 2 and .NET framework 3.5.
  • All other guys will see SlideShow1 in pure JavaScript.

I had not much time to create some kind of redistributable package, but I want to share my SlideShow.ascx and SlideShow.ascx.cs files right here. (wow, it is like "feature request": "Joe, please, implement file attachments to our Forum feature! Thank you!" ) This control may be in a minute registered on working portal by hands in usual way.

 

Best Regards,

Anton Kytmanov

kyta.spb.ru

 

SlideShow.ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SlideShow.ascx.cs" Inherits="Vertigo.SlideShow.SlideShow" %>

 

SlideShow.ascx.cs:

using System;
using System.Collections;
using System.Configuration;
using System.Globalization;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using mojoPortal.Web;

namespace Vertigo.SlideShow {
public partial class SlideShow : SiteModuleControl {
#region Constants
private const string silverlight2_ObjectFormat = @"
<object type=""application/x-silverlight-2""
data=""data:application/x-silverlight-2,""
width=""{0}"" height=""{1}"">
<param name=""background"" value=""{2}"" />
<param name=""source"" value=""{3}"" />
<param name=""initParams"" value=""{4}"" />

<a href=""http://go.microsoft.com/fwlink/?LinkID=124807"" style=""text-decoration: none;""><img src=""http://go.microsoft.com/fwlink/?LinkId=108181"" style=""border-style: none;"" alt=""Get Microsoft Silverlight"" /></a>
</object>
";

private const string silverlight1_Object = @"
<script type=""text/javascript"">
new SlideShow.Control(new SlideShow.XmlConfigProvider());
</script>
";
#endregion Constants

private uint width = 530;
private uint height = 400;
private string bgColor = "white";
private string pathToXAP = @"/ClientBin/Vertigo.SlideShow.xap";
private string initParams = @"ConfigurationProvider=LightTheme,DataProvider=XmlDataProvider;Path=/Data/Sites/1/FolderGalleries/Data2.xml";

private string controlPresentationInHtml = "";

public SlideShow() : base()
{
        controlPresentationInHtml = string.Format(CultureInfo.InvariantCulture,
        silverlight2_ObjectFormat,
        width, height, bgColor, pathToXAP, initParams);
}

protected void Page_Load (object sender, EventArgs e) {
// If Windows...
if (Request.Browser.Platform.ToUpperInvariant().StartsWith("WIN")) {
// Unknown;
// Win95; Win98; Windows NT 5.0 (Windows 2000); Windows NT 5.1 (Windows XP); WinNT (all other versions of Windows NT); Win16; WinCE
// Mac68K; MacPPC
// UNIX
// WebTV

controlPresentationInHtml = string.Format(CultureInfo.InvariantCulture,
silverlight2_ObjectFormat,
width, height, bgColor, pathToXAP, initParams);

return;
}

// Prepare JavaScript
controlPresentationInHtml = silverlight1_Object;


string myScript = "\n<script type=\"text/javascript\" src=\"" + ResolveUrl ("/ClientScript/Silverlight.js") + "\"></script>";
if (!Page.ClientScript.IsClientScriptBlockRegistered ("Silverlight")) {
Page.ClientScript.RegisterClientScriptBlock (typeof (SlideShow), "Silverlight", myScript, false);
}

myScript = "\n<script type=\"text/javascript\" src=\"" + ResolveUrl ("/ClientScript/SlideShow.js") + "\"></script>";
if (!Page.ClientScript.IsClientScriptBlockRegistered ("VertigoSlideShow")) {
Page.ClientScript.RegisterClientScriptBlock (typeof (SlideShow), "VertigoSlideShow", myScript, false);
}
}

protected override void Render (HtmlTextWriter writer) {
writer.Write (controlPresentationInHtml);
}
}
}

1/12/2009 5:47:15 AM
Gravatar
Total Posts 18439

Re: Silverlight in mojoPortal for mere mortals

Hi Anton,

Looks great! I've seen that Vertigo Slide Show popping up everywhere lately, its very cool. If you'd like to contribute this to the project, send the files for this to me at joe dot audette at g mail dotcom and agree to license it under the same CPL as mojoPortal, I'll include it in the next release and list you in the credits.

Best,

Joe

8/21/2009 12:55:04 PM
Gravatar
Total Posts 2239

Re: Silverlight in mojoPortal for mere mortals

Was this added to mojo? If not, I'll just go ahead and add it to my site manually.

-Joe

8/21/2009 1:22:47 PM
Gravatar
Total Posts 18439

Re: Silverlight in mojoPortal for mere mortals

Hi Joe,

No I think this one drifted off my radar at a time when I was very busy, thanks for bringing it back up.

I will look into adding this soon but its not in time for the coming release which I hope to make no later than Monday.

Best,

Joe

9/3/2009 2:45:32 PM
Gravatar
Total Posts 18439

Re: Silverlight in mojoPortal for mere mortals

Hi All,

I've integrated the Vertigo Silverlight player into mojoPortal in the Image Gallery feature and created a new  Flickr Slideshow feature as well.

Its on demo.mojoportal.com now. the Flickr part is hard to demo because it requires a Flickr username and api key. It works on my local machine but I'm not going to enter my credentials into the module settings on a public demo.

If you use the regular Image Gallery Feature and upload some images then go to the feature instance settings and enable the Silverlight Slide Show you can see it. I must say it is pretty sweet! But the Silverlight pugin is not yet as ubiquitous as I would like.

Anyway, its a really nice user experience with Silverlight enabled.

Cheers,

Joe

You must sign in to post in the forums. This thread is closed to new posts.