gxc
2019-12-25 944b87b6bcccb095cd73f13f4410fb20faf48f74
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs
@@ -1,10 +1,11 @@
using System;
using Shared.Common;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DeviceRelay
namespace Shared.Phone.UserCenter.Device
{
    /// <summary>
    /// 设备干接点配置
@@ -30,9 +31,9 @@
        /// </summary>
        private FrameCaptionInputControl btnDeviceName = null;
        /// <summary>
        /// 设备Mac地址
        /// 设备的某一回路
        /// </summary>
        private string deviceMac = string.Empty;
        private CommonDevice deviceObj = null;
        /// <summary>
        /// 设备需要保存的设备名字
        /// </summary>
@@ -49,11 +50,11 @@
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        /// <param name="i_deviceMac">设备Mac地址</param>
        public void ShowForm(string i_deviceMac)
        /// <param name="i_device">设备的某一回路</param>
        public void ShowForm(CommonDevice i_device)
        {
            this.deviceMac = i_deviceMac;
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
            this.deviceObj = i_device;
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
            //获取这一堆设备时属于什么类型的
            this.deviceEnumInfo = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
@@ -76,18 +77,18 @@
            this.ClearBodyFrame();
            //初始化桌布
            this.InitFrameTable();
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 562, 1175);
            //初始化设备回路图标
            this.InitDeviceEpointIcon();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr = null;
            //保存
            var btnFinish = new BottomClickButton();
            //借用Y轴坐标(让这个区域不能点击菜单)
            var frameBack = new FrameLayout();
            frameBack.Y = btnFinish.Yaxis;
            frameBack.Height = bodyFrameLayout.Height - btnFinish.Yaxis;
            bodyFrameLayout.AddChidren(frameBack);
            btnFinish.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += async (sender, e) =>
@@ -98,7 +99,7 @@
                this.ShowProgressBar();
                foreach (var epoint in dicDeviceSaveName.Keys)
                {
                    var device = Common.LocalDevice.Current.GetDevice(deviceMac, epoint);
                    var device = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, epoint);
                    if (device == null || dicDeviceSaveName[epoint] == string.Empty)
                    {
                        //不能允许空白名字
@@ -166,29 +167,15 @@
            };
            //所属区域
            List<string> listRoomName = Common.Room.CurrentRoom.GetRoomListNameByDevice(nowSelectDevice);
            caption = Language.StringByID(R.MyInternationalizationString.uBelongArea);
            nameValue = Common.Room.CurrentRoom.GetRoomName(listRoomName);
            var btnBeloneArea = new FrameCaptionViewControl(caption, nameValue, listview.rowSpace / 2);
            listview.AddChidren(btnBeloneArea);
            btnBeloneArea.InitControl();
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
            listview.AddChidren(rowBeloneArea);
            rowBeloneArea.InitControl(Language.StringByID(R.MyInternationalizationString.uBelongArea), nowSelectDevice);
            //底线
            btnBeloneArea.AddBottomLine();
            //右箭头
            btnBeloneArea.AddRightArrow();
            btnBeloneArea.ButtonClickEvent += (sender, e) =>
            rowBeloneArea.AddBottomLine();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                var form = new SelectRoomForm();
                form.AddForm(listRoomName);
                form.ActionSelectRoom = (list) =>
                {
                    //变更房间
                    Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, list);
                    btnBeloneArea.Text = Common.Room.CurrentRoom.GetRoomName(list);
                    listRoomName.Clear();
                    listRoomName.AddRange(list);
                };
                //变更房间
                Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys);
            };
            //3路继电器或者1路调光器第七回路的配置信息
@@ -205,7 +192,7 @@
                    //这里先去获取它的干接点类型
                    this.ShowProgressBar();
                    //获取第七回路的配置信息
                    listRelayInfo7 = await HdlPanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
                    listRelayInfo7 = await HdlDevicePanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
                    if (listRelayInfo7 == null)
                    {
                        //关闭进度条
@@ -223,18 +210,6 @@
            this.AddBindRow(listRelayInfo7);
            //添加背光灯行
            this.AddBackLightRow();
            //借用Y轴坐标
            var btnTemp = new BottomClickButton();
            var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount;
            if (bodyFrameLayout.Height - btnTemp.Yaxis + realHeight > listview.Height)
            {
                //促使被挡住的菜单能够向上滑动
                var frameTemp = new FrameLayout();
                frameTemp.Height = bodyFrameLayout.Height - btnTemp.Yaxis + Application.GetRealHeight(115);
                listview.AddChidren(frameTemp);
            }
            btnTemp = null;
        }
        #endregion
@@ -270,7 +245,7 @@
            {
                menuCount = 2;
            }
            var frame = new TopRightMenuControl(this, menuCount);
            var frame = new TopRightMenuControl(menuCount);
            if (canTest == true)
            {
                //定位
@@ -337,7 +312,7 @@
                    //标题:选择干接点功能
                    var title = Language.StringByID(R.MyInternationalizationString.uSelectDryContactFunction);
                    var form = new BottomDialogSelectForm();
                    var form = new BottomItemSelectForm();
                    form.AddForm(title, listText, nowSelectNo);
                    form.FinishSelectEvent += async (selectNo) =>
                    {
@@ -353,7 +328,7 @@
                            //选择的是传感器输入
                            value = 65535;
                        }
                        var result = await HdlPanelLogic.Current.EditorDryContactFunction((Panel)nowSelectDevice, value);
                        var result = await HdlDevicePanelLogic.Current.EditorDryContactFunction((Panel)nowSelectDevice, value);
                        if (result == true)
                        {
                            //重新初始化菜单行,隐藏或者开放绑定目标菜单
@@ -400,6 +375,11 @@
                btnBind.AddRightArrow();
                btnBind.ButtonClickEvent += (sender, e) =>
                {
                    var panel = nowSelectDevice as ZigBee.Device.Panel;
                    var bindTargetsPage = new Shared.Phone.UserCenter.DeviceBind.BindTargetsPage(panel);
                    Shared.Phone.UserView.HomePage.Instance.AddChidren(bindTargetsPage);
                    Shared.Phone.UserView.HomePage.Instance.PageIndex += 1;
                    bindTargetsPage.Show();
                };
            }
        }
@@ -414,7 +394,7 @@
        private void AddBackLightRow()
        {
            //三路继电器,或者一路调光器 的时候才能开启此选项
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
            var myType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
            if (myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad
@@ -431,8 +411,8 @@
                btnLight.AddRightArrow();
                btnLight.ButtonClickEvent += (sender, e) =>
                {
                    var form = new RelayThreeLoadBackLightSettionForm();
                    form.AddForm(deviceMac);
                    var form = new DeviceRelay.RelayThreeLoadBackLightSettionForm();
                    form.AddForm(deviceObj.DeviceAddr);
                };
            }
        }
@@ -484,7 +464,7 @@
                frame.Height = Application.GetMinRealAverage(124);
                frameBack.AddChidren(frame);
                //初始化一行设备图标
                this.InitDeviceIconFrame(frame, listIcon[i], i == 0, ref index);
                this.InitDeviceIconFrame(frame, listIcon[i], ref index);
                if (listIcon.Count == 1)
                {
@@ -513,10 +493,9 @@
        /// </summary>
        /// <param name="frame"></param>
        /// <param name="listDevice"></param>
        /// <param name="isFirstRow"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        private void InitDeviceIconFrame(FrameLayout frame, List<CommonDevice> listDevice, bool isFirstRow, ref int index)
        private void InitDeviceIconFrame(FrameLayout frame, List<CommonDevice> listDevice, ref int index)
        {
            NormalViewControl btnTemp = null;
            //间距
@@ -539,12 +518,12 @@
                //点击事件
                btnIcon.ButtonClickEvent += this.DeviceEpointSelectEvent;
                if (i == 0 && isFirstRow == true)
                if (listDevice[i].DeviceEpoint == deviceObj.DeviceEpoint)
                {
                    btnTemp = btnIcon;
                }
            }
            if (isFirstRow == true)
            if (btnTemp != null)
            {
                //初始化菜单行
                this.DeviceEpointSelectEvent(btnTemp, null);
@@ -557,7 +536,8 @@
        /// <returns></returns>
        private List<List<CommonDevice>> GetAllDeviceGroup()
        {
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceMac);
            bool hadDevice = false;
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
            var listRelay = new List<CommonDevice>();
            foreach (var device in listDevice)
            {
@@ -565,6 +545,11 @@
                {
                    //只要干接点
                    listRelay.Add(device);
                    if (device.DeviceEpoint == deviceObj.DeviceEpoint)
                    {
                        //能够匹配得到这个回路
                        hadDevice = true;
                    }
                }
            }
            //排序
@@ -576,6 +561,12 @@
                }
                return -1;
            });
            if (hadDevice == false)
            {
                //如果匹配不到这个回路,则默认第一个
                this.deviceObj = listRelay[0];
            }
            //从下往上4个为一组
            var listIcon = new List<List<CommonDevice>>();
            var listTemp = new List<CommonDevice>();
@@ -593,44 +584,6 @@
                listIcon.Insert(0, listTemp);
            }
            return listIcon;
        }
        #endregion
        #region ■ 初始化桌布_________________________
        /// <summary>
        /// 初始化桌布
        /// </summary>
        private void InitFrameTable()
        {
            //弧度的圆的一半的高度(固定)
            int halfRoundHeigth = Application.GetRealHeight(116) / 2;
            //弧度的圆
            var btnRound = new NormalViewControl(bodyFrameLayout.Width, halfRoundHeigth * 2, false);
            btnRound.Y = Application.GetRealHeight(562);
            btnRound.BackgroundColor = UserCenterColor.Current.White;
            btnRound.Radius = (uint)halfRoundHeigth;
            bodyFrameLayout.AddChidren(btnRound);
            //明细列表的桌布,白色背景(覆盖弧度的圆的半边)
            var detailBackFrame = new FrameLayout();
            detailBackFrame.Y = btnRound.Bottom - btnRound.Height / 2;
            detailBackFrame.Height = Application.GetRealHeight(1175);//高度就是要它超过
            detailBackFrame.BackgroundColor = UserCenterColor.Current.White;
            bodyFrameLayout.AddChidren(detailBackFrame);
            //设备编辑
            var btnTile = new NormalViewControl(800, 60, true);
            btnTile.X = ControlCommonResourse.XXLeft;
            btnTile.TextSize = 15;
            btnTile.TextColor = UserCenterColor.Current.TextColor2;
            btnTile.TextID = R.MyInternationalizationString.uDeviceEditor;
            detailBackFrame.AddChidren(btnTile);
            this.listview = new VerticalListControl(12);
            listview.Y = btnTile.Bottom + Application.GetRealHeight(17);
            listview.Height = Application.GetRealHeight(1175) - halfRoundHeigth - btnTile.Bottom - Application.GetRealHeight(17);
            detailBackFrame.AddChidren(listview);
        }
        #endregion
@@ -665,7 +618,7 @@
            nowContr.TextColor = UserCenterColor.Current.TextColor1;
            nowSelectControl = nowContr;
            nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceMac, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
            nowSelectDevice = Common.LocalDevice.Current.GetDevice(deviceObj.DeviceAddr, Convert.ToInt32(nowContr.Name.Replace("btn", string.Empty)));
            //重新初始化菜单行
            this.InitMenuRow();