黄学彪
2020-03-06 a5b3c4bae726ef6770d4bfcbf2f4b50a37ed4a15
ZigbeeApp/Shared/Phone/Device/Logic/TemplateDeviceAction.cs
@@ -18,7 +18,6 @@
        Button roomTextButton = new Button();
        Button devicetypeButton = new Button();
        VerticalScrolViewLayout middle;
        HorizontalScrolViewLayout devicetypehorizontalScrol1;
        FrameLayout clickframeLayout = new FrameLayout();
        Button clickbutton = new Button();
        Button clicktextcolcrbutton = new Button();
@@ -47,6 +46,7 @@
                Height = Application.GetRealHeight(69),
                Y = Application.GetRealHeight(92),
                TextID = MyInternationalizationString.devicestate,
                IsBold = true,
            };
            topRowLayout.AddChidren(titleName);
@@ -107,7 +107,8 @@
            ///没有房间直接返回去;
            if (Common.Room.Lists.Count == 0)
            var listAllRoom = UserCenter.HdlRoomLogic.Current.GetAllListRooms();
            if (listAllRoom.Count == 0)
            {
                return;
            }
@@ -122,15 +123,6 @@
            this.AddChidren(roomhorizontalScrol);
             devicetypehorizontalScrol1 = new HorizontalScrolViewLayout()
            {
                Width = Application.GetRealWidth(1080 - 58 - 200),
                Height = Application.GetRealHeight(280),
                Y = roomhorizontalScrol.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                X = Application.GetRealWidth(58 + 200),
            };
            this.AddChidren(devicetypehorizontalScrol1);
            ///设备类型滑动控件
            var devicetypehorizontalScrol = new HorizontalScrolViewLayout()
            {
@@ -139,18 +131,20 @@
                Y = roomhorizontalScrol.Bottom,
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                X = Application.GetRealWidth(58),
                Radius = (uint)Application.GetRealHeight(50),
                //Radius = (uint)Application.GetRealHeight(50),
            };
            this.AddChidren(devicetypehorizontalScrol);
            devicetypehorizontalScrol.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft);
            middle = new VerticalScrolViewLayout();
            middle.Y = devicetypehorizontalScrol.Bottom + Application.GetRealHeight(40);
            middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
            middle.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
            middle.X = Application.GetRealWidth(58);
            middle.Radius = (uint)Application.GetRealHeight(50);
            //middle.Radius = (uint)Application.GetRealHeight(50);
            this.AddChidren(middle);
            middle.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
            ///目前支持的设备
            List<DeviceType> deviceTypeList = new List<DeviceType> {
@@ -272,7 +266,7 @@
                dropdown.Visible = false;
                if (Config.Instance.Home.FloorDics.Count == 0)
                {
                    roomlists.AddRange(Common.Room.Lists);
                    roomlists.AddRange(listAllRoom);
                }
                else
                {
@@ -332,15 +326,16 @@
                    roomTextButton.IsSelected = false;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    roomnameBtn.IsSelected = true;
                    var list = new List<CommonDevice>();
                    foreach (var deviceKeys in room.ListDevice)
                    {
                        if (device.CommonDevice == null)
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
                        if (!deviceTypeList.Contains(device.Type))
                        {
                            continue;
                        }
@@ -349,13 +344,13 @@
                    if (list.Count == 0)
                    {
                        devicetypehorizontalScrol.Height = 0;
                        devicetypehorizontalScrol1.Height = 0;
                        middle.Height = 0;
                    }
                    else
                    {
                        devicetypehorizontalScrol.Height = Application.GetRealHeight(280);
                        devicetypehorizontalScrol1.Height = Application.GetRealHeight(280);
                        middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
@@ -371,15 +366,16 @@
                    roomTextButton.IsSelected = false;
                    roomTextButton = roomnameBtn;
                    roomnameBtn.IsSelected = true;
                    var list = new List<DeviceUI>();
                    foreach (var device in room.DeviceUIList)
                    roomnameBtn.IsSelected = true;
                    var list = new List<CommonDevice>();
                    foreach (var deviceKeys in room.ListDevice)
                    {
                        if (device.CommonDevice == null)
                        var device = LocalDevice.Current.GetDevice(deviceKeys);
                        if (device == null)
                        {
                            continue;
                        }
                        if (!deviceTypeList.Contains(device.CommonDevice.Type))
                        if (!deviceTypeList.Contains(device.Type))
                        {
                            continue;
                        }
@@ -388,13 +384,13 @@
                    if (list.Count == 0)
                    {
                        devicetypehorizontalScrol.Height = 0;
                        devicetypehorizontalScrol1.Height = 0;
                        middle.Height = 0;
                    }
                    else
                    {
                        devicetypehorizontalScrol.Height = Application.GetRealHeight(280);
                        devicetypehorizontalScrol1.Height = Application.GetRealHeight(280);
                        middle.Height = Application.GetRealHeight(1920 - 40) - devicetypehorizontalScrol.Bottom;
                    }
                    AllDeviceTypeView(list, devicetypehorizontalScrol);
@@ -410,29 +406,29 @@
        /// <summary>
        ///加载该区域所有设备的视图方法
        /// </summary>
        void AllDeviceTypeView(List<DeviceUI> devicelist, HorizontalScrolViewLayout devicetypehorizontalScrol)
        void AllDeviceTypeView(List<CommonDevice> 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);
            var lightjosn = devicelist.Find((device) => device.Type == DeviceType.DimmableLight || device.Type == DeviceType.OnOffOutput);
            if (lightjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Lights));
            }
            var curtainjosn = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.WindowCoveringDevice);
            var curtainjosn = devicelist.Find((device) => device.Type == DeviceType.WindowCoveringDevice);
            if (curtainjosn != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Curtains));
            }
            var ac = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.Thermostat);
            var ac = devicelist.Find((device) => device.Type == DeviceType.Thermostat);
            if (ac != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.AC));
            }
            var airSwitch = devicelist.Find((device) => device.CommonDevice.Type == DeviceType.AirSwitch);
            var airSwitch = devicelist.Find((device) => device.Type == DeviceType.AirSwitch);
            if (airSwitch != null)
            {
                devicetypelist.Add(Language.StringByID(MyInternationalizationString.Airswitch));
@@ -555,13 +551,13 @@
        /// 加载该类型设备视图方法
        /// </summary>
        /// <param name="devicelist">设备列表</param>
        void ActionDeviceView(List<DeviceType> deviceTypelist, List<DeviceUI> devicelist)
        void ActionDeviceView(List<DeviceType> deviceTypelist, List<CommonDevice> devicelist)
        {
            middle.RemoveAll();
            foreach (var common in devicelist)
            {
                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.CommonDevice.Type))
                if (deviceTypelist.Count != 0 && !deviceTypelist.Contains(common.Type))
                {
                    continue;
                }
@@ -605,14 +601,14 @@
                var devicename = new Button
                {
                    Text = common.CommonDevice.DeviceEpointName,
                    Text = common.DeviceEpointName,
                    TextAlignment = TextAlignment.CenterLeft,
                    TextColor = ZigbeeColor.Current.LogicTextBlackColor,
                    SelectedTextColor = ZigbeeColor.Current.LogicAddColor,
                    TextSize = 14,
                };
                deviceRow.AddChidren(devicename);
                switch (common.CommonDevice.Type)
                switch (common.Type)
                {
                    case DeviceType.OnOffOutput:
@@ -662,7 +658,7 @@
                    var flMain = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor };
                    this.AddChidren(flMain);
                    CurrentDeviceStateView(flMain, common.CommonDevice, false);
                    CurrentDeviceStateView(flMain, common, false);
                };
                deviceFramelayout.MouseUpEventHandler += devicclick;
                bjFramelayout.MouseUpEventHandler += devicclick;
@@ -688,14 +684,6 @@
            {
                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
            {
@@ -704,9 +692,10 @@
                Height = Application.GetRealHeight(530 + 160),
                Y = Application.GetRealHeight(1920 - 530 - 160),
                BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor,
                Radius = (uint)Application.GetRealHeight(60),
               // Radius = (uint)Application.GetRealHeight(60),
            };
            flMain.AddChidren(devicefra);
            devicefra.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft|HDLUtils.RectCornerTopRight);
            #region  -------取消   完成
            var timetype = new RowLayout
@@ -2084,9 +2073,9 @@
                {
                    if (!edit)
                    {
                        var alert = new Alert(Language.StringByID(MyInternationalizationString.Prompt),
                                               Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                                               Language.StringByID(MyInternationalizationString.complete));
                        var alert = new UserCenter.ShowMsgControl(UserCenter.ShowMsgType.Normal,
                        Language.StringByID(MyInternationalizationString.selectdevicestatuscondition),
                        Language.StringByID(MyInternationalizationString.confrim));
                        alert.Show();
                        return;
                    }