|
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System;
using System.Collections.Generic;
using System.Windows.Media.Animation;
namespace Microsoft.Windows.Controls.DataVisualization
{
/// <summary>
/// Represents a storyboard queue that plays storyboards in sequence.
/// </summary>
internal class StoryboardQueue
{
/// <summary>
/// A queue of the storyboards.
/// </summary>
private Queue<Storyboard> _storyBoards = new Queue<Storyboard>();
/// <summary>
/// Accepts a new storyboard to play in sequence.
/// </summary>
/// <param name="storyBoard">The storyboard to play.</param>
public void Enqueue(Storyboard storyBoard)
{
Enqueue(storyBoard, null);
}
/// <summary>
/// Accepts a new storyboard to play in sequence.
/// </summary>
/// <param name="storyBoard">The storyboard to play.</param>
/// <param name="completedAction">An action to execute when the
/// storyboard completes.</param>
public void Enqueue(Storyboard storyBoard, EventHandler completedAction)
{
storyBoard.Completed +=
(sender, args) =>
{
if (completedAction != null)
{
completedAction(sender, args);
}
_storyBoards.Dequeue();
Dequeue();
};
_storyBoards.Enqueue(storyBoard);
if (_storyBoards.Count == 1)
{
Dequeue();
}
}
/// <summary>
/// Removes the next storyboard in the queue and plays it.
/// </summary>
private void Dequeue()
{
if (_storyBoards.Count > 0)
{
_storyBoards.Peek().Begin();
}
}
}
}
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.