using System; using System.Collections.Generic; using Shared.Phone.UserCenter; namespace Shared.Common { /// /// 场景 /// [System.Serializable] public class SceneUI : ZigBee.Device.CommonDevice { #region ◆ 变量____________________________ /// /// 场景文件 /// /// The name of the file. [Newtonsoft.Json.JsonIgnore] public string FileName { get { return $"Scene_{Id}.json"; } } /// /// 场景id /// public int Id = int.MaxValue; /// /// 场景名 /// public string Name = string.Empty; /// /// 图片路径 /// public string IconPath = "Scene/SceneDefault.png"; /// /// 图片来源 0--本地图库 1--拍照 2--系统图库 /// public int IconPathType = 0; /// /// 功能路径列表---备用 /// public List FunctionFilePathList = new List { }; /// /// 通用标识--备用 /// public object Tag; /// /// 延时执行时间--设备延时 /// public int DelayTime = 0; /// /// 标识当前场景是否是分享的场景 /// public bool IsSharedScene = false; /// /// 是否收藏 /// public bool IsCollected = false; /// /// 延时执行时间--整个场景延时(不是延时场景里面的执行目标) /// 不序列化,重新打开APP置。即只对本次编辑场景延时执行有效 /// [Newtonsoft.Json.JsonIgnore] public int SceneDelayTime = 0; /// /// 场景执行目标 /// public List AddSceneMemberDataList = new List { }; #endregion #region ◆ 通过场景id获取场景路径_____________ /// /// GetSceneFilePathBySceneId /// /// /// public static string GetSceneFilePathBySceneId(int sceneId) { return $"Scene_{sceneId}.json"; } #endregion #region ◆ 收藏____________________________ /// /// collect /// /// /// public void Collect(bool collected, bool autoBackup = true) { IsCollected = collected; Save(autoBackup); } #endregion #region ◆ 保存____________________________ /// /// 保存 /// /// 是否备份 public void Save(bool autoBackup = true) { Global.WriteFileByBytesByHomeId(FileName, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); if (autoBackup == true) { HdlAutoBackupLogic.AddOrEditorFile(FileName); } } #endregion } }