具备界面基础功能
This commit is contained in:
113
SHH.CameraDashboard/App/AppGlobal.cs
Normal file
113
SHH.CameraDashboard/App/AppGlobal.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using System.Collections.ObjectModel;
|
||||
|
||||
namespace SHH.CameraDashboard
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序全局状态和事件总线。
|
||||
/// 此类作为一个静态的中央枢纽,用于在应用程序的不同部分之间共享数据和通信。
|
||||
/// </summary>
|
||||
public static class AppGlobal
|
||||
{
|
||||
#region --- 全局数据存储 ---
|
||||
|
||||
/// <summary>
|
||||
/// 获取一个可观察的集合,用于存储和显示所有已配置的服务节点。
|
||||
/// 由于使用了 <see cref="ObservableCollection{T}"/>,当集合内容发生变化时,UI(如 ListView)会自动更新。
|
||||
/// </summary>
|
||||
public static ObservableCollection<ServiceNodeModel> ServiceNodes { get; }
|
||||
= new ObservableCollection<ServiceNodeModel>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置当前正在使用的服务节点。
|
||||
/// 当用户从列表中选择一个节点时,应更新此属性。
|
||||
/// </summary>
|
||||
public static ServiceNodeModel? UseServiceNode { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- 全局事件总线 ---
|
||||
|
||||
#region CameraAdd
|
||||
|
||||
/// <summary>
|
||||
/// 当应用程序的任何部分请求添加一个新摄像头时发生。
|
||||
/// </summary>
|
||||
public static event Action? OnRequestAddCamera;
|
||||
|
||||
/// <summary>
|
||||
/// 触发 <see cref="OnRequestAddCamera"/> 事件,以请求打开摄像头添加界面。
|
||||
/// </summary>
|
||||
public static void RequestAdd()
|
||||
=> OnRequestAddCamera?.Invoke();
|
||||
|
||||
#endregion
|
||||
|
||||
#region CameraEdit
|
||||
|
||||
/// <summary>
|
||||
/// 当应用程序的任何部分请求编辑一个摄像头时发生。
|
||||
/// 事件处理程序将接收到要编辑的 <see cref="WebApiCameraModel"/> 实例。
|
||||
/// </summary>
|
||||
public static event Action<WebApiCameraModel>? OnRequestEditCamera;
|
||||
|
||||
/// <summary>
|
||||
/// 触发 <see cref="OnRequestEditCamera"/> 事件,以请求打开摄像头编辑界面。
|
||||
/// </summary>
|
||||
/// <param name="camera">要编辑的摄像头数据模型。</param>
|
||||
public static void RequestEdit(WebApiCameraModel camera)
|
||||
=> OnRequestEditCamera?.Invoke(camera);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CameraDelete
|
||||
|
||||
/// <summary>
|
||||
/// 当应用程序的任何部分请求删除一个摄像头时发生。
|
||||
/// 事件处理程序将接收到要删除的 <see cref="WebApiCameraModel"/> 实例。
|
||||
/// </summary>
|
||||
public static event Action<WebApiCameraModel>? OnRequestDeleteCamera;
|
||||
|
||||
/// <summary>
|
||||
/// 触发 <see cref="OnRequestDeleteCamera"/> 事件,以请求删除指定的摄像头。
|
||||
/// </summary>
|
||||
/// <param name="camera">要删除的摄像头数据模型。</param>
|
||||
public static void RequestDelete(WebApiCameraModel camera)
|
||||
=> OnRequestDeleteCamera?.Invoke(camera);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CameraRefreshList
|
||||
|
||||
/// <summary>
|
||||
/// 当应用程序的任何部分请求刷新摄像头列表时发生。
|
||||
/// </summary>
|
||||
public static event Action? OnRefreshListRequest;
|
||||
|
||||
/// <summary>
|
||||
/// 触发 <see cref="OnRefreshListRequest"/> 事件,以请求刷新摄像头列表数据。
|
||||
/// </summary>
|
||||
public static void RequestRefresh()
|
||||
=> OnRefreshListRequest?.Invoke();
|
||||
|
||||
#endregion
|
||||
|
||||
// [新增] 请求云台控制事件
|
||||
public static event Action<WebApiCameraModel>? OnRequestPtzCamera;
|
||||
|
||||
// [新增] 触发方法
|
||||
public static void RequestPtz(WebApiCameraModel camera) => OnRequestPtzCamera?.Invoke(camera);
|
||||
|
||||
// 图像处理
|
||||
public static event Action<WebApiCameraModel>? OnRequestImgProc;
|
||||
|
||||
public static void RequestImgProc(WebApiCameraModel camera) => OnRequestImgProc?.Invoke(camera);
|
||||
|
||||
// 1. 定义事件委托:当 ViewModel 请求订阅时触发
|
||||
public static event Action<WebApiCameraModel>? OnRequestSubscription;
|
||||
|
||||
// 2. 定义触发方法:供 CameraItemTopViewModel 调用
|
||||
public static void RequestSubscription(WebApiCameraModel camera) => OnRequestSubscription?.Invoke(camera);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user