From d7ad5a3953a8cd001659092ebde204b881f94b9d Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期四, 31 十月 2019 10:47:13 +0800
Subject: [PATCH] 2019-10-31-1

---
 ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs |  184 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 164 insertions(+), 20 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
index b61b296..24b3a70 100644
--- a/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
+++ b/ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
@@ -88,7 +88,8 @@
                 Width = Application.GetRealWidth(400),
                 Height = Application.GetRealHeight(69),
                 Y = Application.GetRealHeight(92),
-                TextID = MyInternationalizationString.customroom,
+                //TextID = MyInternationalizationString.customroom,
+                Text = Config.Instance.Home.GetCurrentFloorName,
             };
             topRowLayout.AddChidren(foolrname);
             var dropdown = new Button
@@ -102,6 +103,7 @@
                 UnSelectedImagePath = "ZigeeLogic/drop-down.png",
             };
             topRowLayout.AddChidren(dropdown);
+
             #endregion
 
             ///娌℃湁鎴块棿鐩存帴杩斿洖鍘伙紱
@@ -154,11 +156,12 @@
                 DeviceType.IASZone,
                 DeviceType.OnOffSwitch,
                 DeviceType.OnOffOutput,//妤兼鐏�
-                DeviceType.DoorLock
+                DeviceType.DoorLock,
+                DeviceType.TemperatureSensor,
             };
 
             ///妤煎眰鐐瑰嚮浜嬩欢
-            foolrname.MouseUpEventHandler += (sender, e) =>
+            EventHandler<MouseEventArgs> foorlclick = (sender, e) =>
             {
 
                 var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
@@ -178,10 +181,9 @@
                     Radius = (uint)Application.GetRealHeight(30),
                 };
                 flMain.AddChidren(foolrbj);
-                ///榛樿璋冭瘯
-                List<string> foolrlist = new List<string> { "涓�妤�", "浜屾ゼ", "涓夋ゼ" };
-                foreach (var foolr in foolrlist)
+                foreach (var foolr in Config.Instance.Home.FloorDics)
                 {
+
                     var foolrRowLayout = new FrameLayout
                     {
                         Height = Application.GetRealHeight(150),
@@ -192,32 +194,57 @@
                     {
                         Width = Application.GetRealWidth(250),
                         Height = Application.GetRealHeight(160),
-                        Text = foolr,
+                        Text = foolr.Value,
                         TextAlignment = TextAlignment.Center,
                         TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                         //SelectedTextColor=0xfffc744b,
+                        Tag = foolr.Key,
                     };
                     foolrRowLayout.AddChidren(btnfoolrname);
 
 
-                    EventHandler<MouseEventArgs> foolrclick = (sender13, e13) =>
+                    EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
                     {
                         roomhorizontalScrol.RemoveAll();
+                        devicetypehorizontalScrol.RemoveAll();
+                        middle.RemoveAll();
                         foolrname.Text = btnfoolrname.Text;
                         flMain.RemoveFromParent();
-                        ///澶囨敞锛氭樉绀洪�変腑妤煎眰鐨勬墍鏈夋埧闂�
-                        AllRoomView(Common.Room.Lists, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
-
+                        var list = Send.GetRoomList(btnfoolrname.Tag.ToString());
+                        AllRoomView(list, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
                     };
-                    foolrRowLayout.MouseUpEventHandler += foolrclick;
-                    btnfoolrname.MouseUpEventHandler += foolrclick;
+                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
+                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
 
 
                 }
 
             };
+            foolrname.MouseUpEventHandler += foorlclick;
+            dropdown.MouseUpEventHandler += foorlclick;
             ///绗竴娆¤繘鏉�
-            AllRoomView(Common.Room.Lists, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
+            var roomlists = new List<Common.Room>();
+            roomlists.Clear();
+            if (Config.Instance.Home.FloorDics.Count < 2)
+            {
+                foolrname.Visible = false;
+                dropdown.Visible = false;
+                if (Config.Instance.Home.FloorDics.Count == 0)
+                {
+                    roomlists.AddRange(Common.Room.Lists);
+                }
+                else
+                {
+                    roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
+                }
+            }
+            else
+            {
+                roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
+
+            }
+
+            AllRoomView(roomlists, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
         }
         /// <summary>
         /// 鍔犺浇鎵�鏈夋埧闂寸殑瑙嗗浘鏂规硶
@@ -272,6 +299,9 @@
                     var list = new List<DeviceUI>();
                     foreach (var device in room.DeviceUIList)
                     {
+                        if (device.CommonDevice==null) {
+                            continue;
+                        }
                         if (!deviceTypeList.Contains(device.CommonDevice.Type))
                         {
                             continue;
@@ -298,6 +328,9 @@
                     var list = new List<DeviceUI>();
                     foreach (var device in room.DeviceUIList)
                     {
+                        if (device.CommonDevice==null) {
+                            continue;
+                        }
                         if (!deviceTypeList.Contains(device.CommonDevice.Type))
                         {
                             continue;
@@ -334,7 +367,7 @@
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
             }
 
-            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone);
+            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone|| device.CommonDevice.Type == DeviceType.TemperatureSensor);
             if (iASZonejosn != null)
             {
                 devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
@@ -454,6 +487,7 @@
                     else if (devicetype == Language.StringByID(MyInternationalizationString.sensor))
                     {
                         list.Add(DeviceType.IASZone);
+                        list.Add(DeviceType.TemperatureSensor);
                     }
                     else if (devicetype == Language.StringByID(MyInternationalizationString.doorLock))
                     {
@@ -555,6 +589,21 @@
                             deviceIconBtn.SelectedImagePath = $"ZigeeLogic/selectedsensor{iASZonedevice.IasDeviceType}.png";
 
 
+                        }
+                        break;
+                    case DeviceType.TemperatureSensor:
+                        {
+                            var temperatureSensor = common.CommonDevice as TemperatureSensor;
+                            if (temperatureSensor.SensorDiv == 1)
+                            {
+                                deviceIconBtn.UnSelectedImagePath = $"ZigeeLogic/temperature.png";
+                                deviceIconBtn.SelectedImagePath = $"ZigeeLogic/selectedtemperature.png";
+                            }
+                            else
+                            {
+                                deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/humidity.png";
+                                deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedhumidity.png";
+                            }
                         }
                         break;
                     case DeviceType.OnOffSwitch:
@@ -1322,8 +1371,7 @@
                 case DeviceType.DoorLock:
                     {
                         #region  ------
-                        var doorlockifonlist = Send.ReadDoorLockIfon("ccccccfffe300347");
-                        //var list = Send.ReadDoorLockIfon(common.DeviceAddr);
+                        var doorlockifonlist = await Send.UserListIfon(common.DeviceAddr);
                         var pra = new UserCenter.MemberListInfoPra();
                         string result = await UserCenter.UserCenterLogic.GetResponseDataByRequestHttps("ZigbeeUsers/GetSubAccountByDistributedMark", false, pra);
                         var listInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<List<UserCenter.MemberInfoRes>>(result);
@@ -1337,9 +1385,20 @@
                                 ///鏌ユ壘鎴愬憳浠ュ強鎴愬憳闂ㄩ攣瑙﹀彂婧�(1鎸夐敭/3鍗�/15鎸囩汗)
                                 if (doorlockifonlist[j].CloudAccountId == membershipifon.SubAccountDistributedMark)
                                 {
-                                    membership.UserIdMode.Add(doorlockifonlist[j].UserIdMode);
-                                    membership.MembershipName = membershipifon.UserName;
+                                    var lockMode = new Send.LockMode();
+                                    lockMode.UserId = doorlockifonlist[j].DoorLockLocalUserId;
+                                    lockMode.OpenMode = doorlockifonlist[j].OpenLockMode;
+                                    membership.UserIdMode.Add(lockMode);
                                     membership.MembershipId = membershipifon.SubAccountDistributedMark;
+                                    if (string.IsNullOrEmpty(membershipifon.UserName))
+                                    {
+                                        membership.MembershipName = membershipifon.Account;
+                                    }
+                                    else
+                                    {
+                                        membership.MembershipName = membershipifon.UserName;
+
+                                    }
 
                                 }
 
@@ -1347,7 +1406,7 @@
                             if (membership.UserIdMode.Count != 0)
                             {
                                 ///杩囨护鎺夐噸澶嶆暟鎹紱
-                                var str = Send.UserList.Find((c) => { return c.MembershipId == membership.MembershipId; });
+                                var str = Send.UserList.Find((c) => { return c.MembershipId == membershipifon.SubAccountDistributedMark; });
                                 if (str == null)
                                 {
                                     Send.UserList.Add(membership);
@@ -1364,7 +1423,92 @@
                         memberList.Show(common);
                     }
                     break;
+                case DeviceType.TemperatureSensor:
+                    {
+                        string current = Language.StringByID(MyInternationalizationString.current);
+                        devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 * 2 - 20 - 50);
+                        devicefra.Height = Application.GetRealHeight(140 + 160 * 2 + 20 + 50);
+                        var temperatureSensor = common as TemperatureSensor;
+                        var Btntemperaturevalue = new Button
+                        {
+                            TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
+                            Height = Application.GetRealHeight(60),
+                            Width = Application.GetRealWidth(400),
+                            TextAlignment = TextAlignment.CenterLeft,
+                            X = Application.GetRealWidth(80),
+                            Y = timetype.Bottom + Application.GetRealHeight(70),
+                        };
+                        devicefra.AddChidren(Btntemperaturevalue);
 
+                        var horizontalSeekBarVol = new HorizontalSeekBar
+                        {
+                            Width = Application.GetRealWidth(920),
+                            Height = Application.GetRealHeight(80),
+                            Radius = (uint)Application.GetRealHeight(25),
+                            Y = timetype.Bottom + Application.GetRealHeight(70 + 60 + 70),
+                            X = Application.GetRealWidth(80),
+                            ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected,
+                            Max = 100,
+                            SleepTime = 1000,
+                            ThumbRadius = 9,
+                        };
+                        devicefra.AddChidren(horizontalSeekBarVol);
+                        horizontalSeekBarVol.MouseUpEventHandler += (sender, e) =>
+                        {
+                            SelectedDeviceStatuscondition = "TemperatureSensor";
+                            if (temperatureSensor.SensorDiv == 1)
+                            {
+                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());
+
+                                Btntemperaturevalue.Text = current + ">" + horizontalSeekBarVol.Progress.ToString() + "鈩�";
+
+                            }
+                            else
+                            {
+                                Btntemperaturevalue.Text = current + "<" + horizontalSeekBarVol.Progress.ToString() + "%";
+                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());//娓╁害鍊�
+                            }
+                        };
+
+
+
+                        if (temperatureSensor.SensorDiv == 1)
+                        {
+                            dictionary(deviceConditionsInfo, "Cluster_ID", "1026");
+                            dictionary(deviceConditionsInfo, "AttriButeId", "0");
+                            dictionary(deviceConditionsInfo, "Range", "0");//0澶т簬AttriButeData1鏃惰Е鍙戝姩浣�
+                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");
+                            dictionary(deviceConditionsInfo, "AttriButeData2", "0");
+                            Btntemperaturevalue.Text = current + ">0鈩�";
+
+                        }
+                        else
+                        {
+                            Btntemperaturevalue.Text = current + "<0%";
+                            dictionary(deviceConditionsInfo, "Cluster_ID", "1029");
+                            dictionary(deviceConditionsInfo, "AttriButeId", "0");
+                            dictionary(deviceConditionsInfo, "Range", "2");//2灏忎簬AttriButeData1鏃惰Е鍙戝姩浣�
+                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");//娓╁害鍊�
+                            dictionary(deviceConditionsInfo, "AttriButeData2", "0");
+                        }
+
+                        if (edit && devices != null)
+                        {
+                            horizontalSeekBarVol.Progress = int.Parse(devices["AttriButeData1"]);
+                            if (temperatureSensor.SensorDiv == 1)
+                            {
+
+                                Btntemperaturevalue.Text = current + ">" + devices["AttriButeData1"] + "鈩�";
+
+                            }
+                            else
+                            {
+                                Btntemperaturevalue.Text = current + "<" + devices["AttriButeData1"] + "%";
+                            }
+                        }
+
+                    }
+                    break;
             }
 
             Btncomplete.MouseUpEventHandler += (sender2, e2) =>

--
Gitblit v1.8.0