gxc
2019-12-25 944b87b6bcccb095cd73f13f4410fb20faf48f74
ZigbeeApp/Shared/Phone/Device/Logic/DeviceStateCondition.cs
@@ -23,7 +23,7 @@
        FrameLayout clickframeLayout = new FrameLayout();
        Button clickbutton = new Button();
        Button clicktextcolcrbutton = new Button();
        public void Show()
        {
@@ -40,11 +40,11 @@
            var titleName = new Button
            {
                TextSize = 16,
                TextSize = 17,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(160),
                Width = Application.GetRealWidth(300),
                Width = Application.GetRealWidth(600),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.devicestate,
@@ -90,6 +90,7 @@
                Y = Application.GetRealHeight(92),
                //TextID = MyInternationalizationString.customroom,
                Text = Config.Instance.Home.GetCurrentFloorName,
                TextSize = 14,
            };
            topRowLayout.AddChidren(foolrname);
            var dropdown = new Button
@@ -121,15 +122,6 @@
            };
            this.AddChidren(roomhorizontalScrol);
            var devicetypehorizontalScrol1 = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(1080 - 58 - 200),
                Height = Application.GetRealHeight(280),
                Y = roomhorizontalScrol.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                X = Application.GetRealWidth(58 + 200),
            };
            this.AddChidren(devicetypehorizontalScrol1);
            ///设备类型滑动控件
            var devicetypehorizontalScrol = new HorizontalScrolViewLayout()
            {
@@ -138,19 +130,20 @@
                Y = roomhorizontalScrol.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                X = Application.GetRealWidth(58),
                Radius = (uint)Application.GetRealHeight(50),
               // Radius = (uint)Application.GetRealHeight(50),
            };
            this.AddChidren(devicetypehorizontalScrol);
            devicetypehorizontalScrol.SetCornerWithSameRadius(20,HDLUtils.RectCornerBottomLeft);
            middle = new VerticalScrolViewLayout();
            middle.Y = devicetypehorizontalScrol.Bottom + Application.GetRealHeight(40);
            middle.Height = Application.GetRealHeight(1920) - devicetypehorizontalScrol.Y;
            middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            middle.X = Application.GetRealWidth(58);
            middle.Radius = (uint)Application.GetRealHeight(50);
            //middle.Radius = (uint)Application.GetRealHeight(50);
            this.AddChidren(middle);
            middle.SetCornerWithSameRadius(20, HDLUtils.RectCornerTopLeft);
            ///目前支持的设备
            var deviceTypeList = new List<DeviceType> {
                DeviceType.IASZone,
@@ -170,47 +163,86 @@
                {
                    flMain.RemoveFromParent();
                };
                var foolrbjicon = new FrameLayout
                {
                    Width = Application.GetRealWidth(450),
                    Height = Application.GetRealHeight(780),
                    X = Application.GetRealWidth(1080 - 468 - 35),
                    Y = Application.GetRealHeight(184),
                    BackgroundImagePath = "Item/SelectFloor_Right.png",
                };
                flMain.AddChidren(foolrbjicon);
                var btnfoolrtext = new Button
                {
                    Width = Application.GetRealWidth(450),
                    Height = Application.GetRealHeight(150),
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    X = Application.GetRealWidth(80),
                    TextID = MyInternationalizationString.selecfoolr,
                    TextSize = 14,
                };
                foolrbjicon.AddChidren(btnfoolrtext);
                var foolrbj = new VerticalScrolViewLayout
                {
                    Width = Application.GetRealWidth(400),
                    Height = Application.GetRealHeight(600),
                    X = Application.GetRealWidth(1080 - 400 - 60),
                    Y = Application.GetRealHeight(184 + 50),
                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                    Radius = (uint)Application.GetRealHeight(30),
                    Width = Application.GetRealWidth(450),
                    Height = foolrbjicon.Height - btnfoolrtext.Height,
                    X = Application.GetRealWidth(80),
                    Y = btnfoolrtext.Bottom,
                };
                flMain.AddChidren(foolrbj);
                foolrbjicon.AddChidren(foolrbj);
                foreach (var foolr in Config.Instance.Home.FloorDics)
                {
                    var foolrRowLayout = new FrameLayout
                    var foolrRowLayout = new RowLayout
                    {
                        Height = Application.GetRealHeight(150),
                        LineColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                    };
                    foolrbj.AddChidren(foolrRowLayout);
                    var btnfoolricon = new Button
                    {
                        Width = Application.GetRealWidth(81),
                        Height = Application.GetRealHeight(81),
                        UnSelectedImagePath = "Floor/Floor.png",
                        Gravity = Gravity.CenterVertical,
                    };
                    foolrRowLayout.AddChidren(btnfoolricon);
                    var btnfoolrname = new Button
                    {
                        Width = Application.GetRealWidth(250),
                        Height = Application.GetRealHeight(160),
                        Height = Application.GetRealHeight(150),
                        Text = foolr.Value,
                        TextAlignment = TextAlignment.Center,
                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        //SelectedTextColor=0xfffc744b,
                        TextAlignment = TextAlignment.CenterLeft,
                        TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                        Tag = foolr.Key,
                        X = btnfoolricon.Right + Application.GetRealWidth(12),
                        TextSize = 14,
                    };
                    foolrRowLayout.AddChidren(btnfoolrname);
                    if (foolrname.Text == foolr.Value)
                    {
                        btnfoolricon.UnSelectedImagePath = "Floor/FloorSelected.png";
                        btnfoolrname.TextColor = ZigbeeColor.Current.LogicTextBlackColor;
                    }
                    EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
                    {
                        roomhorizontalScrol.RemoveAll();
                        devicetypehorizontalScrol.RemoveAll();
                        middle.RemoveAll();
                        foolrname.Text = btnfoolrname.Text;
                        flMain.RemoveFromParent();
                        var list = Send.GetRoomList(btnfoolrname.Tag.ToString());
                        AllRoomView(list, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
                    };
                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
@@ -268,20 +300,20 @@
                    Width = Application.GetRealWidth(255),
                    UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png",
                    SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png",
                    Y=Application.GetRealHeight(21),
                    Y = Application.GetRealHeight(21),
                };
                fra.AddChidren(roombjBtn);
                var roomnameBtn= new Button
                var roomnameBtn = new Button
                {
                    Height = Application.GetRealHeight(152-26-20),
                    Width = Application.GetRealWidth(255-20-50),
                    Height = Application.GetRealHeight(152 - 26 - 20),
                    Width = Application.GetRealWidth(255 - 20 - 50),
                    Text = room.Name,
                    TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                    Y=Application.GetRealHeight(21 +13+10),
                    X=Application.GetRealWidth(10+25),
                    Y = Application.GetRealHeight(21 + 13 + 10),
                    X = Application.GetRealWidth(10 + 25),
                };
                fra.AddChidren(roomnameBtn);
@@ -299,7 +331,8 @@
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    {
                        if (device.CommonDevice==null) {
                        if (device.CommonDevice == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
@@ -308,6 +341,17 @@
                        }
                        list.Add(device);
                    }
                    if (list.Count == 0)
                    {
                        devicetypehorizontalScrol.Height = 0;
                        middle.Height = 0;
                    }
                    else
                    {
                        devicetypehorizontalScrol.Height = Application.GetRealHeight(280);
                        middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
                }
@@ -328,7 +372,8 @@
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    {
                        if (device.CommonDevice==null) {
                        if (device.CommonDevice == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
@@ -337,6 +382,18 @@
                        }
                        list.Add(device);
                    }
                    if (list.Count == 0)
                    {
                        devicetypehorizontalScrol.Height = 0;
                        middle.Height = 0;
                    }
                    else
                    {
                        devicetypehorizontalScrol.Height = Application.GetRealHeight(280);
                        middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
@@ -367,7 +424,7 @@
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
            }
            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone|| device.CommonDevice.Type == DeviceType.TemperatureSensor);
            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone || device.CommonDevice.Type == DeviceType.TemperatureSensor);
            if (iASZonejosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
@@ -537,7 +594,7 @@
                    Height = Application.GetRealHeight(112),
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(30 + 9),
                    Radius = (uint)Application.GetRealHeight(56),
                   // Radius = (uint)Application.GetRealHeight(56),
                    BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                };
                deviceFramelayout.AddChidren(bjFramelayout);
@@ -568,6 +625,7 @@
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                    TextSize = 14,
                };
                deviceRow.AddChidren(devicename);
                switch (common.CommonDevice.Type)
@@ -648,11 +706,11 @@
        /// 选中该设备功能作为条件的视图方法
        /// </summary>
        /// <param name="common">Common.</param>
        public async static  void CurrentDeviceView(FrameLayout flMain, CommonDevice common, bool edit)
        public async static void CurrentDeviceView(FrameLayout flMain, CommonDevice common, bool edit)
        {
            //不让当前界面滑动
            UserView.HomePage.Instance.ScrollEnabled = false;
            List<Dictionary<string, string>> doorlockConditionsInfo= new List<Dictionary<string, string>>();
            List<Dictionary<string, string>> doorlockConditionsInfo = new List<Dictionary<string, string>>();
            Dictionary<string, string> deviceConditionsInfo = new Dictionary<string, string>();
            dictionary(deviceConditionsInfo, "Type", "1");
            dictionary(deviceConditionsInfo, "IsValid", "1");
@@ -663,18 +721,7 @@
            flMain.MouseUpEventHandler += (sender, e) =>
            {
                flMain.RemoveFromParent();
            };
            var devicefra1 = new FrameLayout
            {
                Width = Application.GetRealWidth(1080),
                Height = Application.GetRealHeight(100),
                Y = Application.GetRealHeight(1920 - 100),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
            };
            flMain.AddChidren(devicefra1);
            var devicefra = new FrameLayout
            {
@@ -683,9 +730,10 @@
                Height = Application.GetRealHeight(530),
                Y = Application.GetRealHeight(1920 - 530),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                Radius = (uint)Application.GetRealHeight(60),
               // Radius = (uint)Application.GetRealHeight(60),
            };
            flMain.AddChidren(devicefra);
            devicefra.SetCornerWithSameRadius(20, HDLUtils.RectCornerTopLeft|HDLUtils.RectCornerTopRight);
            #region  -------取消   完成
            var timetype = new RowLayout
@@ -702,6 +750,7 @@
                Width = Application.GetRealWidth(200),
                X = Application.GetRealWidth(80),
                TextAlignment = TextAlignment.CenterLeft,
                TextSize = 14,
            };
            timetype.AddChidren(Btncancel);
            Btncancel.MouseUpEventHandler += (sender16, e16) =>
@@ -715,9 +764,9 @@
                TextID = MyInternationalizationString.security,
                TextColor = ZigbeeColor.Current.LogicBtnTypeColor,
                Height = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(320),
                Width = Application.GetRealWidth(420),
                TextAlignment = TextAlignment.Center,
                X = Btncancel.Right + Application.GetRealWidth(100),
                X = Btncancel.Right + Application.GetRealWidth(50),
                TextSize = 16,
                Text = common.DeviceEpointName,
            };
@@ -729,7 +778,8 @@
                Height = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(200),
                TextAlignment = TextAlignment.CenterRight,
                X = Btntitle.Right + Application.GetRealWidth(100),
                X = Btntitle.Right + Application.GetRealWidth(50),
                TextSize = 14,
            };
            timetype.AddChidren(Btncomplete);
@@ -790,6 +840,7 @@
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            TextSize = 14,
                        };
                        openrowlayout.AddChidren(btnopen);
@@ -820,6 +871,7 @@
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            TextSize = 14,
                        };
                        closerowlayout.AddChidren(btnclose);
@@ -915,6 +967,7 @@
                            Height = Application.GetRealHeight(180),
                            //SelectedBackgroundColor = 0xfffe5e00,
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextSize = 14,
                        };
                        openrowlayout.AddChidren(btnopen);
@@ -945,6 +998,7 @@
                            Width = Application.GetRealWidth(300),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextSize = 14,
                        };
                        closerowlayout.AddChidren(btnclose);
@@ -1041,6 +1095,7 @@
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            TextSize = 14,
                        };
                        openrowlayout.AddChidren(btnopen);
@@ -1071,6 +1126,7 @@
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            TextSize = 14,
                        };
                        closerowlayout.AddChidren(btnclose);
@@ -1114,7 +1170,7 @@
                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");
                            if (iASZonedevice.IasDeviceType == 13)
                            {
                                SelectedDeviceStatuscondition = "no";
                                SelectedDeviceStatuscondition = "";
                                btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                openBtnSelected.Visible = false;
@@ -1196,7 +1252,7 @@
                                    timeoutrowlayout.AddChidren(timeoutBtnSelected);
                                    EventHandler<MouseEventArgs> timeoutclick = (sender, e) =>
                                    {
                                        SelectedDeviceStatuscondition = "no";
                                        SelectedDeviceStatuscondition = "";
                                        btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                        btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                        openBtnSelected.Visible = false;
@@ -1215,7 +1271,6 @@
                                    #endregion
                                }
                                break;
                            case 40:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
@@ -1255,7 +1310,6 @@
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                            case 277:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
@@ -1342,6 +1396,7 @@
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            Text = Language.StringByID(MyInternationalizationString.OnOffSwitch) + common.DeviceEpoint.ToString(),
                            TextSize = 14,
                            //SelectedBackgroundColor = 0xfffe5e00,
                        };
                        buttonRow.AddChidren(button);
@@ -1349,12 +1404,12 @@
                        var buttonSelected = new SelectedButton();
                        buttonRow.AddChidren(buttonSelected);
                        EventHandler<MouseEventArgs> buttonclick = (sender, e) =>
                       {
                           buttonSelected.Visible = true;
                           SelectedDeviceStatuscondition = "OnOffSwitch";
                           button.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                        {
                            buttonSelected.Visible = true;
                            SelectedDeviceStatuscondition = "OnOffSwitch";
                            button.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                       };
                        };
                        buttonRow.MouseUpEventHandler += buttonclick;
                        button.MouseUpEventHandler += buttonclick;
                        buttonSelected.MouseUpEventHandler += buttonclick;
@@ -1370,52 +1425,18 @@
                    break;
                case DeviceType.DoorLock:
                    {
                        #region  ------
                        var doorlockifonlist = Send.ReadDoorLockIfon("ccccccfffe300347");
                        //var list = Send.ReadDoorLockIfon(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);
                        Send.UserList.Clear();
                        for (int i = 0; i < listInfo.Count; i++)
                        {
                            var membership = new Send.MembershipIfon();
                            var membershipifon = listInfo[i];
                            for (int j = 0; j < doorlockifonlist.Count; j++)
                            {
                                ///查找成员以及成员门锁触发源(1按键/3卡/15指纹)
                                if (doorlockifonlist[j].CloudAccountId == membershipifon.SubAccountDistributedMark)
                                {
                                    membership.UserIdMode.Add(doorlockifonlist[j].UserIdMode);
                                    membership.MembershipName = membershipifon.UserName;
                                    membership.MembershipId = membershipifon.SubAccountDistributedMark;
                                }
                            }
                            if (membership.UserIdMode.Count != 0)
                            {
                                ///过滤掉重复数据;
                                var str = Send.UserList.Find((c) => { return c.MembershipId == membership.MembershipId; });
                                if (str == null)
                                {
                                    Send.UserList.Add(membership);
                                }
                            }
                        }
                        #endregion
                        flMain.RemoveFromParent();
                        var memberList = new MemberList();
                        UserView.HomePage.Instance.AddChidren(memberList);
                        UserView.HomePage.Instance.PageIndex += 1;
                        MemberList.action += () => { flMain.RemoveFromParent(); };
                        MemberList.edit = false;
                        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;
@@ -1427,6 +1448,7 @@
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(80),
                            Y = timetype.Bottom + Application.GetRealHeight(70),
                            TextSize = 14,
                        };
                        devicefra.AddChidren(Btntemperaturevalue);
@@ -1450,12 +1472,12 @@
                            {
                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());
                                Btntemperaturevalue.Text = "当前>" + horizontalSeekBarVol.Progress.ToString() + "℃";
                                Btntemperaturevalue.Text = current + ">" + horizontalSeekBarVol.Progress.ToString() + "℃";
                            }
                            else
                            {
                                Btntemperaturevalue.Text = "当前<" + horizontalSeekBarVol.Progress.ToString() + "%";
                                Btntemperaturevalue.Text = current + "<" + horizontalSeekBarVol.Progress.ToString() + "%";
                                dictionary(deviceConditionsInfo, "AttriButeData1", horizontalSeekBarVol.Progress.ToString());//温度值
                            }
                        };
@@ -1469,12 +1491,12 @@
                            dictionary(deviceConditionsInfo, "Range", "0");//0大于AttriButeData1时触发动作
                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");
                            dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                            Btntemperaturevalue.Text = "当前>0℃";
                            Btntemperaturevalue.Text = current + ">0℃";
                        }
                        else
                        {
                            Btntemperaturevalue.Text = "当前<0%";
                            Btntemperaturevalue.Text = current + "<0%";
                            dictionary(deviceConditionsInfo, "Cluster_ID", "1029");
                            dictionary(deviceConditionsInfo, "AttriButeId", "0");
                            dictionary(deviceConditionsInfo, "Range", "2");//2小于AttriButeData1时触发动作
@@ -1488,12 +1510,12 @@
                            if (temperatureSensor.SensorDiv == 1)
                            {
                                Btntemperaturevalue.Text = "当前>" + devices["AttriButeData1"] + "℃";
                                Btntemperaturevalue.Text = current + ">" + devices["AttriButeData1"] + "℃";
                            }
                            else
                            {
                                Btntemperaturevalue.Text = "当前<" + devices["AttriButeData1"] + "%";
                                Btntemperaturevalue.Text = current + "<" + devices["AttriButeData1"] + "%";
                            }
                        }
@@ -1540,7 +1562,7 @@
            deviceConditionsInfo.Add(Key, Value);
        }
    }
}