Using silverlight for automatic slideshow

Jun 3, 2009 at 10:19 PM

Hello friends,

I want to know how to use silverlight for making automatic slideshow movie. Actually I'm looking for plugin which does this

Thanks for your help

Jun 5, 2009 at 9:18 AM

What do you want to know?

The basics of slidehow:

 private Timer slideShowTimer = null;

        private void StartSlideShow()
        {
            TimeSpan period = TimeSpan.FromSeconds(6d);
            this.slideShowTimer = new Timer(new TimerCallback(slideShowTimer_Elapsed), null, period, period);
        }

        private void StopSlideShow()
        {
            if (this.slideShowTimer != null)
                this.slideShowTimer.Dispose();

            this.slideShowTimer = null;
        }

        private void slideShowTimer_Elapsed(object userState)
        {
            this.Dispatcher.BeginInvoke(new Action(delegate
                {
                    this.OnNextPictureRequested(new RoutedEventArgs());
                }));
        }

 

public event RoutedEventHandler NextPictureRequested;

        private void OnNextPictureRequested(RoutedEventArgs e)
        {
            if (this.NextPictureRequested != null)
                this.NextPictureRequested(this, e);
        }

        public event RoutedEventHandler PreviousPictureRequested;

        private void OnPreviousPictureRequested(RoutedEventArgs e)
        {
            if (this.PreviousPictureRequested != null)
                this.PreviousPictureRequested(this, e);
        }

And event handlers in main page:

void pictureDisplay_NextPictureRequested(object sender, RoutedEventArgs e)
        {
            this.SelectNeighbourPictureToDisplay(sender as PictureDisplay, 1);
        }

        void pictureDisplay_PreviousPictureRequested(object sender, RoutedEventArgs e)
        {
            this.SelectNeighbourPictureToDisplay(sender as PictureDisplay, -1);
        }

        private void SelectNeighbourPictureToDisplay(PictureDisplay display, int direction)
        {
            if (this.DisplayedThumbnails.Count == 0) return;

            ThumbnailDisplay foundThumbnail = null;
            for (int i = 0; i < this.DisplayedThumbnails.Count && foundThumbnail == null; i++)
                if (this.DisplayedThumbnails[i].Thumbnail == display.Thumbnail)
                    foundThumbnail = this.DisplayedThumbnails[i];

            if (foundThumbnail == null)
                foundThumbnail = this.DisplayedThumbnails[0];

            int index = this.DisplayedThumbnails.IndexOf(foundThumbnail) + direction;
            if (index < 0) index = this.DisplayedThumbnails.Count - 1;
            if (index >= this.DisplayedThumbnails.Count) index = 0;

            display.Thumbnail = this.DisplayedThumbnails[index].Thumbnail;
        }

 

I hope this can help you.