using System;
using System.Windows.Controls;
using System.Windows.Media;
namespace VPet_Simulator.Core
{
///
/// 动画显示接口
///
public interface IGraph
{
///
/// 从0开始运行该动画
///
/// 停止动作
/// 显示位置
void Run(Decorator parant, Action EndAction = null);
///
/// 是否循环播放
///
bool IsLoop { get; set; }
///
/// 是否准备完成
///
bool IsReady { get; }
///
/// 是否读取失败
///
bool IsFail { get; }
///
/// 失败报错信息
///
string FailMessage { get; }
///
/// 该动画信息
///
GraphInfo GraphInfo { get; }
///
/// 当前动画播放状态和控制
///
TaskControl Control { get; }
///
/// 停止动画
///
/// 停止动画时是否不运行结束动画
void Stop(bool StopEndAction)
{
if (Control == null)
return;
if (StopEndAction)
Control.EndAction = null;
Control.Type = TaskControl.ControlType.Stop;
}
///
/// 设置为继续播放
///
void SetContinue()
{
Control.Type = TaskControl.ControlType.Continue;
}
///
/// 指示该ImageRun支持
///
public interface IRunImage : IGraph
{
///
/// 从0开始运行该动画
///
/// 显示位置
/// 结束方法
/// 额外图片
void Run(Decorator parant, ImageSource image, Action EndAction = null);
}
///
/// 动画控制类
///
public class TaskControl
{
///
/// 当前动画播放状态
///
public bool PlayState => Type != ControlType.Status_Stoped && Type != ControlType.Stop;
///
/// 设置为继续播放
///
public void SetContinue() { Type = ControlType.Continue; }
///
/// 停止播放
///
public void Stop(Action endAction = null) { EndAction = endAction; Type = ControlType.Stop; }
///
/// 控制类型
///
public enum ControlType
{
///
/// 维持现状, 不进行任何超控
///
Status_Quo,
///
/// 停止当前动画
///
Stop,
///
/// 播放完成后继续播放,仅生效一次, 之后将恢复为Status_Quo
///
Continue,
///
/// 动画已停止
///
Status_Stoped,
}
///
/// 结束动作
///
public Action EndAction;
///
/// 控制类型
///
public ControlType Type = ControlType.Status_Quo;
///
/// 为动画控制类提供操作和结束动作
///
///
public TaskControl(Action endAction = null)
{
EndAction = endAction;
}
}
}
}