/// <summary> /// Start first task from queue, remove it from queue and raise FadeStart event /// </summary> protected void StartTask() { if (currentTask == null && tasks.Count > 0) { currentTask = tasks.Dequeue(); if (currentTask.action != null) { currentTask.action.Completed = false; } if (currentTask.pAction != null) { currentTask.pAction.Completed = false; } OnFadeStart(new FadeEventArgs() { Direction = currentTask.State == FadeState.In ? FadeDirection.In : FadeDirection.Out }); } }
/// <summary> /// Called when fading task finished, call task's action and raise FadeFinish event /// </summary> protected void FinishTask() { if (currentTask != null) { if (currentTask.action == null & currentTask.pAction == null) { OnFadeFinish(new FadeEventArgs() { Direction = currentTask.State == FadeState.In ? FadeDirection.In : FadeDirection.Out }); currentTask = null; } else { if (currentTask.action != null) { if (currentTask.action.Completed) { OnFadeFinish(new FadeEventArgs() { Direction = currentTask.State == FadeState.In ? FadeDirection.In : FadeDirection.Out }); currentTask = null; } } else if (currentTask.pAction != null) { if (currentTask.pAction.Completed) { OnFadeFinish(new FadeEventArgs() { Direction = currentTask.State == FadeState.In ? FadeDirection.In : FadeDirection.Out }); currentTask = null; } } } } }
/// <summary> /// Add fading tast to the queue /// </summary> /// <param name="task"></param> public void AddTask(FaderTask task) { tasks.Enqueue(task); }