WJC
2019-10-31 d7ad5a3953a8cd001659092ebde204b881f94b9d
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) =>