// PlayNextImage
// Called when a new image is displayed due to a timeout.
// Removes the current image object and queues a new next image.
// Sets the next image index as the new current image, and increases the size
// of the new current image. Then sets the timeout to display the next image.
private async void PlayNextImage(int num)
{
// Stop the timer to avoid repeating.
if (timer != null)
{
timer.Stop();
}
await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal,
async() =>
{
SlideShowPanel.Children.Remove((UIElement)(SlideShowPanel.FindName("image" + num)));
var i = await QueueImage(num + 2, false);
currentImage = num + 1;
((Image)SlideShowPanel.FindName("image" + currentImage)).Width = imageSize;
});
timer = new Windows.UI.Xaml.DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, timeLapse);
timer.Tick += delegate(object sender, object e)
{
PlayNextImage(num + 1);
};
timer.Start();
}