HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceDryContactSettionForm.cs
@@ -17,7 +17,7 @@
        /// <summary>
        /// 列表控件
        /// </summary>
        private VerticalListControl listview = null;
        private FrameListControl listview = null;
        /// <summary>
        /// 当前选择的设备
        /// </summary>
@@ -29,7 +29,7 @@
        /// <summary>
        /// 设备备注的控件
        /// </summary>
        private FrameCaptionInputControl btnDeviceName = null;
        private FrameCaptionInputControl frameDeviceName = null;
        /// <summary>
        /// 设备的某一回路
        /// </summary>
@@ -42,6 +42,10 @@
        /// 设备具体类型的信息
        /// </summary>
        private DeviceEnumInfo deviceEnumInfo = null;
        /// <summary>
        /// 信息编辑控件
        /// </summary>
        private InformationEditorControl tableContr = null;
        #endregion
@@ -76,25 +80,25 @@
            //清空bodyFrame
            this.ClearBodyFrame();
            var listBackControl = new VerticalFrameControl();
            listBackControl.Height = bodyFrameLayout.Height;
            bodyFrameLayout.AddChidren(listBackControl);
            //初始化桌布
            var tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(bodyFrameLayout, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 562, 1175);
            this.tableContr = new InformationEditorControl();
            this.listview = tableContr.InitControl(listBackControl.frameTable, Language.StringByID(R.MyInternationalizationString.uDeviceEditor), 1175);
            //初始化设备回路图标
            this.InitDeviceEpointIcon();
            //初始化桌布完成
            tableContr.FinishInitControl(bodyFrameLayout, this.listview);
            tableContr = null;
            this.InitDeviceEpointIcon(listBackControl);
            //保存
            var btnFinish = new BottomClickButton();
            btnFinish.TextID = R.MyInternationalizationString.uSave;
            bodyFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += async (sender, e) =>
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                //记录起当前正在操作的回路名字
                dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
                dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = frameDeviceName.Text.Trim();
                //开启进度条
                this.ShowProgressBar();
                foreach (var epoint in dicDeviceSaveName.Keys)
@@ -110,7 +114,7 @@
                    if (oldName != newName)
                    {
                        //设备名称修改
                        var result = await Common.LocalDevice.Current.ReName(device, newName);
                        var result = Common.LocalDevice.Current.ReName(device, newName);
                        if (result == false)
                        {
                            //关闭
@@ -123,12 +127,17 @@
                //关闭自身
                this.CloseForm();
            };
            //如果当前是展示模板,则不能编辑
            if (Common.Config.Instance.Home.IsShowTemplate == true)
            {
                btnFinish.CanClick = false;
            }
        }
        /// <summary>
        /// 初始化菜单行
        /// </summary>
        private async void InitMenuRow()
        private void InitMenuRow()
        {
            this.listview.RemoveAll();
@@ -140,31 +149,36 @@
                nameValue = dicDeviceSaveName[nowSelectDevice.DeviceEpoint];
            }
            this.btnDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
            listview.AddChidren(btnDeviceName);
            btnDeviceName.InitControl();
            btnDeviceName.AddBottomLine();
            btnDeviceName.txtInput.FinishInputEvent += async () =>
            this.frameDeviceName = new FrameCaptionInputControl(caption, nameValue, listview.rowSpace / 2);
            this.frameDeviceName.txtInput.MaxByte = 48;//限制只能输入48个字节
            listview.AddChidren(frameDeviceName);
            frameDeviceName.InitControl();
            frameDeviceName.AddBottomLine();
            //如果当前是展示模板,则不能编辑
            if (Common.Config.Instance.Home.IsShowTemplate == false)
            {
                string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
                if (btnDeviceName.Text.Trim() == string.Empty)
                frameDeviceName.txtInput.FinishInputEvent += () =>
                {
                    //将名字还原
                    btnDeviceName.Text = oldName;
                }
                if (oldName != btnDeviceName.Text.Trim())
                {
                    //设备名称修改
                    var result = await Common.LocalDevice.Current.ReName(nowSelectDevice, btnDeviceName.Text.Trim());
                    if (result == false)
                    string oldName = Common.LocalDevice.Current.GetDeviceEpointName(nowSelectDevice);
                    if (frameDeviceName.Text.Trim() == string.Empty)
                    {
                        return;
                        //将名字还原
                        frameDeviceName.Text = oldName;
                    }
                    //干接点备注修改成功!
                    string msg = Language.StringByID(R.MyInternationalizationString.uDryContactReNoteSuccess);
                    this.ShowMassage(ShowMsgType.Tip, msg);
                }
            };
                    if (oldName != frameDeviceName.Text.Trim())
                    {
                        //设备名称修改
                        var result = Common.LocalDevice.Current.ReName(nowSelectDevice, frameDeviceName.Text.Trim());
                        if (result == false)
                        {
                            return;
                        }
                        //干接点备注修改成功!
                        string msg = Language.StringByID(R.MyInternationalizationString.uDryContactReNoteSuccess);
                        this.ShowMassage(ShowMsgType.Tip, msg);
                    }
                };
            }
            //所属区域
            var rowBeloneArea = new BelongAreaControl(listview.rowSpace / 2);
@@ -175,7 +189,7 @@
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //变更房间
                Common.Room.CurrentRoom.ChangedRoom(nowSelectDevice, roomKeys);
                HdlRoomLogic.Current.ChangedRoom(nowSelectDevice, roomKeys);
            };
            //3路继电器或者1路调光器第七回路的配置信息
@@ -186,13 +200,15 @@
            if (isHdlDevice == true)
            {
                //如果是3路继电器或者1路调光器,并且是第七回路的时候,它好像可以改变类型
                //如果是7路干接点输入输出模块,并且是第七回路的时候,它好像可以改变类型
                if ((deviceEnumInfo.ConcreteType == DeviceConcreteType.Relay_ThreeLoad && nowSelectDevice.DeviceEpoint == 10)
                    || (deviceEnumInfo.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad && nowSelectDevice.DeviceEpoint == 7))
                    || (deviceEnumInfo.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad && nowSelectDevice.DeviceEpoint == 7)
                    || (deviceEnumInfo.ConcreteType == DeviceConcreteType.Relay_SevenLoadInOutPutDryContact && nowSelectDevice.DeviceEpoint == 7))
                {
                    //这里先去获取它的干接点类型
                    this.ShowProgressBar();
                    //获取第七回路的配置信息
                    listRelayInfo7 = await HdlDevicePanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
                    listRelayInfo7 = HdlDevicePanelLogic.Current.GetDryContactConfigureInfo(nowSelectDevice);
                    if (listRelayInfo7 == null)
                    {
                        //关闭进度条
@@ -210,6 +226,8 @@
            this.AddBindRow(listRelayInfo7);
            //添加背光灯行
            this.AddBackLightRow();
            //初始化桌布完成
            tableContr.FinishInitControl();
        }
        #endregion
@@ -222,7 +240,8 @@
        private void InitTopRightMenu()
        {
            //检测此回路是否拥有定位功能
            if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false)
            if (Common.LocalDevice.Current.DeviceIsCanFixedPosition(nowSelectDevice) == false
                || Common.Config.Instance.Home.IsShowTemplate == true)
            {
                return;
            }
@@ -250,7 +269,7 @@
            //{
            //    menuCount = 2;
            //}
            var frame = new TopRightMenuControl(menuCount);
            var frame = new TopRightMenuControl(menuCount, 1);
            if (canTest == true)
            {
                //定位
@@ -318,8 +337,8 @@
                    var title = Language.StringByID(R.MyInternationalizationString.uSelectDryContactFunction);
                    var form = new BottomItemSelectForm();
                    form.AddForm(title, listText, nowSelectNo);
                    form.FinishSelectEvent += async (selectNo) =>
                    form.AddForm(title, listText, null, nowSelectNo);
                    form.FinishSelectEvent += (selectNo) =>
                    {
                        if (selectNo == nowSelectNo)
                        {
@@ -333,7 +352,7 @@
                            //选择的是传感器输入
                            value = 65535;
                        }
                        var result = await HdlDevicePanelLogic.Current.EditorDryContactFunction((Panel)nowSelectDevice, value);
                        var result = HdlDevicePanelLogic.Current.EditorDryContactThirdFunction((Panel)nowSelectDevice, value);
                        if (result == true)
                        {
                            //重新初始化菜单行,隐藏或者开放绑定目标菜单
@@ -341,6 +360,11 @@
                        }
                    };
                };
                //如果当前是展示模板,则不能编辑
                if (Common.Config.Instance.Home.IsShowTemplate == true)
                {
                    btnFunction.CanClick = false;
                }
            }
        }
@@ -402,8 +426,11 @@
            var listDevice = Common.LocalDevice.Current.GetDevicesByMac(deviceObj.DeviceAddr);
            var myType = Common.LocalDevice.Current.GetMyDeviceEnumInfo(listDevice);
            //欧标2路5A没有背光灯
            if (myType.ConcreteType == DeviceConcreteType.Relay_ThreeLoad
                || myType.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad)
                || myType.ConcreteType == DeviceConcreteType.DimmableLight_OneLoad
                || myType.ConcreteType == DeviceConcreteType.Relay_NationalThreeLoadTenA
                || myType.ConcreteType == DeviceConcreteType.Relay_SevenLoadInOutPutDryContact)
            {
                //背光灯
                string caption = Language.StringByID(R.MyInternationalizationString.uBackLight);
@@ -416,8 +443,19 @@
                btnLight.AddRightArrow();
                btnLight.ButtonClickEvent += (sender, e) =>
                {
                    var form = new DeviceRelay.RelayThreeLoadBackLightSettionForm();
                    form.AddForm(deviceObj.DeviceAddr);
                    if (myType.ConcreteType == DeviceConcreteType.Relay_NationalThreeLoadTenA
                    || myType.ConcreteType == DeviceConcreteType.Relay_SevenLoadInOutPutDryContact)
                    {
                        //国标3路10A继电器小模块 或者 7路干接点输入输出模块
                        var form = new DeviceRelay.RelayNationalBackLightSettionForm();
                        form.AddForm(deviceObj.DeviceAddr);
                    }
                    else
                    {
                        //三路继电器,或者一路调光器
                        var form = new DeviceRelay.RelayThreeLoadBackLightSettionForm();
                        form.AddForm(deviceObj.DeviceAddr);
                    }
                };
            }
        }
@@ -429,7 +467,7 @@
        /// <summary>
        /// 初始化设备回路图标
        /// </summary>
        private void InitDeviceEpointIcon()
        private void InitDeviceEpointIcon(VerticalFrameControl listBackControl)
        {
            //获取按组分配的设备
            var listIcon = this.GetAllDeviceGroup();
@@ -440,9 +478,7 @@
            frameBorder.Width = Application.GetRealWidth(887);
            frameBorder.Height = Application.GetRealHeight(423);
            frameBorder.Radius = (uint)Application.GetRealHeight(6);
            frameBorder.BorderWidth = 1;
            frameBorder.BorderColor = 0xffd0d0d0;
            bodyFrameLayout.AddChidren(frameBorder);
            listBackControl.frameTable.AddChidren(frameBorder);
            var frameBack = new FrameLayout();
            frameBack.Height = frameBorder.Height;
@@ -452,7 +488,7 @@
                //需要滑动控件
                var listControl = new VerticalScrolViewLayout();
                listControl.Height = frameBorder.Height;
                bodyFrameLayout.AddChidren(listControl);
                listBackControl.frameTable.AddChidren(listControl);
                listControl.AddChidren(frameBack);
            }
@@ -466,8 +502,8 @@
            for (int i = 0; i < listIcon.Count; i++)
            {
                var frame = new FrameLayout();
                frame.Width = Application.GetMinRealAverage(887);
                frame.Height = Application.GetMinRealAverage(124);
                frame.Width = this.GetPictrueRealSize(887);
                frame.Height = this.GetPictrueRealSize(124);
                frameBack.AddChidren(frame);
                //初始化一行设备图标
                this.InitDeviceIconFrame(frame, listIcon[i], ref index);
@@ -478,14 +514,14 @@
                }
                else
                {
                    frame.Y = Application.GetMinRealAverage(58) + (frameBack.ChildrenCount - 1) * (frame.Height + Application.GetMinRealAverage(60));
                    frame.Y = this.GetPictrueRealSize(58) + (frameBack.ChildrenCount - 1) * (frame.Height + this.GetPictrueRealSize(60));
                }
            }
            if (listIcon.Count > 2)
            {
                //计算真实高度
                int realHeight = Application.GetMinRealAverage(58 + 58) + (frameBack.ChildrenCount - 1) * Application.GetMinRealAverage(124 + 60);
                int realHeight = this.GetPictrueRealSize(58 + 58) + (frameBack.ChildrenCount - 1) * this.GetPictrueRealSize(124 + 60);
                if (realHeight > frameBack.Height)
                {
                    //变更高度
@@ -505,7 +541,7 @@
        {
            NormalViewControl btnTemp = null;
            //间距
            int space = Application.GetMinRealAverage(84);
            int space = this.GetPictrueRealSize(84);
            int defultXX = (frame.Width - frame.Height * listDevice.Count - (listDevice.Count - 1) * space) / 2;
            for (int i = 0; i < listDevice.Count; i++)
            {
@@ -616,7 +652,7 @@
                nowSelectControl.TextSize = 13;
                nowSelectControl.TextColor = UserCenterColor.Current.TextGrayColor3;
                //记录它的名字
                dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = btnDeviceName.Text.Trim();
                dicDeviceSaveName[nowSelectDevice.DeviceEpoint] = frameDeviceName.Text.Trim();
            }
            //选择状态
            nowContr.BorderColor = 0xfffb744a;