VPet/VPet-Simulator.Core/Graph/IGraph.cs

137 lines
4.1 KiB
C#
Raw Normal View History

2024-03-30 07:00:02 +00:00
using System;
2023-03-26 22:35:19 +00:00
using System.Windows.Controls;
2023-06-01 08:16:45 +00:00
using System.Windows.Media;
2023-07-16 23:58:09 +00:00
2022-12-13 07:10:18 +00:00
namespace VPet_Simulator.Core
{
/// <summary>
/// 动画显示接口
/// </summary>
public interface IGraph
{
/// <summary>
/// 从0开始运行该动画
/// </summary>
2024-04-17 04:48:07 +00:00
/// <param name="EndAction">停止动作</param>
/// <param name="parant">显示位置</param>
2024-04-11 15:36:01 +00:00
void Run(Decorator parant, Action EndAction = null);
2024-04-17 04:48:07 +00:00
2022-12-13 07:10:18 +00:00
/// <summary>
/// 是否循环播放
/// </summary>
bool IsLoop { get; set; }
2024-04-17 04:48:07 +00:00
2023-02-22 05:37:23 +00:00
/// <summary>
2023-05-31 17:47:23 +00:00
/// 是否准备完成
2023-02-22 05:37:23 +00:00
/// </summary>
2023-06-01 08:16:45 +00:00
bool IsReady { get; }
/// <summary>
/// 是否读取失败
/// </summary>
bool IsFail { get; }
/// <summary>
/// 失败报错信息
/// </summary>
string FailMessage { get; }
2022-12-13 07:10:18 +00:00
/// <summary>
2023-07-16 23:58:09 +00:00
/// 该动画信息
2022-12-13 07:10:18 +00:00
/// </summary>
2023-07-16 23:58:09 +00:00
GraphInfo GraphInfo { get; }
2024-04-17 04:48:07 +00:00
/// <summary>
/// 当前动画播放状态和控制
/// </summary>
TaskControl Control { get; }
2022-12-13 07:10:18 +00:00
/// <summary>
/// 停止动画
/// </summary>
2024-04-17 04:48:07 +00:00
/// <param name="StopEndAction">停止动画时是否不运行结束动画</param>
void Stop(bool StopEndAction)
{
if (Control == null)
return;
if (StopEndAction)
Control.EndAction = null;
Control.Type = TaskControl.ControlType.Stop;
}
/// <summary>
/// 设置为继续播放
/// </summary>
void SetContinue()
{
Control.Type = TaskControl.ControlType.Continue;
}
2023-06-01 08:16:45 +00:00
/// <summary>
/// 指示该ImageRun支持
/// </summary>
public interface IRunImage : IGraph
{
/// <summary>
/// 从0开始运行该动画
/// </summary>
/// <param name="parant">显示位置</param>
/// <param name="EndAction">结束方法</param>
/// <param name="image">额外图片</param>
2024-04-11 15:36:01 +00:00
void Run(Decorator parant, ImageSource image, Action EndAction = null);
2023-06-01 08:16:45 +00:00
}
2024-04-17 04:48:07 +00:00
/// <summary>
/// 动画控制类
/// </summary>
public class TaskControl
{
/// <summary>
/// 当前动画播放状态
/// </summary>
public bool PlayState => Type != ControlType.Status_Stoped && Type != ControlType.Stop;
/// <summary>
/// 设置为继续播放
/// </summary>
public void SetContinue() { Type = ControlType.Continue; }
/// <summary>
/// 停止播放
/// </summary>
public void Stop(Action endAction = null) { EndAction = endAction; Type = ControlType.Stop; }
/// <summary>
/// 控制类型
/// </summary>
public enum ControlType
{
/// <summary>
/// 维持现状, 不进行任何超控
/// </summary>
Status_Quo,
/// <summary>
/// 停止当前动画
/// </summary>
Stop,
/// <summary>
/// 播放完成后继续播放,仅生效一次, 之后将恢复为Status_Quo
/// </summary>
Continue,
/// <summary>
/// 动画已停止
/// </summary>
Status_Stoped,
}
/// <summary>
/// 结束动作
/// </summary>
public Action EndAction;
/// <summary>
/// 控制类型
/// </summary>
public ControlType Type = ControlType.Status_Quo;
/// <summary>
/// 为动画控制类提供操作和结束动作
/// </summary>
/// <param name="endAction"></param>
public TaskControl(Action endAction = null)
{
EndAction = endAction;
}
}
2022-12-13 07:10:18 +00:00
}
}