gxc
2019-10-31 1a2061079e97a738ec7b8959bfd9a6e6c6997403
ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceCondition.cs
New file
@@ -0,0 +1,1452 @@
using System;
using Shared;
using Shared.R;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using ZigBee.Device;
using Shared.Common;
namespace Shared.Phone.Device.Logic
{
    public class TemplateDeviceCondition : FrameLayout
    {
        public TemplateDeviceCondition()
        {
            Tag = "Logic";
        }
        Button roombjButton = new Button();
        Button roomTextButton = new Button();
        Button devicetypeButton = new Button();
        VerticalScrolViewLayout middle;
        FrameLayout clickframeLayout = new FrameLayout();
        Button clickbutton = new Button();
        Button clicktextcolcrbutton = new Button();
        public void Show()
        {
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
            #region  最上面的布局代码
            var topRowLayout = new RowLayout
            {
                BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor,
                Height = Application.GetRealHeight(184),
                LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor,
            };
            this.AddChidren(topRowLayout);
            var titleName = new Button
            {
                TextSize = 16,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(160),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.devicestate,
            };
            topRowLayout.AddChidren(titleName);
            var clickBtn = new Button
            {
                Width = Application.GetRealWidth(81 + 51),
                Height = Application.GetRealHeight(58 + 40),
                Y = Application.GetRealHeight(98 - 40),
            };
            topRowLayout.AddChidren(clickBtn);
            clickBtn.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
                UserView.HomePage.Instance.ScrollEnabled = true;
            };
            var back = new Button
            {
                Width = Application.GetRealWidth(30),
                Height = Application.GetRealHeight(51),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(98),
                //Gravity = Gravity.CenterVertical;
                UnSelectedImagePath = "ZigeeLogic/back.png",
            };
            topRowLayout.AddChidren(back);
            back.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
                UserView.HomePage.Instance.ScrollEnabled = true;
            };
            var foolrname = new Button
            {
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterRight,
                X = Application.GetRealWidth(1080 - 400 - 120),
                Width = Application.GetRealWidth(400),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                // TextID = MyInternationalizationString.customroom,
                Text = Config.Instance.Home.GetCurrentFloorName,
            };
            topRowLayout.AddChidren(foolrname);
            var dropdown = new Button
            {
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterRight,
                X = foolrname.Right,
                Width = Application.GetRealWidth(72),
                Height = Application.GetRealHeight(72),
                Y = Application.GetRealHeight(92),
                UnSelectedImagePath = "ZigeeLogic/drop-down.png",
            };
            topRowLayout.AddChidren(dropdown);
            #endregion
            ///没有房间直接返回去;
            if (Common.Room.Lists.Count == 0)
            {
                return;
            }
            ///房间滑动控件
            var roomhorizontalScrol = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(1080 - 58),
                Height = Application.GetRealHeight(200),
                Y = topRowLayout.Bottom,
                X = Application.GetRealWidth(58),
            };
            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()
            {
                Width = Application.GetRealWidth(1080 - 58),
                Height = Application.GetRealHeight(280),
                Y = roomhorizontalScrol.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                X = Application.GetRealWidth(58),
                Radius = (uint)Application.GetRealHeight(50),
            };
            this.AddChidren(devicetypehorizontalScrol);
            middle = new VerticalScrolViewLayout();
            middle.Y = devicetypehorizontalScrol.Bottom + Application.GetRealHeight(40);
            middle.Height = Application.GetRealHeight(1920) - devicetypehorizontalScrol.Y;
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            middle.X = Application.GetRealWidth(58);
            middle.Radius = (uint)Application.GetRealHeight(50);
            this.AddChidren(middle);
            ///目前支持的设备
            var deviceTypeList = new List<DeviceType> {
                DeviceType.IASZone,
                //DeviceType.OnOffSwitch,
                //DeviceType.OnOffOutput,//楼梯灯
                //DeviceType.DoorLock
            };
            ///楼层点击事件
            EventHandler<MouseEventArgs> foorlclick=(sender,e) =>
            {
                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                this.AddChidren(flMain);
                flMain.MouseUpEventHandler += (sender2, e2) =>
                {
                    flMain.RemoveFromParent();
                };
                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),
                };
                flMain.AddChidren(foolrbj);
                ///默认调试
                foreach (var foolr in Config.Instance.Home.FloorDics)
                {
                    var foolrRowLayout = new FrameLayout
                    {
                        Height = Application.GetRealHeight(150),
                    };
                    foolrbj.AddChidren(foolrRowLayout);
                    var btnfoolrname = new Button
                    {
                        Width = Application.GetRealWidth(250),
                        Height = Application.GetRealHeight(160),
                        Text = foolr.Value,
                        TextAlignment = TextAlignment.Center,
                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        Tag = foolr.Key,
                    };
                    foolrRowLayout.AddChidren(btnfoolrname);
                    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;
                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
                }
            };
            foolrname.MouseUpEventHandler += foorlclick;
            dropdown.MouseUpEventHandler += foorlclick;
            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>
        /// 加载所有房间的视图方法
        /// </summary>
        void AllRoomView(List<Common.Room> roomlist, List<DeviceType> deviceTypeList, HorizontalScrolViewLayout roomhorizontalScrol, HorizontalScrolViewLayout devicetypehorizontalScrol)
        {
            for (int i = 0; i < roomlist.Count; i++)
            {
                var room = roomlist[i];
                var fra = new FrameLayout
                {
                    Height = Application.GetRealHeight(200),
                    Width = Application.GetRealWidth(255),
                };
                roomhorizontalScrol.AddChidren(fra);
                var roombjBtn = new Button
                {
                    Height = Application.GetRealHeight(158),
                    Width = Application.GetRealWidth(255),
                    UnSelectedImagePath = "ZigeeLogic/iconBackgroundColor.png",
                    SelectedImagePath = "ZigeeLogic/iconSelectedBackgroundColor.png",
                    Y = Application.GetRealHeight(21),
                };
                fra.AddChidren(roombjBtn);
                var roomnameBtn = new Button
                {
                    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),
                };
                fra.AddChidren(roomnameBtn);
                if (i == 0)//
                {
                    roombjButton.IsSelected = false;
                    roombjButton = roombjBtn;
                    roombjBtn.IsSelected = true;
                    roomTextButton.IsSelected = false;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    {
                        if (device.CommonDevice == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
                        {
                            continue;
                        }
                        list.Add(device);
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
                }
                EventHandler<MouseEventArgs> roomclick = (sender, e) =>
                {
                    roombjButton.IsSelected = false;
                    roombjButton = roombjBtn;
                    roombjBtn.IsSelected = true;
                    roomTextButton.IsSelected = false;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    {
                        if (device.CommonDevice == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
                        {
                            continue;
                        }
                        list.Add(device);
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
                };
                roomnameBtn.MouseUpEventHandler += roomclick;
                roombjBtn.MouseUpEventHandler += roomclick;
            }
        }
        /// <summary>
        /// 加载该区域所有设备视图方法
        /// </summary>0
        /// <param name="devicelist">Devicelist.</param>
        void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol)
        {
            List<string> devicetypelist = new List<string>();
            devicetypelist.Clear();
            #region  ------排列设备类型------
            ///暂时隐藏灯光和窗帘设备
            var lightjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.ColorDimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput);
            if (lightjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights));
            }
            var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice);
            if (curtainjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
            }
            var iASZonejosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.IASZone);
            if (iASZonejosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.sensor));
            }
            var onOffSwitchjson = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.OnOffSwitch);
            if (onOffSwitchjson != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.OnOffSwitch));
            }
            var doorLock = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.DoorLock);
            if (doorLock != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.doorLock));
            }
            #endregion
            devicetypehorizontalScrol.RemoveAll();
            for (int i = 0; i < devicetypelist.Count; i++)
            {
                var devicetype = devicetypelist[i];
                var spaceRowLayout = new FrameLayout();
                devicetypehorizontalScrol.AddChidren(spaceRowLayout);
                if (i == 0)
                {
                    spaceRowLayout.Width = Application.GetRealWidth(37);
                }
                else
                {
                    spaceRowLayout.Width = Application.GetRealWidth(80);
                }
                var deviceRowLayout = new FrameLayout
                {
                    Width = Application.GetRealWidth(156 + 20),
                    Height = Application.GetRealHeight(280 - 30),
                    Y = Application.GetRealHeight(30),
                };
                devicetypehorizontalScrol.AddChidren(deviceRowLayout);
                var backgroundColor = new Button
                {
                    Width = Application.GetRealWidth(156),
                    Height = Application.GetRealHeight(180),
                    X = Application.GetRealWidth(10),
                    UnSelectedImagePath = "ZigeeLogic/deviceunselectedbackgroundcolor.png",
                    SelectedImagePath = "ZigeeLogic/deviceselectedbackgroundcolor.png",
                };
                deviceRowLayout.AddChidren(backgroundColor);
                var devicetypeicon = new Button
                {
                    Width = Application.GetRealWidth(84),
                    Height = Application.GetRealHeight(84),
                    X = Application.GetRealWidth(46),
                    Y = Application.GetRealHeight(30),
                };
                deviceRowLayout.AddChidren(devicetypeicon);
                var devicetypename = new Button
                {
                    Width = Application.GetRealWidth(176),
                    Height = Application.GetRealHeight(40),
                    Text = devicetype,
                    TextAlignment = TextAlignment.Center,
                    Y = backgroundColor.Bottom,
                    TextColor = ZigbeeColor.Current.LogicAddColor,
                    TextSize = 10,
                };
                deviceRowLayout.AddChidren(devicetypename);
                if (devicetype == Language.StringByID(MyInternationalizationString.Lights))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedlight.png";
                    // devicetypeicon.SelectedImagePath = "ZigeeLogic/LightSelected.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedcurtain.png";
                    //devicetypeicon.SelectedImagePath = "ZigeeLogic/CurtainSelected.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.OnOffSwitch))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedpanel.png";
                    // devicetypeicon.SelectedImagePath = "ZigeeLogic/OnOffSwitchSelected.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.sensor))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedsenor.png";
                    // devicetypeicon.SelectedImagePath = "ZigeeLogic/SensorSelected.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.doorLock))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selecteddoorlock.png";
                }
                EventHandler<MouseEventArgs> devicetypeclick = (sender13, e13) =>
                {
                    List<DeviceType> list = new List<DeviceType>();
                    list.Clear();
                    devicetypeButton.IsSelected = false;
                    devicetypeButton = backgroundColor;
                    backgroundColor.IsSelected = true;
                    ///分类显示(例如灯光:{灯光1,灯光2...})
                    if (devicetype == Language.StringByID(MyInternationalizationString.Lights))
                    {
                        list.Add(DeviceType.OnOffOutput);//0x0101十进制257
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
                    {
                        list.Add(DeviceType.WindowCoveringDevice);
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.OnOffSwitch))
                    {
                        list.Add(DeviceType.OnOffSwitch);
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.sensor))
                    {
                        list.Add(DeviceType.IASZone);
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.doorLock))
                    {
                        list.Add(DeviceType.DoorLock);
                    }
                    ConditionDeviceView(list, devicelist);
                };
                deviceRowLayout.MouseUpEventHandler += devicetypeclick;
                devicetypename.MouseUpEventHandler += devicetypeclick;
                devicetypeicon.MouseUpEventHandler += devicetypeclick;
                backgroundColor.MouseUpEventHandler += devicetypeclick;
            }
            ///显示房间所有设备
            ConditionDeviceView(new List<DeviceType>(), devicelist);
        }
        /// <summary>
        /// 加载该类型设备视图方法
        /// </summary>
        /// <param name="deviceTypelist">Device typelist.</param>
        /// <param name="devicelist">设备列表</param>
        void ConditionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist)
        {
            middle.RemoveAll();
            foreach (var common in devicelist)
            {
                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type))
                {
                    continue;
                }
                if (common.CommonDevice.Type == DeviceType.IASZone)
                {
                    var iASZonedevice = common.CommonDevice as IASZone;
                    if (iASZonedevice.DeviceID != 1026 || iASZonedevice.IasDeviceType != 13)
                    {
                        continue;
                    }
                }
                var deviceFramelayout = new FrameLayout
                {
                    Height = Application.GetRealHeight(160),
                };
                middle.AddChidren(deviceFramelayout);
                var bjFramelayout = new FrameLayout
                {
                    Width = Application.GetRealWidth(112),
                    Height = Application.GetRealHeight(112),
                    X = Application.GetRealWidth(58),
                    Y = Application.GetRealHeight(30 + 9),
                    Radius = (uint)Application.GetRealHeight(56),
                    BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
                };
                deviceFramelayout.AddChidren(bjFramelayout);
                var deviceIconBtn = new Button
                {
                    Width = Application.GetRealWidth(82),
                    Height = Application.GetRealHeight(82),
                    Gravity = Gravity.Center,
                };
                bjFramelayout.AddChidren(deviceIconBtn);
                var deviceRow = new RowLayout
                {
                    Y = Application.GetRealHeight(30),
                    Width = Application.GetRealWidth(850),
                    Height = Application.GetRealHeight(130),
                    X = Application.GetRealWidth(176 + 10),
                    LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                };
                deviceFramelayout.AddChidren(deviceRow);
                var devicename = new Button
                {
                    Text = common.CommonDevice.DeviceEpointName,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                };
                deviceRow.AddChidren(devicename);
                switch (common.CommonDevice.Type)
                {
                    case DeviceType.OnOffOutput:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/light.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedlight.png";
                        }
                        break;
                    case DeviceType.IASZone:
                        {
                            var iASZonedevice = common.CommonDevice as IASZone;
                            if (iASZonedevice.DeviceID != 1026)
                            {
                                break;
                            }
                            deviceIconBtn.UnSelectedImagePath = $"ZigeeLogic/sensor{iASZonedevice.IasDeviceType}.png";
                            deviceIconBtn.SelectedImagePath = $"ZigeeLogic/selectedsensor{iASZonedevice.IasDeviceType}.png";
                        }
                        break;
                    case DeviceType.OnOffSwitch:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/panel.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedpanel.png";
                        }
                        break;
                    case DeviceType.DoorLock:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/doorlock.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selecteddoorlock.png";
                        }
                        break;
                }
                EventHandler<MouseEventArgs> devicclick = (sen, e) =>
                {
                    clickbutton.IsSelected = false;
                    clickbutton = deviceIconBtn;
                    deviceIconBtn.IsSelected = true;
                    clickframeLayout.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
                    clickframeLayout = bjFramelayout;
                    bjFramelayout.BackgroundColor = ZigbeeColor.Current.LogicIconBackgroundColor;
                    clicktextcolcrbutton.IsSelected = false;
                    clicktextcolcrbutton = devicename;
                    devicename.IsSelected = true;
                    var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                    this.AddChidren(flMain);
                    CurrentDeviceView(flMain, common.CommonDevice, false);
                };
                deviceFramelayout.MouseUpEventHandler += devicclick;
                bjFramelayout.MouseUpEventHandler += devicclick;
                deviceIconBtn.MouseUpEventHandler += devicclick;
                deviceRow.MouseUpEventHandler += devicclick;
                devicename.MouseUpEventHandler += devicclick;
            }
        }
        /// <summary>
        /// 选中该设备功能作为条件的视图方法
        /// </summary>
        /// <param name="common">Common.</param>
        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>>();
            Dictionary<string, string> deviceConditionsInfo = new Dictionary<string, string>();
            dictionary(deviceConditionsInfo, "Type", "1");
            dictionary(deviceConditionsInfo, "IsValid", "1");
            dictionary(deviceConditionsInfo, "MacAddr", common.DeviceAddr);
            dictionary(deviceConditionsInfo, "Epoint", common.DeviceEpoint.ToString());
            //var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
            //this.AddChidren(flMain);
            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
            {
                Width = Application.GetRealWidth(1080),
                Height = Application.GetRealHeight(530),
                Y = Application.GetRealHeight(1920 - 530),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                Radius = (uint)Application.GetRealHeight(60),
            };
            flMain.AddChidren(devicefra);
            #region  -------取消   完成
            var timetype = new RowLayout
            {
                Height = Application.GetRealHeight(140),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            devicefra.AddChidren(timetype);
            var Btncancel = new Button
            {
                TextID = MyInternationalizationString.cancel,
                TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
                Height = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(200),
                X = Application.GetRealWidth(80),
                TextAlignment = TextAlignment.CenterLeft,
            };
            timetype.AddChidren(Btncancel);
            Btncancel.MouseUpEventHandler += (sender16, e16) =>
            {
                flMain.RemoveFromParent();
                UserView.HomePage.Instance.ScrollEnabled = true;
            };
            var Btntitle = new Button
            {
                TextID = MyInternationalizationString.security,
                TextColor = ZigbeeColor.Current.LogicBtnTypeColor,
                Height = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(320),
                TextAlignment = TextAlignment.Center,
                X = Btncancel.Right + Application.GetRealWidth(100),
                TextSize = 16,
                Text = common.DeviceEpointName,
            };
            timetype.AddChidren(Btntitle);
            var Btncomplete = new Button
            {
                TextID = MyInternationalizationString.complete,
                TextColor = ZigbeeColor.Current.LogicBtnCompleteColor,
                Height = Application.GetRealHeight(140),
                Width = Application.GetRealWidth(200),
                TextAlignment = TextAlignment.CenterRight,
                X = Btntitle.Right + Application.GetRealWidth(100),
            };
            timetype.AddChidren(Btncomplete);
            #endregion
            string SelectedDeviceStatuscondition = "";
            Dictionary<string, string> devices = null;
            if (edit)
            {
                foreach (var deviceinfo in Common.Logic.CurrentLogic.Conditions)
                {
                    if (deviceinfo["Type"] == "1")
                    {
                        if (common.DeviceAddr == deviceinfo["MacAddr"] && common.DeviceEpoint.ToString() == deviceinfo["Epoint"])
                        {
                            devices = deviceinfo;
                            break;
                        }
                    }
                }
            }
            switch (common.Type)
            {
                ///灯光
                case DeviceType.OnOffOutput:
                    {
                        dictionary(deviceConditionsInfo, "Cluster_ID", "6");
                        dictionary(deviceConditionsInfo, "AttriButeId", "0");
                        dictionary(deviceConditionsInfo, "Range", "1");
                        dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                        #region  灯光View
                        var openframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(openframelayout);
                        var openrowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        openframelayout.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            Width = Application.GetRealWidth(600),
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        openrowlayout.AddChidren(btnopen);
                        var openBtnSelected = new SelectedButton();
                        openrowlayout.AddChidren(openBtnSelected);
                        var closeframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = openframelayout.Bottom,
                        };
                        devicefra.AddChidren(closeframelayout);
                        var closerowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        closeframelayout.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        closerowlayout.AddChidren(btnclose);
                        var closeBtnSelected = new SelectedButton();
                        closerowlayout.AddChidren(closeBtnSelected);
                        #endregion
                        ///点击确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            btnopen.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                            btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                            SelectedDeviceStatuscondition = "OnOffOutput";
                            dictionary(deviceConditionsInfo, "AttriButeData1", "1");//默认值
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        openframelayout.MouseUpEventHandler += openclick;
                        ///点击取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                            btnclose.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            SelectedDeviceStatuscondition = "OnOffOutput";
                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");//默认值
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        closeframelayout.MouseUpEventHandler += closeclick;
                        if (edit && devices != null)
                        {
                            if (devices["AttriButeId"] == "0")
                            {
                                if (devices["AttriButeData1"] == "1")
                                {
                                    btnopen.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                    btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                    openBtnSelected.Visible = true;
                                    closeBtnSelected.Visible = false;
                                }
                                else
                                {
                                    btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                    btnclose.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                    openBtnSelected.Visible = false;
                                    closeBtnSelected.Visible = true;
                                }
                            }
                        }
                    }
                    break;
                case DeviceType.WindowCoveringDevice:
                    {
                        dictionary(deviceConditionsInfo, "Cluster_ID", "258");
                        dictionary(deviceConditionsInfo, "AttriButeId", "8");
                        dictionary(deviceConditionsInfo, "Range", "0");
                        dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                        #region 窗帘View
                        devicefra.Y = Application.GetRealHeight(1920 - 30 - 720);
                        devicefra.Height = Application.GetRealHeight(720);
                        var windowCoveringfra = new FrameLayout
                        {
                            Y = Application.GetRealHeight(180),
                            Height = Application.GetRealHeight(180 * 2 + 30),
                        };
                        devicefra.AddChidren(windowCoveringfra);
                        var openrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                        };
                        windowCoveringfra.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            //Text = "开",
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(50),
                            Width = Application.GetRealWidth(300),
                            Height = Application.GetRealHeight(180),
                            //SelectedBackgroundColor = 0xfffe5e00,
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        };
                        openrowlayout.AddChidren(btnopen);
                        var openBtnSelected = new Button
                        {
                            X = Application.GetRealWidth(1000 - 150),
                            Width = Application.GetMinRealAverage(110),
                            Height = Application.GetMinRealAverage(110),
                            UnSelectedImagePath = "Item/YesSelected.png",
                            Visible = false,
                            Gravity = Gravity.CenterVertical
                        };
                        openrowlayout.AddChidren(openBtnSelected);
                        var closerowlayout = new RowLayout
                        {
                            Y = openrowlayout.Bottom,
                            Height = Application.GetRealHeight(180),
                        };
                        windowCoveringfra.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(50),
                            Width = Application.GetRealWidth(300),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        };
                        closerowlayout.AddChidren(btnclose);
                        var closeBtnSelected = new Button
                        {
                            X = Application.GetRealWidth(1000 - 150),
                            Width = Application.GetMinRealAverage(110),
                            Height = Application.GetMinRealAverage(110),
                            UnSelectedImagePath = "Item/YesSelected.png",
                            Visible = false,
                            Gravity = Gravity.CenterVertical
                        };
                        closerowlayout.AddChidren(closeBtnSelected);
                        #endregion
                        ///点击确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            SelectedDeviceStatuscondition = "WindowCoveringDevice";
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            dictionary(deviceConditionsInfo, "AttriButeData1", "95");//默认值
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        ///点击取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            SelectedDeviceStatuscondition = "WindowCoveringDevice";
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            dictionary(deviceConditionsInfo, "AttriButeData1", "5");//默认值
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        if (edit && devices != null)
                        {
                            if (devices["AttriButeId"] == "8")
                            {
                                if (int.Parse(devices["AttriButeData1"]) > 5)
                                {
                                    openBtnSelected.Visible = true;
                                    closeBtnSelected.Visible = false;
                                }
                                else
                                {
                                    openBtnSelected.Visible = false;
                                    closeBtnSelected.Visible = true;
                                }
                            }
                        }
                    }
                    break;
                case DeviceType.IASZone:
                    {
                        var iASZonedevice = common as IASZone;
                        if (iASZonedevice.DeviceID != 1026)
                        {
                            break;
                        }
                        dictionary(deviceConditionsInfo, "Cluster_ID", "1280");
                        dictionary(deviceConditionsInfo, "AttriButeId", "1281");
                        dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                        #region  安防设备View
                        var openframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(openframelayout);
                        var openrowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        openframelayout.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            Width = Application.GetRealWidth(600),
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        openrowlayout.AddChidren(btnopen);
                        var openBtnSelected = new SelectedButton();
                        openrowlayout.AddChidren(openBtnSelected);
                        var closeframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = openframelayout.Bottom,
                        };
                        devicefra.AddChidren(closeframelayout);
                        var closerowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        closeframelayout.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        closerowlayout.AddChidren(btnclose);
                        var closeBtnSelected = new SelectedButton();
                        closerowlayout.AddChidren(closeBtnSelected);
                        #endregion
                        int timevalue = 0;
                        ///点击确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            SelectedDeviceStatuscondition = "IASZone";
                            btnopen.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                            btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            if (iASZonedevice.IasDeviceType == 13)
                            {
                                closeBtnSelected.Visible = true;
                            }
                            dictionary(deviceConditionsInfo, "Range", "5");
                            dictionary(deviceConditionsInfo, "AttriButeData1", "1");
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        openframelayout.MouseUpEventHandler += openclick;
                        ///点击取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            SelectedDeviceStatuscondition = "IASZone";
                            btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                            btnclose.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            dictionary(deviceConditionsInfo, "Range", "1");
                            dictionary(deviceConditionsInfo, "AttriButeData1", "0");
                            if (iASZonedevice.IasDeviceType == 13)
                            {
                                SelectedDeviceStatuscondition = "no";
                                btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                openBtnSelected.Visible = false;
                                closeBtnSelected.Visible = true;
                                var ignoreTime = new IgnoreTime();
                                UserView.HomePage.Instance.AddChidren(ignoreTime);
                                UserView.HomePage.Instance.PageIndex += 1;
                                ignoreTime.Show(common, btnclose.Text, edit, timevalue);
                            }
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        closeframelayout.MouseUpEventHandler += closeclick;
                        switch (iASZonedevice.IasDeviceType)
                        {
                            case 13:
                                {
                                    btnopen.TextID = MyInternationalizationString.someone;
                                    btnclose.TextID = MyInternationalizationString.unattendedtime1;
                                    closeBtnSelected.UnSelectedImagePath = "ZigeeLogic/next.png";
                                    closeBtnSelected.Visible = true;
                                    openframelayout.AddChidren(openrowlayout);
                                    closeframelayout.AddChidren(closerowlayout);
                                }
                                break;
                            case 21:
                            case 22:
                                {
                                    #region
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 * 3 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 * 3 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.logicopen;
                                    btnclose.TextID = MyInternationalizationString.logicclose;
                                    closerowlayout.LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor;
                                    openframelayout.AddChidren(openrowlayout);
                                    closeframelayout.AddChidren(closerowlayout);
                                    var timeoutframelayout = new FrameLayout
                                    {
                                        Height = Application.GetRealHeight(160),
                                        Y = closeframelayout.Bottom,
                                    };
                                    devicefra.AddChidren(timeoutframelayout);
                                    var timeoutrowlayout = new RowLayout
                                    {
                                        Y = Application.GetRealHeight(30),
                                        Width = Application.GetRealWidth(920),
                                        Height = Application.GetRealHeight(130),
                                        X = Application.GetRealWidth(80),
                                        LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                                    };
                                    timeoutframelayout.AddChidren(timeoutrowlayout);
                                    var btntimeout = new Button
                                    {
                                        TextID = MyInternationalizationString.closetimeout,
                                        Width = Application.GetRealWidth(600),
                                        TextAlignment = TextAlignment.CenterLeft,
                                        TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                                    };
                                    timeoutrowlayout.AddChidren(btntimeout);
                                    var timeoutBtnSelected = new Button
                                    {
                                        X = Application.GetRealWidth(860),
                                        Width = Application.GetMinRealAverage(60),
                                        Height = Application.GetMinRealAverage(60),
                                        UnSelectedImagePath = "ZigeeLogic/next.png",
                                        Gravity = Gravity.CenterVertical,
                                    };
                                    timeoutrowlayout.AddChidren(timeoutBtnSelected);
                                    EventHandler<MouseEventArgs> timeoutclick = (sender, e) =>
                                    {
                                        SelectedDeviceStatuscondition = "no";
                                        btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                        btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = false;
                                        var ignoreTime = new IgnoreTime();
                                        UserView.HomePage.Instance.AddChidren(ignoreTime);
                                        UserView.HomePage.Instance.PageIndex += 1;
                                        ignoreTime.Show(common, btntimeout.Text, edit, timevalue);
                                    };
                                    timeoutframelayout.MouseUpEventHandler += timeoutclick;
                                    timeoutrowlayout.MouseUpEventHandler += timeoutclick;
                                    btntimeout.MouseUpEventHandler += timeoutclick;
                                    timeoutBtnSelected.MouseUpEventHandler += timeoutclick;
                                    #endregion
                                }
                                break;
                            case 40:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.smokescreen;
                                    //btnclose.TextID = MyInternationalizationString.nosmokescreen;
                                    openframelayout.AddChidren(openrowlayout);
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                            case 42:
                                {
                                    btnopen.TextID = MyInternationalizationString.waterleakage;
                                    btnclose.TextID = MyInternationalizationString.noleakage;
                                    openframelayout.AddChidren(openrowlayout);
                                    closeframelayout.AddChidren(closerowlayout);
                                }
                                break;
                            case 43:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.gas;
                                    //btnclose.TextID = MyInternationalizationString.nogas;
                                    openframelayout.AddChidren(openrowlayout);
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                            case 44:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.emergencybutton;
                                    //btnclose.TextID = MyInternationalizationString.nosmokescreen;
                                    openframelayout.AddChidren(openrowlayout);
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                            case 277:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.callthepolice;
                                    //btnclose.TextID = MyInternationalizationString.nosmokescreen;
                                    openframelayout.AddChidren(openrowlayout);
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                            default:
                                {
                                    devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                                    devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                                    btnopen.TextID = MyInternationalizationString.callthepolice;
                                    openframelayout.AddChidren(openrowlayout);
                                    openrowlayout.LineColor = ZigbeeColor.Current.LogicBackgroundColor;
                                }
                                break;
                        }
                        if (edit && devices != null)
                        {
                            if (devices["AttriButeId"] == "1281")
                            {
                                if (devices["AttriButeData1"] == "1")
                                {
                                    btnopen.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                    btnclose.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                    openBtnSelected.Visible = true;
                                    closeBtnSelected.Visible = false;
                                }
                                else
                                {
                                    if (devices.ContainsKey("IgnoreTime"))
                                    {
                                        timevalue = int.Parse(devices["IgnoreTime"]);
                                    }
                                    else
                                    {
                                        btnopen.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
                                        btnclose.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = true;
                                    }
                                }
                            }
                        }
                    }
                    break;
                case DeviceType.OnOffSwitch:
                    {
                        dictionary(deviceConditionsInfo, "Cluster_ID", "1282");
                        dictionary(deviceConditionsInfo, "AttriButeId", "1283");
                        dictionary(deviceConditionsInfo, "Range", "0");//按键特殊
                        dictionary(deviceConditionsInfo, "AttriButeData1", "0");
                        dictionary(deviceConditionsInfo, "AttriButeData2", "0");
                        devicefra.Y = Application.GetRealHeight(1920 - 140 - 160 - 20 - 50);
                        devicefra.Height = Application.GetRealHeight(140 + 160 + 20 + 50);
                        var OnOffOutputfra = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(OnOffOutputfra);
                        var buttonRow = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        OnOffOutputfra.AddChidren(buttonRow);
                        var button = new Button
                        {
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            Text = Language.StringByID(MyInternationalizationString.OnOffSwitch) + common.DeviceEpoint.ToString(),
                            //SelectedBackgroundColor = 0xfffe5e00,
                        };
                        buttonRow.AddChidren(button);
                        var buttonSelected = new SelectedButton();
                        buttonRow.AddChidren(buttonSelected);
                        EventHandler<MouseEventArgs> buttonclick = (sender, e) =>
                        {
                            buttonSelected.Visible = true;
                            SelectedDeviceStatuscondition = "OnOffSwitch";
                            button.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                        };
                        buttonRow.MouseUpEventHandler += buttonclick;
                        button.MouseUpEventHandler += buttonclick;
                        buttonSelected.MouseUpEventHandler += buttonclick;
                        OnOffOutputfra.MouseUpEventHandler += buttonclick;
                        if (edit && devices != null)
                        {
                            buttonSelected.Visible = true;
                            button.TextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
                        }
                    }
                    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
                        var memberList = new MemberList();
                        UserView.HomePage.Instance.AddChidren(memberList);
                        UserView.HomePage.Instance.PageIndex += 1;
                        MemberList.action += () => { flMain.RemoveFromParent(); };
                        memberList.Show(common);
                    }
                    break;
            }
            Btncomplete.MouseUpEventHandler += (sender2, e2) =>
            {
                //UserView.HomePage.Instance.ScrollEnabled = true;
                if (SelectedDeviceStatuscondition != "")
                {
                    LogicIfon.AddDeviceconditions(common, deviceConditionsInfo);
                }
                else
                {
                    if (!edit)
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                               Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                                               Language.StringByID(MyInternationalizationString.complete));
                        alert.Show();
                        return;
                    }
                }
                flMain.RemoveFromParent();
                var templatePage = new TemplatePage();
                UserView.HomePage.Instance.AddChidren(templatePage);
                UserView.HomePage.Instance.PageIndex += 1;
                templatePage.Show();
            };
        }
        public static void dictionary(Dictionary<string, string> deviceConditionsInfo, string Key, string Value)
        {
            if (deviceConditionsInfo.ContainsKey(Key))
            {
                deviceConditionsInfo.Remove(Key);
            }
            deviceConditionsInfo.Add(Key, Value);
        }
    }
}