From 52005ed57f3f7bc796fdd1a878e4f298a126f1e8 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 29 十月 2019 16:48:47 +0800
Subject: [PATCH] 2019.10.29-3
---
ZigbeeApp/Shared/Common/DeviceUI.cs | 215 +++++++++++++++++++++--------------------------------
1 files changed, 85 insertions(+), 130 deletions(-)
diff --git a/ZigbeeApp/Shared/Common/DeviceUI.cs b/ZigbeeApp/Shared/Common/DeviceUI.cs
index cb57e47..78b9db5 100644
--- a/ZigbeeApp/Shared/Common/DeviceUI.cs
+++ b/ZigbeeApp/Shared/Common/DeviceUI.cs
@@ -15,27 +15,13 @@
#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>
/// 璁惧鏂囦欢
@@ -45,20 +31,58 @@
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璁惧鏂囦欢鍚嶏紝鎸囩殑鏄痙evice锛�
- /// </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>
@@ -68,51 +92,14 @@
{
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>
/// 鎺у埗寤舵椂榛樿鍙嶉鐨勭嚎绋嬪垪琛�
@@ -169,64 +156,9 @@
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
@@ -380,5 +312,28 @@
}
#endregion
+
+ #region 鈼� 閫氳繃id鑾峰彇璁惧鍖哄煙_____________
+
+ /// <summary>
+ /// GetZone
+ /// </summary>
+ /// <returns></returns>
+ public string GetZone()
+ {
+ var room = Room.CurrentRoom.GetRoomByDevice(CommonDevice);
+ if (room == null)
+ {
+ return Language.StringByID(R.MyInternationalizationString.UnallocatedArea);
+ }
+ var floorName = Config.Instance.Home.GetFloorNameById(room.FloorId);
+ if (floorName == null)
+ {
+ return room.Name;
+ }
+ return $"{floorName},{room.Name}";
+ }
+
+ #endregion
}
}
--
Gitblit v1.8.0