BinarySlideShow
A slide show: shows a list of slides one after another, on a timer or under your control, with any of twenty-three transition effects between them – for kiosks, product tours, photo galleries, dashboards that cycle through views, and presentations.
public class BinarySlideShow : ContentControl
Inherits from / implements: ContentControl
Remarks
Slides
Each slide is a BinarySlideShowItem holding any content. Add them to
Slides, which every slide show starts with, empty. To show a single slide of your own
choosing, set SlideContent or call PlayThisSlide.
Playing
Play starts the timer, which shows the next slide every
SlideTransitionTimerInterval milliseconds, going back to the first after the last; the
first slide appears one interval after the start. Pause, Resume and
Stop control the timer, and StartSlideShowOnceInstantiated plays without
a call. The timer runs only while the control is on screen, so a slide show on a page the user has
left stops by itself and carries on when the page is shown again.
Moving by hand
Next, Previous, GoToFirstSlide,
GoToLastSlide and GoToThisSlide move through the slides – from buttons,
or the arrow keys. Each action raises an AboutTo... event first, such as
AboutToGoToNextSlide; set CancelEventArgs.Cancel in it to stop the
action.
Next, Previous, GoToFirstSlide and
GoToLastSlide pass the slide they move to as the outgoing side of the transition, so
with the SlideTransitionEffect.Default, Slide and
SlideFromBottom effects the slide shown changes to it only at the following move or timer
tick. GoToThisSlide and the timer show the new slide at once.
Effects
SlideTransitionEffect chooses the transition, and can be changed between slides.
Several effects use the control's own UIElement.Effect,
UIElement.RenderTransform, UIElement.OpacityMask or template, so leave
those to the control.
Examples
A self-running kiosk show with a fade every five seconds, and buttons to move by hand.
<Window x:Class="Kiosk.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:show="clr-namespace:Binarymission.WPF.Controls.InteractionControls;assembly=Binarymission.WPF.Controls.InteractionControls.SlideShow"
Title="Welcome" Width="1024" Height="640">
<DockPanel>
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Previous" Margin="4" Click="OnPrevious" />
<Button Content="Next" Margin="4" Click="OnNext" />
</StackPanel>
<show:BinarySlideShow x:Name="Tour" SlideTransitionEffect="Fade"
SlideTransitionTimerInterval="5000" StartSlideShowOnceInstantiated="True" />
</DockPanel>
</Window>using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Binarymission.WPF.Controls.InteractionControls;
foreach (string file in new[] { "lobby.jpg", "showroom.jpg", "workshop.jpg" })
{
Tour.Slides.Add(new BinarySlideShowItem
{
Content = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Slides/" + file)), Stretch = Stretch.Uniform }
});
}
Tour.AboutToGoToNextSlide += (sender, e) => e.Cancel = Tour.Slides.Count == 0;
private void OnNext(object sender, RoutedEventArgs e) { Tour.Next(); }
private void OnPrevious(object sender, RoutedEventArgs e) { Tour.Previous(); }Members at a glance
| Constructors | |
|---|---|
BinarySlideShow | Initializes a new instance of the BinarySlideShow class. |
| Properties | |
BlendEffectStartColor | Gets or sets the first colour the SlideTransitionEffect.ColorBlend effect tints the slide with. |
BlendEffectTransitionColor | Gets or sets the second colour the SlideTransitionEffect.ColorBlend effect tints the slide with. |
DefaultSlideContent | Gets or sets the slide shown before the first slide, and used as the outgoing side of a transition when there is no slide before it. |
DefaultSlideContentText | Gets or sets the text of the built-in blank slide shown before the first slide. |
IsPaused | Gets or sets whether the slide show is paused. Setting it calls Pause or Resume. |
IsShowDefaultBlankSlideAtStartup | Gets or sets whether DefaultSlideContent is shown while the slide show waits for its
first slide. |
IsStopped | Gets or sets whether the slide show is stopped. Setting it calls Stop or Play. |
SlideContent | Gets or sets the slide on screen; setting it shows that content with the transition effect. |
SlideTransitionEffect | Gets or sets the effect used to move from one slide to the next. |
SlideTransitionTimerInterval | Gets or sets how long each slide stays on screen while the slide show plays. |
Slides | Gets or sets the slides, in the order they are shown. |
StartSlideShowOnceInstantiated | Gets or sets whether the slide show plays by itself, with no call to Play. |
| Methods | |
GoToFirstSlide | Moves to the first slide in Slides. |
GoToLastSlide | Moves to the last slide in Slides; the timer, if playing, goes on to the first. |
GoToThisSlide | Shows the slide at a given position, and optionally plays on from it. |
Next | Moves on one slide; after the last, goes back to the first. |
OnApplyTemplate | Shows the blank opening slide if IsShowDefaultBlankSlideAtStartup is on, and plays if
StartSlideShowOnceInstantiated is on, whenever a template is applied. |
Pause | Pauses the slide show on the slide on screen, until Resume is called. |
Play | Starts the slide show: the next slide is shown every SlideTransitionTimerInterval
milliseconds, from the first again after the last. |
PlayThisSlide | Shows a given slide, with the current transition effect, whether or not it is in Slides. |
Previous | Moves back one slide; at the first slide, stays there. |
Resume | Carries on a paused or stopped slide show from where it was. |
Stop | Stops the slide show; the slide on screen stays there. Play starts it again. |
| Events | |
AboutToGoToASpecificSlideIndex | Occurs when GoToThisSlide is called, before the move; set Cancel to stay put. |
AboutToGoToFirstSlide | Occurs when GoToFirstSlide is called, before the move; set Cancel to stay on the slide. |
AboutToGoToLastSlide | Occurs when GoToLastSlide is called, before the move; set Cancel to stay on the slide. |
AboutToGoToNextSlide | Occurs when Next is called, before the move; set Cancel to stay on the slide. |
AboutToGoToPreviousSlide | Occurs when Previous is called, before the move; set Cancel to stay on the slide. |
AboutToGoToSpecificSlideInstance | Occurs when PlayThisSlide is called, before the slide is shown; set Cancel to stop it. |
AboutToPause | Occurs when Pause is called, before the slide show pauses; set Cancel to keep it playing. |
AboutToPlay | Occurs when Play is called, before the slide show starts; set Cancel to stop it starting. |
AboutToResume | Occurs when Resume is called, before the slide show resumes; set Cancel to keep it paused. |
AboutToStop | Occurs when Stop is called, before the slide show stops; set Cancel to keep it playing. |
| Fields | |
BlendEffectStartColorProperty | Identifies the BlendEffectStartColor dependency property. |
BlendEffectTransitionColorProperty | Identifies the BlendEffectTransitionColor dependency property. |
DefaultSlideContentProperty | Identifies the DefaultSlideContent dependency property. |
DefaultSlideContentTextProperty | Identifies the DefaultSlideContentText dependency property. |
IsShowDefaultBlankSlideAtStartupProperty | Identifies the IsShowDefaultBlankSlideAtStartup dependency property. |
SlideContentProperty | Identifies the SlideContent dependency property. |
SlideTransitionEffectProperty | Identifies the SlideTransitionEffect dependency property. |
SlideTransitionTimerIntervalProperty | Identifies the SlideTransitionTimerInterval dependency property. |
SlidesProperty | Identifies the Slides dependency property. |
StartSlideShowOnceInstantiatedProperty | Identifies the StartSlideShowOnceInstantiated dependency property. |
Constructors
Properties
BlendEffectStartColor
Gets or sets the first colour the SlideTransitionEffect.ColorBlend effect tints the slide with.
- Value
- The default is
Colors.Gray. Applied faintly; its own alpha is not used.
BlendEffectTransitionColor
Gets or sets the second colour the SlideTransitionEffect.ColorBlend effect tints the slide with.
- Value
- The default is
Colors.Blue. Applied very faintly; its own alpha is not used.
DefaultSlideContent
Gets or sets the slide shown before the first slide, and used as the outgoing side of a transition when there is no slide before it.
- Value
- The default is a blank slide in the window colour with
DefaultSlideContentTextcentred on it.
Remarks
Shown at start-up only while IsShowDefaultBlankSlideAtStartup is on, and then
only if it is a BinarySlideShowItem.
DefaultSlideContentText
Gets or sets the text of the built-in blank slide shown before the first slide.
- Value
- The default is
"Slideshow is initializing... please wait...".
Remarks
The built-in slide is made when the control is created, with the text this property has at
that moment, so a value set afterwards does not reach it. To show text of your own, set
DefaultSlideContent to a slide of your own.
IsShowDefaultBlankSlideAtStartup
Gets or sets whether DefaultSlideContent is shown while the slide show waits for its
first slide.
- Value
trueto show it. The default isfalse: the control is blank until the first slide.
IsStopped
- Value
- The default is
false.
SlideContent
Gets or sets the slide on screen; setting it shows that content with the transition effect.
- Value
- The default is
null. Each move and tick sets it to the slide shown.
SlideTransitionEffect
Gets or sets the effect used to move from one slide to the next.
- Value
- The default is
SlideTransitionEffect.Default: no effect.
Remarks
Read at each transition, so it can be changed between slides – picked at random for variety, for example.
SlideTransitionTimerInterval
Gets or sets how long each slide stays on screen while the slide show plays.
- Value
- A time in milliseconds. The default is
3000(three seconds).
Remarks
A change applies from the next tick. Allow for the effect's own length, up to three
seconds. A negative value throws an ArgumentOutOfRangeException.
Slides
Gets or sets the slides, in the order they are shown.
- Value
- Each control starts with an empty list of its own, ready to add to.
Remarks
The list is read at every move and tick, so slides can be added while the show plays. Set
to null, the timer shows SlideContent instead.
StartSlideShowOnceInstantiated
Gets or sets whether the slide show plays by itself, with no call to Play.
- Value
trueto play. The default isfalse.
Remarks
Setting it to true calls Play at once (raising
AboutToPlay), and again when the template is applied; the slides start once the
control is on screen.
Methods
GoToFirstSlide
Moves to the first slide in Slides.
Remarks
Raises AboutToGoToFirstSlide first. Does nothing while there are no slides.
GoToLastSlide
Moves to the last slide in Slides; the timer, if playing, goes on to the first.
Remarks
Raises AboutToGoToLastSlide first. Does nothing while there are no slides.
GoToThisSlide
Shows the slide at a given position, and optionally plays on from it.
Parameters
slideIndex- The zero-based position of the slide in
Slides. A position past the last slide does nothing; a negative one throws. startPlayingFromTheDesiredIndextrueto callPlayafter showing the slide;falseto leave the slide show as it is.
Exceptions
ArgumentOutOfRangeExceptionslideIndexis negative and there are slides.
Remarks
Raises AboutToGoToASpecificSlideIndex first.
Example
// Jump to the slide picked in a thumbnail strip, and play on from it.
Tour.GoToThisSlide(thumbnails.SelectedIndex, true);Next
Moves on one slide; after the last, goes back to the first.
Remarks
Raises AboutToGoToNextSlide first. It sets IsPaused but does not
stop the timer, which carries on from the new position.
OnApplyTemplate
Shows the blank opening slide if IsShowDefaultBlankSlideAtStartup is on, and plays if
StartSlideShowOnceInstantiated is on, whenever a template is applied.
Remarks
Most effects switch the control's template as they run, so this is called again at those transitions, with the same results.
Pause
Pauses the slide show on the slide on screen, until Resume is called.
Remarks
Raises AboutToPause first.
Play
Starts the slide show: the next slide is shown every SlideTransitionTimerInterval
milliseconds, from the first again after the last.
Remarks
Raises AboutToPlay first. The first slide appears one interval after the
call, and nothing advances until the control is on screen.
PlayThisSlide
Shows a given slide, with the current transition effect, whether or not it is in Slides.
Parameters
slide- The slide to show.
nulldoes nothing.
Remarks
Raises AboutToGoToSpecificSlideInstance first. The timer, if playing, carries
on from its own position at the next tick.
Previous
Moves back one slide; at the first slide, stays there.
Remarks
Raises AboutToGoToPreviousSlide first. It sets IsPaused but does
not stop the timer, which carries on from the new position.
Resume
Carries on a paused or stopped slide show from where it was.
Remarks
Raises AboutToResume first.
Stop
Stops the slide show; the slide on screen stays there. Play starts it again.
Remarks
Raises AboutToStop first.
Events
AboutToGoToASpecificSlideIndex
Occurs when GoToThisSlide is called, before the move; set Cancel to stay put.
AboutToGoToFirstSlide
Occurs when GoToFirstSlide is called, before the move; set Cancel to stay on the slide.
AboutToGoToLastSlide
Occurs when GoToLastSlide is called, before the move; set Cancel to stay on the slide.
AboutToGoToNextSlide
Occurs when Next is called, before the move; set Cancel to stay on the slide.
AboutToGoToPreviousSlide
Occurs when Previous is called, before the move; set Cancel to stay on the slide.
AboutToGoToSpecificSlideInstance
Occurs when PlayThisSlide is called, before the slide is shown; set Cancel to stop it.
AboutToPause
Occurs when Pause is called, before the slide show pauses; set Cancel to keep it playing.
AboutToPlay
Occurs when Play is called, before the slide show starts; set Cancel to stop it starting.
AboutToResume
Occurs when Resume is called, before the slide show resumes; set Cancel to keep it paused.
AboutToStop
Occurs when Stop is called, before the slide show stops; set Cancel to keep it playing.
Fields
BlendEffectStartColorProperty static
Identifies the BlendEffectStartColor dependency property.
BlendEffectTransitionColorProperty static
Identifies the BlendEffectTransitionColor dependency property.
DefaultSlideContentProperty static
Identifies the DefaultSlideContent dependency property.
DefaultSlideContentTextProperty static
Identifies the DefaultSlideContentText dependency property.
IsShowDefaultBlankSlideAtStartupProperty static
Identifies the IsShowDefaultBlankSlideAtStartup dependency property.
SlideContentProperty static
Identifies the SlideContent dependency property.
SlideTransitionEffectProperty static
Identifies the SlideTransitionEffect dependency property.
SlideTransitionTimerIntervalProperty static
Identifies the SlideTransitionTimerInterval dependency property.
SlidesProperty static
Identifies the Slides dependency property.
StartSlideShowOnceInstantiatedProperty static
Identifies the StartSlideShowOnceInstantiated dependency property.