Click here to Skip to main content
15,885,546 members
Articles / Web Development / ASP.NET

Configurable Silverlight Image Rotator

Rate me:
Please Sign up or sign in to vote.
4.92/5 (18 votes)
23 Feb 2009CPOL11 min read 102.7K   3.1K   84  
Using Silverlight 2.0 and C#/VB.NET to build an image rotator that has a useful set of basic features and is easy to setup and deploy.
using System;
using System.Configuration;

namespace ImageRotator_CSharp.Web
{
	public partial class ImageRotatorTestPage : System.Web.UI.Page
	{
		#region Private Member Variables

		string imageRotatorDiv = ConfigurationManager.AppSettings["ImageRotatorDivID"];

		#endregion

		/// <summary>
		/// Setup initParamaters for silverlight control when page initially loads, 
		/// special characters must be escaped with ASCII character. 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void Page_Load(object sender, EventArgs e)
		{
			string browserWindowOptions = "resizable=1|scrollbars=1|menubar=1|status=1|toolbar=1|titlebar=1|width=1000|height=725|left=5|top=5";

			if (!this.Page.IsPostBack)
			{
				string autoPlay = ConfigurationManager.AppSettings["EnableAutoPlay"].ToLower();
				string autoPlayInterval = ConfigurationManager.AppSettings["AutoPlayInterval"];
				string numberedNavigation = ConfigurationManager.AppSettings["DisplayNumberedNavigation"].ToLower();
				string arrowNavigation = ConfigurationManager.AppSettings["DisplayArrowNavigation"].ToLower();
				string stopStartAutoPlay = ConfigurationManager.AppSettings["EnableStopStartAutoPlay"].ToLower();
				string animation = ConfigurationManager.AppSettings["EnableAnimations"].ToLower();
				string border = ConfigurationManager.AppSettings["DisplayBorder"].ToLower();
				string borderThickness = ConfigurationManager.AppSettings["BorderThickness"];
				string argb = ConfigurationManager.AppSettings["ARGB"];

				string initParams = "autoPlay=" + autoPlay;
				initParams += ",autoPlayInterval=" + autoPlayInterval;
				initParams += ",numberedNavigation=" + numberedNavigation;
				initParams += ",arrowNavigation=" + arrowNavigation;
				initParams += ",stopStartAutoPlay=" + stopStartAutoPlay;
				initParams += ",animation=" + animation;
				initParams += ",border=" + border;
				initParams += ",borderThickness=" + borderThickness;
				initParams += ",argb=" + argb;
				initParams += ",imageRotatorDiv=" + imageRotatorDiv;
				initParams += ",browserWindowOptions=" + browserWindowOptions;

				imageRotator.InitParameters = initParams;
			}
		}

		/// <summary>
		/// Setup initParamaters for silverlight control when refresh button is clicked, 
		/// special characters must be escaped with ASCII character.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected void refresh_Click(object sender, EventArgs e)
		{
			string browserWindowOptions = "resizable=1|scrollbars=1|menubar=1|status=1|toolbar=1|titlebar=1|width=900|height=725|left=5|top=5";

			string initParams = "autoPlay=" + autoPlay.Checked.ToString();
			initParams += ",autoPlayInterval=" + autoPlayInterval.Text;
			initParams += ",numberedNavigation=" + numberedNavigation.Checked.ToString();
			initParams += ",arrowNavigation=" + arrowNavigation.Checked.ToString();
			initParams += ",stopStartAutoPlay=" + stopStartAutoPlay.Checked.ToString();
			initParams += ",animation=" + animation.Checked.ToString();
			initParams += ",border=" + border.Checked.ToString();
			initParams += ",borderThickness=" + borderThickness.SelectedValue;
			initParams += ",argb=" + a.Text + "|" + r.Text + "|" + g.Text + "|" + b.Text;
			initParams += ",imageRotatorDiv=" + imageRotatorDiv;
			initParams += ",browserWindowOptions=" + browserWindowOptions;
			imageRotator.InitParameters = initParams;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
I have been Software developer for the past 10 years. Mostly worked in web world in asp.net and c#. Recently began job using wpf and vb.net.

Also enjoy reading books on politics and American history, listening to music, and COD on XBox 360.

Visit my blog at: www.anothercodesite.com/blog

All posts have source code for both C# and VB.

Comments and Discussions