gxc
2019-10-29 081ea8d273048fd03756718ac6fb48a3c09218e9
ZigbeeApp/Shared/Phone/Device/Logic/LogicDevicePage.cs
@@ -16,83 +16,139 @@
        {
            Tag = "Logic";
        }
        Button SelectedButton = new Button();
        HorizontalScrolViewLayout horizontalScrol;
        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.LogicTopViewBackgroundColor;
            var topFrameLayout = new RowLayout
            UserView.HomePage.Instance.ScrollEnabled = false;
            this.BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor;
            #region  最上面的布局代码
            var topRowLayout = new RowLayout
            {
                Height = Application.GetRealHeight(220),
                Y = Application.GetRealHeight(80),
                BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor,
                BackgroundColor = ZigbeeColor.Current.LogicTopBackgroundColor,
                Height = Application.GetRealHeight(184),
                LineColor = ZigbeeColor.Current.LogicRowLayoutTopLineColor,
            };
            AddChidren(topFrameLayout);
            this.AddChidren(topRowLayout);
            var titleName = new Button
            {
                TextID = MyInternationalizationString.devicestate,
                TextSize = 17,
                TextSize = 16,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextAlignment = TextAlignment.CenterLeft,
                X = Application.GetRealWidth(150),
                X = Application.GetRealWidth(160),
                Width = Application.GetRealWidth(300),
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.devicestate,
            };
            topFrameLayout.AddChidren(titleName);
            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(110),
                Height = Application.GetRealHeight(110),
                X = Application.GetRealWidth(20),
                Gravity = Gravity.CenterVertical,
                UnSelectedImagePath = "ZigeeLogic/Back.png",
                Width = Application.GetRealWidth(30),
                Height = Application.GetRealHeight(51),
                X = Application.GetRealWidth(81),
                Y = Application.GetRealHeight(98),
                //Gravity = Gravity.CenterVertical;
                UnSelectedImagePath = "ZigeeLogic/back.png",
            };
            topFrameLayout.AddChidren(back);
            topRowLayout.AddChidren(back);
            back.MouseDownEventHandler += (sender, e) =>
            {
                RemoveFromParent();
                UserView.HomePage.Instance.ScrollEnabled = true;
            };
            var  roomname = new Button
            var foolrname = new Button
            {
                Width = Application.GetMinRealAverage(300 + 300-30),
                Height = Application.GetMinRealAverage(80),
                X = Application.GetRealWidth(1080 - 300 - 30 - 300),
                Y = Application.GetRealHeight(120),
                TextAlignment = TextAlignment.CenterRight,
                //Text = "自定义房间",
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextID=MyInternationalizationString.customroom,
                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,
            };
            topFrameLayout.AddChidren(roomname);
           var  horizontalScrolfl = new FrameLayout
            topRowLayout.AddChidren(foolrname);
            var dropdown = new Button
            {
                Height = Application.GetRealHeight(220 + 30),
                Y = topFrameLayout.Bottom,
                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),
            };
            AddChidren(horizontalScrolfl);
             horizontalScrol = new HorizontalScrolViewLayout()
            this.AddChidren(devicetypehorizontalScrol1);
            ///设备类型滑动控件
            var devicetypehorizontalScrol = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(1080 - 40),
                Height = Application.GetRealHeight(180 + 30),
                Y = Application.GetRealHeight(40),
                X = Application.GetRealWidth(40),
                Radius = (uint)Application.GetRealHeight(30),
                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),
            };
            horizontalScrolfl.AddChidren(horizontalScrol);
            this.AddChidren(devicetypehorizontalScrol);
            middle = new VerticalScrolViewLayout();
            middle.Y = horizontalScrolfl.Bottom;
            middle.Height = Application.GetRealHeight(1920 - 300 - 250);
            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);
            ///目前支持的设备
@@ -100,10 +156,14 @@
                DeviceType.OnOffOutput,
                DeviceType.DimmableLight,
                DeviceType.WindowCoveringDevice,
                DeviceType.Thermostat,
                DeviceType.AirSwitch,
            };
            ///房间点击事件
            roomname.MouseUpEventHandler += (sender, e) =>
            ///楼层点击事件
            EventHandler<MouseEventArgs> foorlclick = (sender, e) =>
            {
                var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
@@ -112,101 +172,191 @@
                {
                    flMain.RemoveFromParent();
                };
                var roombj = new VerticalScrolViewLayout
                var foolrbj = new VerticalScrolViewLayout
                {
                    Width = Application.GetRealWidth(400),
                    Height = Application.GetRealHeight(600),
                    X = Application.GetRealWidth(1080 - 400 - 60),
                    Y = Application.GetRealHeight(220 + 30 + 80),
                    Y = Application.GetRealHeight(184 + 50),
                    BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                    Radius = (uint)Application.GetRealHeight(30),
                };
                flMain.AddChidren(roombj);
                List<Common.Room> roomlist = new List<Common.Room>();
                roomlist.Clear();
                Common.Room customroom = new Common.Room();
                customroom.Name = Language.StringByID(MyInternationalizationString.customroom);
                foreach (var device in Common.Logic.LogicDviceList)
                flMain.AddChidren(foolrbj);
                foreach (var foolr in Config.Instance.Home.FloorDics)
                {
                    var deviceui = customroom.GetDeviceUI(device);
                    if (deviceui != null)
                    {
                        customroom.DeviceUIList.Add(deviceui);
                    }
                }
                roomlist.Add(customroom);
                roomlist.AddRange(Common.Room.Lists);
                foreach (var room in roomlist)
                {
                    var rowLayout = new RowLayout
                    var foolrRowLayout = new FrameLayout
                    {
                        Height = Application.GetRealHeight(150),
                    };
                    roombj.AddChidren(rowLayout);
                    foolrbj.AddChidren(foolrRowLayout);
                    var btnroomname = new Button
                    var btnfoolrname = new Button
                    {
                        Width = Application.GetRealWidth(300),
                        Text = room.Name,
                        TextAlignment = TextAlignment.CenterLeft,
                        X = Application.GetRealWidth(30),
                        Width = Application.GetRealWidth(250),
                        Height = Application.GetRealHeight(160),
                        Text = foolr.Value,
                        TextAlignment = TextAlignment.Center,
                        TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        //SelectedTextColor=0xfffc744b,
                        Tag = foolr.Key,
                    };
                    rowLayout.AddChidren(btnroomname);
                    foolrRowLayout.AddChidren(btnfoolrname);
                    EventHandler<MouseEventArgs> roomclick = (sender1, e1) =>
                    EventHandler<MouseEventArgs> foolrnameclick = (sender13, e13) =>
                    {
                        roomhorizontalScrol.RemoveAll();
                        devicetypehorizontalScrol.RemoveAll();
                        middle.RemoveAll();
                        foolrname.Text = btnfoolrname.Text;
                        flMain.RemoveFromParent();
                        roomname.Text = room.Name;
                        var list = new List<DeviceUI>();
                        foreach (var device in room.DeviceUIList) {
                            if (!deviceTypeList.Contains(device.CommonDevice.Type))
                            {
                                continue;
                            }
                            list.Add(device);
                        }
                        AllDeviceTypeView(list);
                        var list = Send.GetRoomList(btnfoolrname.Tag.ToString());
                        AllRoomView(list, deviceTypeList, roomhorizontalScrol, devicetypehorizontalScrol);
                    };
                    rowLayout.MouseUpEventHandler += roomclick;
                    btnroomname.MouseUpEventHandler += roomclick;
                    foolrRowLayout.MouseUpEventHandler += foolrnameclick;
                    btnfoolrname.MouseUpEventHandler += foolrnameclick;
                }
            };
            Common.Room customroom1 = new Common.Room();
            foreach (var device in Common.Logic.LogicDviceList)
            foolrname.MouseUpEventHandler += foorlclick;
            dropdown.MouseUpEventHandler += foorlclick;
            ///第一次进来
            var roomlists = new List<Common.Room>();
            roomlists.Clear();
            if (Config.Instance.Home.FloorDics.Count < 2)
            {
                //过滤掉没有用到设备;
                if (!deviceTypeList.Contains(device.Type))
                foolrname.Visible = false;
                dropdown.Visible = false;
                if (Config.Instance.Home.FloorDics.Count == 0)
                {
                    continue;
                    roomlists.AddRange(Common.Room.Lists);
                }
                var deviceui = customroom1.GetDeviceUI(device);
                if (deviceui != null)
                else
                {
                    customroom1.DeviceUIList.Add(deviceui);
                    roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
                }
            }
            else
            {
                roomlists = Send.GetRoomList(Config.Instance.Home.CurrentFloorId);
            }
            AllDeviceTypeView(customroom1.DeviceUIList);
            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>
        void AllDeviceTypeView(List<DeviceUI> devicelist)
        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.DimmableLight || device.CommonDevice.Type == DeviceType.OnOffOutput);
            if (lightjosn != null)
@@ -218,58 +368,99 @@
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
            }
            #endregion
            horizontalScrol.RemoveAll();
            foreach (var devicetype in devicetypelist)
            var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat);
            if (ac != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC));
            }
            var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch);
            if (airSwitch != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch));
            }
            #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
                {
                    Height = Application.GetRealHeight(180 + 30),
                    Width = Application.GetRealWidth(250),
                    Width = Application.GetRealWidth(156 + 20),
                    Height = Application.GetRealHeight(280 - 30),
                    Y = Application.GetRealHeight(30),
                };
                horizontalScrol.AddChidren(deviceRowLayout);
                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(110),
                    Height = Application.GetRealHeight(110),
                    X = Application.GetRealWidth(70),
                    Width = Application.GetRealWidth(84),
                    Height = Application.GetRealHeight(84),
                    X = Application.GetRealWidth(46),
                    Y = Application.GetRealHeight(30),
                };
                deviceRowLayout.AddChidren(devicetypeicon);
                if (devicetype == Language.StringByID(MyInternationalizationString.Lights))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/Light.png";
                    devicetypeicon.SelectedImagePath = "ZigeeLogic/LightSelected.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/Curtain.png";
                    devicetypeicon.SelectedImagePath = "ZigeeLogic/CurtainSelected.png";
                }
                var devicetypename = new Button
                {
                    Width = Application.GetRealWidth(250),
                    Height = Application.GetRealHeight(50),
                    Width = Application.GetRealWidth(176),
                    Height = Application.GetRealHeight(40),
                    Text = devicetype,
                    TextAlignment = TextAlignment.Center,
                    Y = devicetypeicon.Bottom + Application.GetRealHeight(20),
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    Y = backgroundColor.Bottom,
                    TextColor = ZigbeeColor.Current.LogicAddColor,
                    TextSize = 10,
                };
                deviceRowLayout.AddChidren(devicetypename);
                if (devicetype == Language.StringByID(MyInternationalizationString.Lights))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedlight.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.Curtains))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedcurtain.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.AC))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedac.png";
                }
                else if (devicetype == Language.StringByID(MyInternationalizationString.Airswitch))
                {
                    devicetypeicon.UnSelectedImagePath = "ZigeeLogic/selectedairswitch.png";
                }
                EventHandler<MouseEventArgs> devicetypeclick = (sender13, e13) =>
                {
                    devicetypeButton.IsSelected = false;
                    devicetypeButton = backgroundColor;
                    backgroundColor.IsSelected = true;
                    List<DeviceType> list = new List<DeviceType>();
                    list.Clear();
                    SelectedButton.IsSelected = false;
                    SelectedButton = devicetypeicon;
                    SelectedButton.IsSelected = true;
                    ///分类显示(例如灯光:{灯光1,灯光2...})
                    if (devicetype == Language.StringByID(MyInternationalizationString.Lights))
                    {
@@ -280,6 +471,14 @@
                    {
                        list.Add(DeviceType.WindowCoveringDevice);
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.AC))
                    {
                        list.Add(DeviceType.Thermostat);
                    }
                    else if (devicetype == Language.StringByID(MyInternationalizationString.Airswitch))
                    {
                        list.Add(DeviceType.AirSwitch);
                    }
                    ActionDeviceView(list, devicelist);
@@ -287,16 +486,17 @@
                deviceRowLayout.MouseUpEventHandler += devicetypeclick;
                devicetypename.MouseUpEventHandler += devicetypeclick;
                devicetypeicon.MouseUpEventHandler += devicetypeclick;
                backgroundColor.MouseUpEventHandler += devicetypeclick;
            }
            ///显示房间所有设备
            ActionDeviceView( new List<DeviceType>(), devicelist);
            ActionDeviceView(new List<DeviceType>(), devicelist);
        }
        /// <summary>
        /// 加载该类型设备视图方法
        /// </summary>
        /// <param name="devicelist">设备列表</param>
        void ActionDeviceView( List<DeviceType> deviceTypelist, List<DeviceUI> devicelist)
        void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist)
        {
            middle.RemoveAll();
            foreach (var common in devicelist)
@@ -306,45 +506,109 @@
                {
                    continue;
                }
                var row = new RowLayout
                var deviceFramelayout = new FrameLayout
                {
                    Height = Application.GetRealHeight(180),
                    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,
                };
                middle.AddChidren(row);
                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
                {
                    Gravity = Gravity.CenterVertical,
                    TextAlignment = TextAlignment.CenterLeft,
                    X = Application.GetRealWidth(40),
                    Width = Application.GetRealWidth(600),
                    //SelectedBackgroundColor = 0xFFE9652D,
                    Text = common.CommonDevice.DeviceEpointName,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                };
                row.AddChidren(devicename);
                var btndeviceback = new Button
                deviceRow.AddChidren(devicename);
                switch (common.CommonDevice.Type)
                {
                    Width = Application.GetRealWidth(110),
                    Height = Application.GetRealHeight(110),
                    UnSelectedImagePath = "ZigeeLogic/Next.png",
                    X = Application.GetRealWidth(1080 - 140),
                    Gravity = Gravity.CenterVertical,
                };
                row.AddChidren(btndeviceback);
                    case DeviceType.OnOffOutput:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/light.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedlight.png";
                        }
                        break;
                    case DeviceType.DimmableLight:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/dimmableLight.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selecteddimmableLight.png";
                        }
                        break;
                    case DeviceType.WindowCoveringDevice:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/curtain.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedcurtain.png";
                        }
                        break;
                    case DeviceType.Thermostat:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/ac.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedac.png";
                        }
                        break;
                    case DeviceType.AirSwitch:
                        {
                            deviceIconBtn.UnSelectedImagePath = "ZigeeLogic/airswitch.png";
                            deviceIconBtn.SelectedImagePath = "ZigeeLogic/selectedairswitch.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);
                    CurrentDeviceStateView(flMain, common.CommonDevice, false);
                };
                row.MouseUpEventHandler += devicclick;
                deviceFramelayout.MouseUpEventHandler += devicclick;
                bjFramelayout.MouseUpEventHandler += devicclick;
                deviceIconBtn.MouseUpEventHandler += devicclick;
                deviceRow.MouseUpEventHandler += devicclick;
                devicename.MouseUpEventHandler += devicclick;
                btndeviceback.MouseUpEventHandler += devicclick;
            }
        }
@@ -364,50 +628,76 @@
            {
                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 - 80),
                X = Application.GetRealWidth(40),
                Width = Application.GetRealWidth(1080),
                Height = Application.GetRealHeight(530 + 160),
                Y = Application.GetRealHeight(1920 - 530 - 160),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                Radius = (uint)Application.GetRealHeight(50),
                Radius = (uint)Application.GetRealHeight(60),
            };
            flMain.AddChidren(devicefra);
            var devicename = new Button
            #region  -------取消   完成
            var timetype = new RowLayout
            {
                Y = Application.GetRealHeight(20),
                Text = common.DeviceEpointName,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                Height = Application.GetRealHeight(150),
                Width = Application.GetRealWidth(1080 - 80),
                Height = Application.GetRealHeight(140),
                LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
            };
            devicefra.AddChidren(devicename);
            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
            if (actionsInfo.ContainsKey("LinkType"))
            {
                actionsInfo.Remove("LinkType");
            }
            if (actionsInfo.ContainsKey("DeviceAddr"))
            {
                actionsInfo.Remove("DeviceAddr");
            }
            if (actionsInfo.ContainsKey("Epoint"))
            {
                actionsInfo.Remove("Epoint");
            }
            if (actionsInfo.ContainsKey("Time"))
            {
                actionsInfo.Remove("Time");
            }
            if (actionsInfo.ContainsKey("TaskList"))
            {
                actionsInfo.Remove("TaskList");
            }
            string SelectedDeviceStatusaction = "no";
            actionsInfo.Add("LinkType", 0);
            actionsInfo.Add("DeviceAddr", common.DeviceAddr);
            actionsInfo.Add("Epoint", common.DeviceEpoint);
@@ -432,6 +722,7 @@
            }
            switch (common.Type)
            {
                ///灯光
                case DeviceType.OnOffOutput:
                    {
@@ -454,123 +745,162 @@
                        switchdictionary.Add("Data1", "0");
                        switchdictionary.Add("Data2", "0");
                        taskListInfo.Add(switchdictionary);
                        #endregion
                        #region  灯光View
                        devicefra.Y = Application.GetRealHeight(1920 - 30 - 720);
                        devicefra.Height = Application.GetRealHeight(720);
                        var OnOffOutputfra = new FrameLayout
                        #region 开
                        var openframelayout = new FrameLayout
                        {
                            Y = Application.GetRealHeight(180),
                            Height = Application.GetRealHeight(180 * 2+ 30),
                            Height = Application.GetRealHeight(160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(OnOffOutputfra);
                        devicefra.AddChidren(openframelayout);
                        var openrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        OnOffOutputfra.AddChidren(openrowlayout);
                        openframelayout.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            //Text = "开",
                            Width = Application.GetRealWidth(600),
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            //SelectedBackgroundColor = 0xfffe5e00,
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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
                        };
                        var openBtnSelected = new SelectedButton();
                        openrowlayout.AddChidren(openBtnSelected);
                        #endregion
                        #region  关
                        var closeframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = openframelayout.Bottom,
                        };
                        devicefra.AddChidren(closeframelayout);
                        var closerowlayout = new RowLayout
                        {
                            Y = openrowlayout.Bottom,
                            Height = Application.GetRealHeight(180),
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        OnOffOutputfra.AddChidren(closerowlayout);
                        closeframelayout.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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,
                        };
                        var closeBtnSelected = new SelectedButton();
                        closerowlayout.AddChidren(closeBtnSelected);
                        #endregion
                        #region   取反
                        var takebackframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = closeframelayout.Bottom,
                        };
                        devicefra.AddChidren(takebackframelayout);
                        var takebackrowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        takebackframelayout.AddChidren(takebackrowlayout);
                        var btntakeback = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.onoff,
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        takebackrowlayout.AddChidren(btntakeback);
                        var takebackBtnSelected = new SelectedButton();
                        takebackrowlayout.AddChidren(takebackBtnSelected);
                        #endregion
                        #endregion
                        ///确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            takebackBtnSelected.Visible = false;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "1");//默认值
                            LogicIfon.AddDeviceactions(common,actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        openframelayout.MouseUpEventHandler += openclick;
                        ///取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            takebackBtnSelected.Visible = false;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "0");//默认值
                            LogicIfon.AddDeviceactions(common, actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        closeframelayout.MouseUpEventHandler += closeclick;
                        //取反
                        EventHandler<MouseEventArgs> takebackclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = false;
                            takebackBtnSelected.Visible = true;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "2");//默认值
                        };
                        takebackrowlayout.MouseUpEventHandler += takebackclick;
                        btntakeback.MouseUpEventHandler += takebackclick;
                        takebackBtnSelected.MouseUpEventHandler += takebackclick;
                        takebackframelayout.MouseUpEventHandler += takebackclick;
                        if (edit && TaskList != null)
                        {
                            foreach (var value in TaskList)
@@ -586,12 +916,21 @@
                                        switchdictionary.Add("Data1", "1");
                                        openBtnSelected.Visible = true;
                                        closeBtnSelected.Visible = false;
                                        takebackBtnSelected.Visible = false;
                                    }
                                    else
                                    else if (value["Data1"] == "0")
                                    {
                                        switchdictionary.Add("Data1", "0");
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = true;
                                        takebackBtnSelected.Visible = false;
                                    }
                                    else if (value["Data1"] == "2")
                                    {
                                        switchdictionary.Add("Data1", "2");
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = false;
                                        takebackBtnSelected.Visible = true;
                                    }
                                    break;
                                }
@@ -607,208 +946,290 @@
                        #region  ----初始化设备功能数据----
                        Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
                        if (switchdictionary.ContainsKey("TaskType"))
                        {
                            switchdictionary.Remove("TaskType");
                        }
                        if (switchdictionary.ContainsKey("Data1"))
                        {
                            switchdictionary.Remove("Data1");
                        }
                        if (switchdictionary.ContainsKey("Data2"))
                        {
                            switchdictionary.Remove("Data2");
                        }
                        switchdictionary.Add("TaskType", "1");
                        switchdictionary.Add("Data1", "0");
                        switchdictionary.Add("Data2", "0");
                        taskListInfo.Add(switchdictionary);
                        //Dictionary<string, string> brightnessdictionary = new Dictionary<string, string>();
                        //if (brightnessdictionary.ContainsKey("TaskType"))
                        //{
                        //    switchdictionary.Remove("TaskType");
                        //}
                        //if (brightnessdictionary.ContainsKey("Data1"))
                        //{
                        //    brightnessdictionary.Remove("Data1");
                        //}
                        //if (brightnessdictionary.ContainsKey("Data2"))
                        //{
                        //    switchdictionary.Remove("Data2");
                        //}
                        //brightnessdictionary.Add("TaskType", "3");
                        //brightnessdictionary.Add("Data1", "0");
                        //brightnessdictionary.Add("Data2", "0");
                        //taskListInfo.Add(brightnessdictionary);
                        #endregion
                        #region  灯光View
                        devicefra.Y = Application.GetRealHeight(1920 - 30 - 900);
                        devicefra.Height = Application.GetRealHeight(900);
                        var OnOffOutputfra = new FrameLayout
                        devicefra.Y = Application.GetRealHeight(1920 - 160 * 3 - 210 - 160);
                        devicefra.Height = Application.GetRealHeight(160 * 3 + 210 + 160);
                        #region 开
                        var openframelayout = new FrameLayout
                        {
                            Y = Application.GetRealHeight(180),
                            Height = Application.GetRealHeight(180 * 3 + 30),
                            Height = Application.GetRealHeight(160 + 160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(OnOffOutputfra);
                        devicefra.AddChidren(openframelayout);
                        var openrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        OnOffOutputfra.AddChidren(openrowlayout);
                        openframelayout.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            //Text = "开",
                            Width = Application.GetRealWidth(600),
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            //SelectedBackgroundColor = 0xfffe5e00,
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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
                        };
                        var openBtnSelected = new SelectedButton();
                        openrowlayout.AddChidren(openBtnSelected);
                        var closerowlayout = new RowLayout
                        var horizontalSeekBarRow = new RowLayout
                        {
                            Y = openrowlayout.Bottom,
                            Height = Application.GetRealHeight(180),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(160),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        OnOffOutputfra.AddChidren(closerowlayout);
                        openframelayout.AddChidren(horizontalSeekBarRow);
                        var horizontalSeekBarVol = new HorizontalSeekBar
                        {
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(80),
                            Radius = (uint)Application.GetRealHeight(25),
                            Y = Application.GetRealHeight(25),
                            //Gravity = Gravity.CenterVertical,
                            ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected,
                            Max = 100,
                            SleepTime = 1000,
                            ThumbRadius = 9,
                            IsCanMove = false
                        };
                        horizontalSeekBarRow.AddChidren(horizontalSeekBarVol);
                        #endregion
                        #region  关
                        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.LogicRowLayoutLineColor,
                        };
                        closeframelayout.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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,
                        };
                        var closeBtnSelected = new SelectedButton();
                        closerowlayout.AddChidren(closeBtnSelected);
                        var customrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                            Y = closerowlayout.Bottom,
                        };
                        OnOffOutputfra.AddChidren(customrowlayout);
                        var Btncustom = new Button
                        {
                            //Text = "自定义亮度",
                            TextID = MyInternationalizationString.custombrightness,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        };
                        customrowlayout.AddChidren(Btncustom);
                        #endregion
                        ///确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        #region   取反
                        var takebackframelayout = new FrameLayout
                        {
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            Height = Application.GetRealHeight(160),
                            Y = closeframelayout.Bottom,
                        };
                        devicefra.AddChidren(takebackframelayout);
                        var takebackrowlayout = new RowLayout
                        {
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                        };
                        takebackframelayout.AddChidren(takebackrowlayout);
                        var btntakeback = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.onoff,
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        takebackrowlayout.AddChidren(btntakeback);
                        var takebackBtnSelected = new SelectedButton();
                        takebackrowlayout.AddChidren(takebackBtnSelected);
                        #endregion
                        #endregion
                        int Progressvalue = 100;
                        horizontalSeekBarVol.ProgressChanged += (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            Progressvalue = horizontalSeekBarVol.Progress;
                            if (switchdictionary.ContainsKey("TaskType"))
                            {
                                switchdictionary.Remove("TaskType");
                            }
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "1");//默认值
                            LogicIfon.AddDeviceactions(common, actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                            switchdictionary.Add("TaskType", "3");
                            //最大亮度值是254需要转换;
                            var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;
                            switchdictionary.Add("Data1", lightbrightnessvalue.ToString());
                        };
                        ///确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            horizontalSeekBarVol.IsCanMove = true;
                            horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected;
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            takebackBtnSelected.Visible = false;
                            horizontalSeekBarVol.Progress = Progressvalue;
                            if (switchdictionary.ContainsKey("TaskType"))
                            {
                                switchdictionary.Remove("TaskType");
                            }
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("TaskType", "3");
                            //最大亮度值是254需要转换;
                            var lightbrightnessvalue = (254 * horizontalSeekBarVol.Progress) / 100;
                            switchdictionary.Add("Data1", lightbrightnessvalue.ToString());
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        openframelayout.MouseUpEventHandler += openclick;
                        ///取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            horizontalSeekBarVol.IsCanMove = false;
                            horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            takebackBtnSelected.Visible = false;
                            if (switchdictionary.ContainsKey("TaskType"))
                            {
                                switchdictionary.Remove("TaskType");
                            }
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("TaskType", "1");
                            switchdictionary.Add("Data1", "0");//默认值
                            LogicIfon.AddDeviceactions(common, actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        ///自定义亮度事件
                        EventHandler<MouseEventArgs> customclick = (sender, e) =>
                        closeframelayout.MouseUpEventHandler += closeclick;
                        //取反
                        EventHandler<MouseEventArgs> takebackclick = (sender, e) =>
                        {
                            var setDeviceState = new SetDeviceState();
                            UserView.HomePage.Instance.AddChidren(setDeviceState);
                            UserView.HomePage.Instance.PageIndex += 1;
                            setDeviceState.Show(common, Btncustom.Text, edit);
                            SelectedDeviceStatusaction = "yes";
                            horizontalSeekBarVol.IsCanMove = false;
                            horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = false;
                            takebackBtnSelected.Visible = true;
                            if (switchdictionary.ContainsKey("TaskType"))
                            {
                                switchdictionary.Remove("TaskType");
                            }
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("TaskType", "1");
                            switchdictionary.Add("Data1", "2");//默认值
                        };
                        customrowlayout.MouseUpEventHandler += customclick;
                        Btncustom.MouseUpEventHandler += customclick;
                        takebackrowlayout.MouseUpEventHandler += takebackclick;
                        btntakeback.MouseUpEventHandler += takebackclick;
                        takebackBtnSelected.MouseUpEventHandler += takebackclick;
                        takebackframelayout.MouseUpEventHandler += takebackclick;
                        if (edit && TaskList != null)
                        {
                            foreach (var value in TaskList)
                            {
                                if (switchdictionary.ContainsKey("Data1"))
                                {
                                    switchdictionary.Remove("Data1");
                                }
                                if (switchdictionary.ContainsKey("TaskType"))
                                {
                                    switchdictionary.Remove("TaskType");
                                }
                                if (value["TaskType"] == "1")
                                {
                                    if (switchdictionary.ContainsKey("Data1"))
                                    {
                                        switchdictionary.Remove("Data1");
                                    }
                                    if (value["Data1"] == "1")
                                    {
                                        switchdictionary.Add("Data1", "1");
                                        openBtnSelected.Visible = true;
                                        closeBtnSelected.Visible = false;
                                    }
                                    else
                                    switchdictionary.Add("TaskType", "1");
                                    if (value["Data1"] == "0")
                                    {
                                        switchdictionary.Add("Data1", "0");
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = true;
                                        takebackBtnSelected.Visible = false;
                                        horizontalSeekBarVol.IsCanMove = false;
                                        horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                                    }
                                    break;
                                    else if (value["Data1"] == "2")
                                    {
                                        switchdictionary.Add("Data1", "2");
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = false;
                                        takebackBtnSelected.Visible = true;
                                        horizontalSeekBarVol.IsCanMove = false;
                                        horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                                    }
                                }
                                else if (value["TaskType"] == "3")
                                {
                                    switchdictionary.Add("TaskType", "3");
                                    switchdictionary.Add("Data1", value["Data1"]);
                                    openBtnSelected.Visible = true;
                                    closeBtnSelected.Visible = false;
                                    takebackBtnSelected.Visible = false;
                                    horizontalSeekBarVol.IsCanMove = true;
                                    horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected;
                                    horizontalSeekBarVol.Progress = int.Parse(value["Data1"])*100/254;
                                    Progressvalue = horizontalSeekBarVol.Progress;
                                }
                                break;
                            }
                        }
@@ -824,198 +1245,201 @@
                        {
                            switchdictionary.Remove("TaskType");
                        }
                        if (switchdictionary.ContainsKey("Data1"))
                        {
                            switchdictionary.Remove("Data1");
                        }
                        if (switchdictionary.ContainsKey("Data2"))
                        {
                            switchdictionary.Remove("Data2");
                        }
                        switchdictionary.Add("TaskType", "6");
                        switchdictionary.Add("Data1", "1");
                        switchdictionary.Add("Data2", "0");
                        taskListInfo.Add(switchdictionary);
                        //Dictionary<string, string> brightnessdictionary = new Dictionary<string, string>();
                        //if (brightnessdictionary.ContainsKey("TaskType"))
                        //{
                        //    brightnessdictionary.Remove("TaskType");
                        //}
                        //if (brightnessdictionary.ContainsKey("Data2"))
                        //{
                        //    brightnessdictionary.Remove("Data2");
                        //}
                        //if (brightnessdictionary.ContainsKey("Data1"))
                        //{
                        //    brightnessdictionary.Remove("Data1");
                        //}
                        //brightnessdictionary.Add("TaskType", "6");
                        //brightnessdictionary.Add("Data1", "5");
                        //brightnessdictionary.Add("Data2", "0");
                        //taskListInfo.Add(brightnessdictionary);
                        #endregion
                        #endregion
                        devicefra.Y = Application.GetRealHeight(1920 - 160 * 2 - 210 - 160);
                        devicefra.Height = Application.GetRealHeight(160 * 2 + 210 + 160);
                        #region 窗帘View
                        devicefra.Y = Application.GetRealHeight(1920 - 30 - 900);
                        devicefra.Height = Application.GetRealHeight(900);
                        var windowCoveringfra = new FrameLayout
                        #region 开
                        var openframelayout = new FrameLayout
                        {
                            Y = Application.GetRealHeight(180),
                            Height = Application.GetRealHeight(180 * 3 + 30),
                            Height = Application.GetRealHeight(160 + 160),
                            Y = timetype.Bottom + Application.GetRealHeight(20),
                        };
                        devicefra.AddChidren(windowCoveringfra);
                        devicefra.AddChidren(openframelayout);
                        var openrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                            Y = Application.GetRealHeight(30),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(130),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
                        };
                        windowCoveringfra.AddChidren(openrowlayout);
                        openframelayout.AddChidren(openrowlayout);
                        var btnopen = new Button
                        {
                            //Text = "开",
                            Width = Application.GetRealWidth(600),
                            TextID = MyInternationalizationString.open,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(300),
                            Height = Application.GetRealHeight(180),
                            //SelectedBackgroundColor = 0xfffe5e00,
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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
                        };
                        var openBtnSelected = new SelectedButton();
                        openrowlayout.AddChidren(openBtnSelected);
                        var closerowlayout = new RowLayout
                        var horizontalSeekBarRow = new RowLayout
                        {
                            Y = openrowlayout.Bottom,
                            Height = Application.GetRealHeight(180),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(160),
                            X = Application.GetRealWidth(80),
                            LineColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        windowCoveringfra.AddChidren(closerowlayout);
                        openframelayout.AddChidren(horizontalSeekBarRow);
                        var horizontalSeekBarVol = new HorizontalSeekBar
                        {
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(80),
                            Radius = (uint)Application.GetRealHeight(25),
                            Y = Application.GetRealHeight(25),
                            //Gravity = Gravity.CenterVertical,
                            ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected,
                            Max = 100,
                            SleepTime = 1000,
                            ThumbRadius = 9,
                            IsCanMove = false
                        };
                        horizontalSeekBarRow.AddChidren(horizontalSeekBarVol);
                        #endregion
                        #region  关
                        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.LogicBlankBackgroundColor,
                        };
                        closeframelayout.AddChidren(closerowlayout);
                        var btnclose = new Button
                        {
                            //Text = "关",
                            TextID = MyInternationalizationString.close,
                            Width = Application.GetRealWidth(600),
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(300),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                            TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                        };
                        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
                        };
                        var closeBtnSelected = new SelectedButton();
                        closerowlayout.AddChidren(closeBtnSelected);
                        var customrowlayout = new RowLayout
                        {
                            Height = Application.GetRealHeight(180),
                            Y = closerowlayout.Bottom,
                        };
                        windowCoveringfra.AddChidren(customrowlayout);
                        var Btncustom = new Button
                        {
                            //Text = "自定义百分比",
                            TextID = MyInternationalizationString.custompercentage,
                            TextAlignment = TextAlignment.CenterLeft,
                            X = Application.GetRealWidth(40),
                            Width = Application.GetRealWidth(600),
                            Height = Application.GetRealHeight(180),
                            TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                        };
                        customrowlayout.AddChidren(Btncustom);
                        #endregion
                        ///点击确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                        #endregion
                        int Progressvalue = 100;
                        horizontalSeekBarVol.ProgressChanged += (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            Progressvalue = horizontalSeekBarVol.Progress;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "0");
                            if (switchdictionary.ContainsKey("Data2"))
                            {
                                switchdictionary.Remove("Data2");
                            }
                            switchdictionary.Add("Data1", "5");
                            switchdictionary.Add("Data2", horizontalSeekBarVol.Progress.ToString());
                            LogicIfon.AddDeviceactions(common, actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                        };
                        ///确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            horizontalSeekBarVol.IsCanMove = true;
                            horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected;
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            horizontalSeekBarVol.Progress = Progressvalue;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            if (switchdictionary.ContainsKey("Data2"))
                            {
                                switchdictionary.Remove("Data2");
                            }
                            switchdictionary.Add("Data1", "5");
                            switchdictionary.Add("Data2", horizontalSeekBarVol.Progress.ToString());
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        ///点击取消事件
                        openframelayout.MouseUpEventHandler += openclick;
                        ///取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            SelectedDeviceStatusaction = "yes";
                            horizontalSeekBarVol.IsCanMove = false;
                            horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            switchdictionary.Add("Data1", "1");
                            if (switchdictionary.ContainsKey("Data2"))
                            {
                                switchdictionary.Remove("Data2");
                            }
                            switchdictionary.Add("Data2", "0");
                            switchdictionary.Add("Data1", "1");//默认值
                            LogicIfon.AddDeviceactions(common, actionsInfo);
                            var logicCommunalPage = new LogicCommunalPage();
                            UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                            UserView.HomePage.Instance.PageIndex += 1;
                            logicCommunalPage.Show(() => { });
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        ///自定义亮度事件
                        EventHandler<MouseEventArgs> customclick = (sender, e) =>
                        {
                            var setDeviceState = new SetDeviceState();
                            UserView.HomePage.Instance.AddChidren(setDeviceState);
                            UserView.HomePage.Instance.PageIndex += 1;
                            setDeviceState.Show(common, Btncustom.Text, edit);
                        closeframelayout.MouseUpEventHandler += closeclick;
                        };
                        customrowlayout.MouseUpEventHandler += customclick;
                        Btncustom.MouseUpEventHandler += customclick;
                        if (edit && TaskList != null)
                        {
                            foreach (var value in TaskList)
                            {
                                if (value["TaskType"] == "6")
                                {
                                    if (value["Data1"] == "0")
                                    if (value["Data1"] == "5")
                                    {
                                        if (switchdictionary.ContainsKey("Data1"))
                                        {
                                            switchdictionary.Remove("Data1");
                                        }
                                        switchdictionary.Add("Data1", "0");
                                        if (switchdictionary.ContainsKey("Data2"))
                                        {
                                            switchdictionary.Remove("Data2");
                                        }
                                        switchdictionary.Add("Data1", "5");
                                        switchdictionary.Add("Data2", value["Data2"]);
                                        horizontalSeekBarVol.IsCanMove = true;
                                        horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColorSelected;
                                        openBtnSelected.Visible = true;
                                        closeBtnSelected.Visible = false;
                                        horizontalSeekBarVol.Progress = int.Parse(value["Data2"]);
                                        Progressvalue = horizontalSeekBarVol.Progress;
                                    }
                                    else if (value["Data1"] == "1")
                                    {
@@ -1026,6 +1450,8 @@
                                        switchdictionary.Add("Data1", "1");
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = true;
                                        horizontalSeekBarVol.IsCanMove = false;
                                        horizontalSeekBarVol.ProgressColor = ZigbeeColor.Current.LogicProgressColor;
                                    }
                                }
@@ -1034,28 +1460,645 @@
                        }
                    }
                    break;
                ///空气开关
                case DeviceType.AirSwitch: {
                        {
                            #region  ----初始化设备功能数据----
                            Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
                            if (switchdictionary.ContainsKey("TaskType"))
                            {
                                switchdictionary.Remove("TaskType");
                            }
                            if (switchdictionary.ContainsKey("Data1"))
                            {
                                switchdictionary.Remove("Data1");
                            }
                            if (switchdictionary.ContainsKey("Data2"))
                            {
                                switchdictionary.Remove("Data2");
                            }
                            switchdictionary.Add("TaskType", "1");
                            switchdictionary.Add("Data1", "0");
                            switchdictionary.Add("Data2", "0");
                            taskListInfo.Add(switchdictionary);
                            #endregion
                            #region  空气灯光View
                            #region 开
                            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);
                            #endregion
                            #region  关
                            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.LogicRowLayoutLineColor,
                            };
                            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
                            #region   取反
                            var takebackframelayout = new FrameLayout
                            {
                                Height = Application.GetRealHeight(160),
                                Y = closeframelayout.Bottom,
                            };
                            devicefra.AddChidren(takebackframelayout);
                            var takebackrowlayout = new RowLayout
                            {
                                Y = Application.GetRealHeight(30),
                                Width = Application.GetRealWidth(920),
                                Height = Application.GetRealHeight(130),
                                X = Application.GetRealWidth(80),
                                LineColor = ZigbeeColor.Current.LogicBackgroundColor,
                            };
                            takebackframelayout.AddChidren(takebackrowlayout);
                            var btntakeback = new Button
                            {
                                //Text = "关",
                                TextID = MyInternationalizationString.onoff,
                                Width = Application.GetRealWidth(600),
                                TextAlignment = TextAlignment.CenterLeft,
                                TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor,
                            };
                            takebackrowlayout.AddChidren(btntakeback);
                            var takebackBtnSelected = new SelectedButton();
                            takebackrowlayout.AddChidren(takebackBtnSelected);
                            #endregion
                            #endregion
                            ///确认事件
                            EventHandler<MouseEventArgs> openclick = (sender, e) =>
                            {
                                SelectedDeviceStatusaction = "yes";
                                openBtnSelected.Visible = true;
                                closeBtnSelected.Visible = false;
                                takebackBtnSelected.Visible = false;
                                if (switchdictionary.ContainsKey("Data1"))
                                {
                                    switchdictionary.Remove("Data1");
                                }
                                switchdictionary.Add("Data1", "1");//默认值
                            };
                            openrowlayout.MouseUpEventHandler += openclick;
                            btnopen.MouseUpEventHandler += openclick;
                            openBtnSelected.MouseUpEventHandler += openclick;
                            openframelayout.MouseUpEventHandler += openclick;
                            ///取消事件
                            EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                            {
                                SelectedDeviceStatusaction = "yes";
                                openBtnSelected.Visible = false;
                                closeBtnSelected.Visible = true;
                                takebackBtnSelected.Visible = false;
                                if (switchdictionary.ContainsKey("Data1"))
                                {
                                    switchdictionary.Remove("Data1");
                                }
                                switchdictionary.Add("Data1", "0");//默认值
                            };
                            closerowlayout.MouseUpEventHandler += closeclick;
                            btnclose.MouseUpEventHandler += closeclick;
                            closeBtnSelected.MouseUpEventHandler += closeclick;
                            closeframelayout.MouseUpEventHandler += closeclick;
                            //取反
                            EventHandler<MouseEventArgs> takebackclick = (sender, e) =>
                            {
                                SelectedDeviceStatusaction = "yes";
                                openBtnSelected.Visible = false;
                                closeBtnSelected.Visible = false;
                                takebackBtnSelected.Visible = true;
                                if (switchdictionary.ContainsKey("Data1"))
                                {
                                    switchdictionary.Remove("Data1");
                                }
                                switchdictionary.Add("Data1", "2");//默认值
                            };
                            takebackrowlayout.MouseUpEventHandler += takebackclick;
                            btntakeback.MouseUpEventHandler += takebackclick;
                            takebackBtnSelected.MouseUpEventHandler += takebackclick;
                            takebackframelayout.MouseUpEventHandler += takebackclick;
                            if (edit && TaskList != null)
                            {
                                foreach (var value in TaskList)
                                {
                                    if (value["TaskType"] == "1")
                                    {
                                        if (switchdictionary.ContainsKey("Data1"))
                                        {
                                            switchdictionary.Remove("Data1");
                                        }
                                        if (value["Data1"] == "1")
                                        {
                                            switchdictionary.Add("Data1", "1");
                                            openBtnSelected.Visible = true;
                                            closeBtnSelected.Visible = false;
                                            takebackBtnSelected.Visible = false;
                                        }
                                        else if (value["Data1"] == "0")
                                        {
                                            switchdictionary.Add("Data1", "0");
                                            openBtnSelected.Visible = false;
                                            closeBtnSelected.Visible = true;
                                            takebackBtnSelected.Visible = false;
                                        }
                                        else if (value["Data1"] == "2")
                                        {
                                            switchdictionary.Add("Data1", "2");
                                            openBtnSelected.Visible = false;
                                            closeBtnSelected.Visible = false;
                                            takebackBtnSelected.Visible = true;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    break;
                case DeviceType.Thermostat:
                    {
                        #region  ----初始化设备功能数据----
                        Dictionary<string, string> switchdictionary = new Dictionary<string, string>();
                        Dictionary<string, string> temperaturedictionary = new Dictionary<string, string>();
                        Dictionary<string, string> modedictionary = new Dictionary<string, string>();
                        Dictionary<string, string> speeddictionary = new Dictionary<string, string>();
                        taskListInfo.Add(switchdictionary);
                        taskListInfo.Add(temperaturedictionary);
                        taskListInfo.Add(modedictionary);
                        taskListInfo.Add(speeddictionary);
                        dictionary(switchdictionary, "TaskType", "1");
                        dictionary(switchdictionary, "Data2", "0");
                        dictionary(temperaturedictionary, "TaskType", "5");
                        dictionary(modedictionary, "TaskType", "5");
                        dictionary(modedictionary, "Data1", "3");
                        dictionary(speeddictionary, "TaskType", "5");
                        dictionary(speeddictionary, "Data1", "6");
                        #endregion
                        #region  空调View
                        devicefra.Y = Application.GetRealHeight(1920 - 600 - 210 - 160*2);
                        devicefra.Height = Application.GetRealHeight(600+ 210 + 160*2);
                        #region 开
                        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);
                        #endregion
                        #region  空调状态View
                        var PickerViewfra = new FrameLayout
                        {
                            Y = openframelayout.Bottom,
                            Height = Application.GetRealHeight(600),
                        };
                        devicefra.AddChidren(PickerViewfra);
                        var pausePickerViewfra= new FrameLayout
                        {
                            Y = openframelayout.Bottom,
                            Height = Application.GetRealHeight(600),
                        };
                        devicefra.AddChidren(pausePickerViewfra);
                        var mUIPickerView = new UIPickerView
                        {
                            Height = Application.GetRealHeight(600-5),
                        };
                        PickerViewfra.AddChidren(mUIPickerView);
                        var line = new Button
                        {
                            Y = Application.GetRealHeight(600-5),
                            Width = Application.GetRealWidth(920),
                            Height = Application.GetRealHeight(5),
                            X = Application.GetRealWidth(80),
                            BackgroundColor = ZigbeeColor.Current.LogicRowLayoutLineColor,
                        };
                        PickerViewfra.AddChidren(line);
                        var mList1 = new List<string>();
                        var mList2 = new List<string> {
                         Language.StringByID(MyInternationalizationString.logiccool),
                         Language.StringByID(MyInternationalizationString.logicheat),
                         Language.StringByID(MyInternationalizationString.logicauto),
                         Language.StringByID(MyInternationalizationString.logicdry),
                         Language.StringByID(MyInternationalizationString.logicfanonly),
                        };
                        var mList3 = new List<string>{
                         Language.StringByID(MyInternationalizationString.logiclow),
                         Language.StringByID(MyInternationalizationString.logicmedium),
                         Language.StringByID(MyInternationalizationString.logichigh),
                          };
                        for (int i = 16; i < 33; i++)
                        {
                            mList1.Add(i.ToString() +" " + "℃");
                        }
                        mUIPickerView.setNPicker(mList1, mList2, mList3);
                        ///默认状态
                        #endregion
                        #region  关
                        var closeframelayout = new FrameLayout
                        {
                            Height = Application.GetRealHeight(160),
                            Y = PickerViewfra.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
                        mUIPickerView.OnSelectChangeEvent += (s1, s2, s3) =>
                        {
                            if (openBtnSelected.Visible)
                            {
                                SelectedDeviceStatusaction = "yes";
                                var temperature = mList1[s1].Split(' ')[0];
                                var modestring = mList2[s2].Split(' ')[0];
                                var speedstring = mList3[s3].Split(' ')[0];
                                ModeState(modestring, temperaturedictionary, modedictionary);
                                var a = int.Parse(temperature) * 100;
                                dictionary(temperaturedictionary, "Data2", a.ToString());
                                SpeedState(speedstring, speeddictionary);
                            }
                        };
                        #endregion
                        //默认26,自动,中风
                        int indextemperature = 10, indexmode = 2, indexspeed = 1;
                        if (edit && TaskList != null)
                        {
                            foreach (var value in TaskList)
                            {
                                if (value["TaskType"] == "1")
                                {
                                    dictionary(switchdictionary, "Data1", value["Data1"]);
                                    if (value["Data1"] == "1")
                                    {
                                        openBtnSelected.Visible = true;
                                        closeBtnSelected.Visible = false;
                                        pausePickerViewfra.Height = Application.GetRealHeight(0);
                                    }
                                    else if (value["Data1"] == "0")
                                    {
                                        openBtnSelected.Visible = false;
                                        closeBtnSelected.Visible = true;
                                        pausePickerViewfra.Height = Application.GetRealHeight(600);
                                    }
                                }
                                else if (value["TaskType"] == "5")
                                {
                                    if (value["Data1"] == "3")
                                    {//3---设置工作模式(1:自动;3:制冷;4:制热;7:送风;8:除湿)
                                        dictionary(modedictionary, "Data2", value["Data2"]);
                                        string modetext = "";
                                        switch (value["Data2"])
                                        {
                                            case "3":
                                                {
                                                    modetext = Language.StringByID(MyInternationalizationString.logiccool);
                                                    //indexmode = 0;
                                                }
                                                break;
                                            case "4":
                                                {
                                                    modetext = Language.StringByID(MyInternationalizationString.logicheat);
                                                    //  indexmode = 1;
                                                }
                                                break;
                                            case "1":
                                                {
                                                    modetext = Language.StringByID(MyInternationalizationString.logicauto);
                                                    //   indexmode = 2;
                                                }
                                                break;
                                            case "8":
                                                {
                                                    modetext = Language.StringByID(MyInternationalizationString.logicdry);
                                                    //  indexmode = 3;
                                                }
                                                break;
                                            case "7":
                                                {
                                                    modetext = Language.StringByID(MyInternationalizationString.logicfanonly);
                                                    //indexmode = 4;
                                                }
                                                break;
                                        }
                                        indexmode = mList2.IndexOf(modetext);
                                    }
                                    else if (value["Data1"] == "6")
                                    {//6---设置风扇模式(1:低风;2:中风;3:高风;)
                                        dictionary(speeddictionary, "Data2", value["Data2"]);
                                        string speedtext = "";
                                        switch (value["Data2"])
                                        {
                                            case "1":
                                                {
                                                    speedtext = Language.StringByID(MyInternationalizationString.logiclow);
                                                    //indexspeed = 0;
                                                }
                                                break;
                                            case "2":
                                                {
                                                    speedtext = Language.StringByID(MyInternationalizationString.logicmedium);
                                                    // indexspeed = 1;
                                                }
                                                break;
                                            case "3":
                                                {
                                                    speedtext = Language.StringByID(MyInternationalizationString.logichigh);
                                                    // indexspeed = 2;
                                                }
                                                break;
                                        }
                                        indexspeed = mList3.IndexOf(speedtext);
                                    }
                                    //4---设置加热度数;5---设置制冷、除湿度数;7---设置自动度数
                                    else if (value["Data1"] == "4" || value["Data1"] == "5" || value["Data1"] == "7")
                                    {
                                        var s = int.Parse(value["Data2"]) / 100;
                                        indextemperature = mList1.IndexOf(s.ToString() + " " + "℃");
                                        dictionary(temperaturedictionary, "Data1", value["Data1"]);
                                        dictionary(temperaturedictionary, "Data2", value["Data2"]);
                                    }
                                }
                            }
                        }
                        ///更新最新空调状态;
                        mUIPickerView.setCurrentItems(indextemperature, indexmode, indexspeed);
                        ///确认事件
                        EventHandler<MouseEventArgs> openclick = (sender, e) =>
                        {
                            pausePickerViewfra.Height = Application.GetRealHeight(0);
                            SelectedDeviceStatusaction = "yes";
                            openBtnSelected.Visible = true;
                            closeBtnSelected.Visible = false;
                            dictionary(switchdictionary, "Data1", "1");
                            var temperature = mList1[indextemperature].Split(' ')[0];
                            var modestring = mList2[indexmode].Split(' ')[0];
                            var speedstring = mList3[indexspeed].Split(' ')[0];
                            ModeState(modestring, temperaturedictionary, modedictionary);
                            var a = int.Parse(temperature) * 100;
                            dictionary(temperaturedictionary, "Data2", a.ToString());
                            SpeedState(speedstring, speeddictionary);
                        };
                        openrowlayout.MouseUpEventHandler += openclick;
                        btnopen.MouseUpEventHandler += openclick;
                        openBtnSelected.MouseUpEventHandler += openclick;
                        openframelayout.MouseUpEventHandler += openclick;
                        ///取消事件
                        EventHandler<MouseEventArgs> closeclick = (sender, e) =>
                        {
                            pausePickerViewfra.Height = Application.GetRealHeight(600);
                            SelectedDeviceStatusaction = "yes";
                            openBtnSelected.Visible = false;
                            closeBtnSelected.Visible = true;
                            dictionary(switchdictionary, "Data1", "0");
                        };
                        closerowlayout.MouseUpEventHandler += closeclick;
                        btnclose.MouseUpEventHandler += closeclick;
                        closeBtnSelected.MouseUpEventHandler += closeclick;
                        closeframelayout.MouseUpEventHandler += closeclick;
                    }
                    break;
            }
            var cancel = new Button
            Btncomplete.MouseUpEventHandler += (sender, e) =>
            {
                Height = Application.GetRealHeight(160),
                TextID = MyInternationalizationString.cancel,
                TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                TextSize = 16,
                BackgroundColor = ZigbeeColor.Current.LogicTopViewBackgroundColor,
                Y = devicefra.Height - Application.GetRealHeight(160),
            };
            devicefra.AddChidren(cancel);
            cancel.MouseUpEventHandler += (sender, e) =>
            {
                if (SelectedDeviceStatusaction == "yes")
                {
                    LogicIfon.AddDeviceactions(common, actionsInfo);
                }
                else
                {
                    if (!edit)
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                               Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                                               Language.StringByID(MyInternationalizationString.complete));
                        alert.Show();
                        return;
                    }
                }
                flMain.RemoveFromParent();
                UserView.HomePage.Instance.ScrollEnabled = true;
                var logicCommunalPage = new LogicCommunalPage();
                UserView.HomePage.Instance.AddChidren(logicCommunalPage);
                UserView.HomePage.Instance.PageIndex += 1;
                logicCommunalPage.Show(() => { });
            };
        }
        public  static void dictionary(Dictionary<string, string> deviceactionsInfo, string Key, string Value)
        {
            if (deviceactionsInfo.ContainsKey(Key))
            {
                deviceactionsInfo.Remove(Key);
            }
            deviceactionsInfo.Add(Key, Value);
        }
        /// <summary>
        /// 空调模式的状态
        /// </summary>
        /// <param name="modestring"></param>
        /// <param name="temperaturedictionary"></param>
        /// <param name="modedictionary"></param>
        public static void ModeState(string modestring,Dictionary<string,string> temperaturedictionary, Dictionary<string, string> modedictionary)
        {
            if (modestring == Language.StringByID(MyInternationalizationString.logiccool))
            {
                dictionary(modedictionary, "Data2", "3");
                dictionary(temperaturedictionary, "Data1", "5");
            }
            else if (modestring == Language.StringByID(MyInternationalizationString.logicheat))
            {
                dictionary(modedictionary, "Data2", "4");
                dictionary(temperaturedictionary, "Data1", "4");
            }
            else if (modestring == Language.StringByID(MyInternationalizationString.logicauto))
            {
                dictionary(modedictionary, "Data2", "1");
                dictionary(temperaturedictionary, "Data1", "7");
            }
            else if (modestring == Language.StringByID(MyInternationalizationString.logicdry))
            {
                dictionary(modedictionary, "Data2", "8");
                dictionary(temperaturedictionary, "Data1", "5");
            }
            else if (modestring == Language.StringByID(MyInternationalizationString.logicfanonly))
            {
                dictionary(temperaturedictionary, "Data1", "20");
                dictionary(modedictionary, "Data2", "7");
            }
        }
        /// <summary>
        /// 风速的模式
        /// </summary>
        /// <param name="speedstring"></param>
        /// <param name="speeddictionary"></param>
        public static void SpeedState(string speedstring, Dictionary<string, string> speeddictionary) {
            if (speedstring == Language.StringByID(MyInternationalizationString.logiclow))
            {
                dictionary(speeddictionary, "Data2", "1");
            }
            else if (speedstring == Language.StringByID(MyInternationalizationString.logicmedium))
            {
                dictionary(speeddictionary, "Data2", "2");
            }
            else if (speedstring == Language.StringByID(MyInternationalizationString.logichigh))
            {
                dictionary(speeddictionary, "Data2", "3");
            }
        }
    }
}