Click here to Skip to main content
15,885,278 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.
Imports System
Imports System.Configuration

Partial Public Class ImageRotator_VBTestPage
	Inherits System.Web.UI.Page

#Region "Private Member Variables"

	Private imageRotatorDiv As String = ConfigurationManager.AppSettings("ImageRotatorDivID")

#End Region

	''' <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 Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

		Dim browserWindowOptions As String = "resizable=1|scrollbars=1|menubar=1|status=1|toolbar=1|titlebar=1|width=1000|height=725|left=5|top=5"

		If Not Me.Page.IsPostBack Then
			Dim autoPlay As String = ConfigurationManager.AppSettings("EnableAutoPlay").ToLower()
			Dim autoPlayInterval As String = ConfigurationManager.AppSettings("AutoPlayInterval")
			Dim numberedNavigation As String = ConfigurationManager.AppSettings("DisplayNumberedNavigation").ToLower()
			Dim arrowNavigation As String = ConfigurationManager.AppSettings("DisplayArrowNavigation").ToLower()
			Dim stopStartAutoPlay As String = ConfigurationManager.AppSettings("EnableStopStartAutoPlay").ToLower()
			Dim animation As String = ConfigurationManager.AppSettings("EnableAnimations").ToLower()
			Dim border As String = ConfigurationManager.AppSettings("DisplayBorder").ToLower()
			Dim borderThickness As String = ConfigurationManager.AppSettings("BorderThickness")
			Dim argb As String = ConfigurationManager.AppSettings("ARGB")

			Dim initParams As String = "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
		End If

	End Sub

	''' <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 Sub refresh_Click(ByVal sender As Object, ByVal e As EventArgs)

		Dim browserWindowOptions As String = "resizable=1|scrollbars=1|menubar=1|status=1|toolbar=1|titlebar=1|width=900|height=725|left=5|top=5"

		Dim initParams As String = "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

	End Sub

End Class

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