old mode 100644
new mode 100755
| | |
| | | #region ◆ 变量____________________________ |
| | | |
| | | /// <summary>
|
| | | /// 是否是自定义图片
|
| | | /// 设备MAC地址
|
| | | /// </summary> |
| | | public bool IsCustomizeImage = false; |
| | | |
| | | //DeviceUI_DeviceFilePath |
| | | public override bool Equals(object obj) |
| | | { |
| | | var other= obj as DeviceUI; |
| | | if (CommonDevice.DeviceAddr==other.CommonDevice.DeviceAddr && CommonDevice.DeviceEpoint==other.CommonDevice.DeviceEpoint) |
| | | { |
| | | return true; |
| | | } |
| | | return false; |
| | | //CommonDevice.DeviceEpoint.Equals(other.CommonDevice.DeviceEpoint) && CommonDevice.DeviceAddr.Equals(other.CommonDevice.DeviceAddr); |
| | | |
| | | } |
| | | |
| | | public override int GetHashCode() |
| | | { |
| | | return base.GetHashCode(); |
| | | } |
| | | public string DeviceAddr = string.Empty; |
| | | /// <summary>
|
| | | /// 设备端点
|
| | | /// </summary> |
| | | public int DeviceEpoint = 0; |
| | | |
| | | /// <summary> |
| | | /// 设备文件 |
| | |
| | | public string FileName |
| | | { |
| | | get |
| | | { |
| | | return $"DeviceUI_{DeviceFileName}"; |
| | | {
|
| | | var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint);
|
| | | if (myDevice != null)
|
| | | {
|
| | | return $"DeviceUI_{myDevice.FilePath}";
|
| | | } |
| | | return $"DeviceUI_Unkwon"; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 设备文件名(并非deviceUI设备文件名,指的是device) |
| | | /// </summary> |
| | | public string DeviceFileName = string.Empty; |
| | | |
| | | /// <summary> |
| | | /// 图片 |
| | | /// </summary> |
| | | public string IconPath = string.Empty; |
| | | |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public ZigBee.Device.CommonDevice CommonDevice |
| | | { |
| | | get |
| | | { |
| | | return Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint); |
| | | } |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 是否是自定义图片
|
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public bool IsCustomizeImage
|
| | | {
|
| | | get
|
| | | {
|
| | | var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint);
|
| | | if (myDevice != null)
|
| | | {
|
| | | return myDevice.IsCustomizeImage;
|
| | | }
|
| | | return false;
|
| | | }
|
| | | } |
| | | /// <summary> |
| | | /// 设备图片 |
| | | /// </summary> |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public string IconPath
|
| | | {
|
| | | get
|
| | | {
|
| | | var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint);
|
| | | if (myDevice != null)
|
| | | {
|
| | | return myDevice.IconPath;
|
| | | }
|
| | | return string.Empty;
|
| | | }
|
| | | } |
| | | /// <summary> |
| | | /// 设备图片--在线或者选中状态 |
| | | /// </summary> |
| | |
| | | { |
| | | get |
| | | { |
| | | if (string.IsNullOrEmpty(IconPath)) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | var pathArr = IconPath.Split('.'); |
| | | if (pathArr == null || string.IsNullOrEmpty(pathArr[0])) |
| | | { |
| | | return string.Empty; |
| | | } |
| | | return $"{pathArr[0]}Selected.png"; |
| | | var myDevice = Common.LocalDevice.Current.GetDevice(DeviceAddr, DeviceEpoint);
|
| | | if (myDevice != null)
|
| | | {
|
| | | return myDevice.OnlineIconPath;
|
| | | }
|
| | | return string.Empty; |
| | | } |
| | | } |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //ZigBee.Device.CommonDevice commonDevice; |
| | | [Newtonsoft.Json.JsonIgnore] |
| | | public ZigBee.Device.CommonDevice CommonDevice |
| | | { |
| | | get |
| | | { |
| | | //commonDevice = ZigBee.Device.CommonDevice.CommonDeviceByFilePath(DeviceFilePath); |
| | | //return commonDevice; |
| | | //if (commonDevice == null) |
| | | //{ |
| | | // return ReCommonDevice; |
| | | //} |
| | | //else{ |
| | | //return commonDevice; |
| | | if (DeviceFileName.Split('_').Length < 4) |
| | | { |
| | | return null; |
| | | } |
| | | return Common.LocalDevice.Current.GetDevice(DeviceFileName.Split('_')[2], int.Parse(DeviceFileName.Split('_')[3])); |
| | | //} |
| | | } |
| | | } |
| | | |
| | | //[Newtonsoft.Json.JsonIgnore] |
| | | //public ZigBee.Device.CommonDevice ReCommonDevice |
| | | //{ |
| | | // get |
| | | // { |
| | | //commonDevice= ZigBee.Device.CommonDevice.CommonDeviceByFilePath(DeviceFilePath); |
| | | //return commonDevice; |
| | | // } |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 控制延时默认反馈的线程列表 |
| | |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | string msg = Language.StringByID(r); |
| | | var tip = new Phone.UserCenter.TipViewControl(msg, 1000, 1); |
| | | tip.ShowView(); |
| | | var tip = new Phone.UserCenter.ShowMsgControl(Phone.UserCenter.ShowMsgType.Tip, msg); |
| | | tip.Show(); |
| | | }); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ◆ 保存____________________________ |
| | | |
| | | /// <summary> |
| | | /// 保存 |
| | | /// </summary> |
| | | public void Save() |
| | | { |
| | | if (Global.IsExistsByHomeId(FileName)) |
| | | { |
| | | return; |
| | | } |
| | | ReSave(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 重新保存 |
| | | /// </summary> |
| | | public void ReSave() |
| | | { |
| | | var paths = DeviceFileName.Split('_'); |
| | | if (paths.Length < 3) |
| | | { |
| | | return; |
| | | } |
| | | if (IconPath == string.Empty) |
| | | { |
| | | //控制面板是一个点
|
| | | if (paths[1] == ZigBee.Device.DeviceType.OnOffSwitch.ToString())
|
| | | {
|
| | | IconPath = "Device/DryContact.png";
|
| | | }
|
| | | else if (paths[1] == ZigBee.Device.DeviceType.ColorDimmableLight.ToString()) |
| | | { |
| | | //彩灯 |
| | | IconPath = "Device/ColorDimmableLight.png"; |
| | | }
|
| | | else if (paths[1] == ZigBee.Device.DeviceType.DimmableLight.ToString()) |
| | | { |
| | | //调光器 |
| | | IconPath = "Device/DimmableLight.png"; |
| | | } |
| | | else if (CommonDevice != null)
|
| | | {
|
| | | //其他的图标有点特殊
|
| | | string unSelectPic = string.Empty;
|
| | | string selectPic = string.Empty;
|
| | | LocalDevice.Current.GetDeviceBeloneIcon(new List<CommonDevice> { CommonDevice }, ref unSelectPic, ref selectPic);
|
| | | IconPath = unSelectPic;
|
| | | } |
| | | } |
| | | Global.WriteFileByBytesByHomeId(FileName, System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this))); |
| | | } |
| | | |
| | | #endregion |