黄学彪
2020-12-17 9f326f4000847e6167d8166fa2f6a66f53cb3734
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
@@ -12,10 +13,11 @@
        /// 构造函数
        /// </summary>
        /// <param name="doorLock"></param>
        public FunctionSetting(ZigBee.Device.DoorLock doorLock)
        public FunctionSetting(Room room, CommonDevice doorLock)
        {
            //闪退
            this.doorLock = doorLock;
            this.doorLock = doorLock as ZigBee.Device.DoorLock;
            currentRoom = room;
            deviceUI = doorLock;
            listNewDevice.Add(doorLock);
            BackgroundColor = Shared.Common.ZigbeeColor.Current.GXCTopViewBackgroundColor;
        }
@@ -23,6 +25,14 @@
        #region  变量申明 
        public ZigBee.Device.DoorLock doorLock = null;
        /// <summary>
        /// 当前房间
        /// </summary>
        Room currentRoom;
        /// <summary>
        /// 设备UI对象
        /// </summary>
        CommonDevice deviceUI;
        /// <summary>
        /// 设备需要保存的设备名字
        /// </summary>
@@ -53,8 +63,8 @@
        #endregion
        #region  UI显示  
        /// <summary>
        /// UI显示
        /// <summary>
        /// UI显示
        /// </summary>
        public void Show()
        {
@@ -90,7 +100,7 @@
                Gravity = Gravity.CenterHorizontal,
                TextColor = ZigbeeColor.Current.XMBlack,
                TextSize = 15,
                Text = Common.LocalDevice.Current.GetDeviceMacName(doorLock),
                Text = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock),
            };
            this.midFrameLayout.AddChidren(btnDeviceText);
@@ -141,15 +151,16 @@
            listview.RemoveAll();
            //设备备注
            string caption = Language.StringByID(R.MyInternationalizationString.DeviceRemarkXm);
            string deviceName = Common.LocalDevice.Current.GetDeviceMacName(doorLock);
            string deviceName = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock);
            var btnNote = new FrameCaptionInputControl(caption, deviceName, listview.rowSpace / 2);
            btnNote.txtInput.MaxByte = 48;//限制只能输入48个字节
            listview.AddChidren(btnNote);
            btnNote.InitControl();
            //划线
            btnNote.AddBottomLine();
            btnNote.txtInput.FinishInputEvent += () =>
            {
                string oldName = Common.LocalDevice.Current.GetDeviceMacName(doorLock);
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceMacName(doorLock);
                if (btnNote.Text == string.Empty)
                {
                    btnNote.Text = oldName;
@@ -171,10 +182,18 @@
            var listCheck = new List<string>();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //选择未分配时,清空
                if (roomKeys == string.Empty) { listCheck = new List<string>(); }
                foreach (var device in this.listNewDevice)
                {
                    if (roomKeys == string.Empty)
                    {
                        //如果选择的是未分配,则它的全部回路无条件全部清空房间
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                        continue;
                    }
                    var room = HdlRoomLogic.Current.GetRoomByDevice(device);
                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
                    string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
                    if (room == null)
                    {
                        //这里有点特殊,如果回路没有设置有区域的时候,才设置
@@ -188,12 +207,12 @@
                    }
                }
                //保存设备房间索引
                Common.LocalDevice.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
                HdlRoomLogic.Current.SaveRealDeviceRoomId(this.listNewDevice, roomKeys);
            };
            //设备模块
            caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
            deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice);
            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
            deviceName = HdlDeviceCommonLogic.Current.GetDeviceObjectText(listNewDevice);
            var btnType = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
            btnType.UseClickStatu = false;
            listview.AddChidren(btnType);
@@ -211,7 +230,7 @@
            bottomFrameLayout.AddChidren(btnFinish);
            btnFinish.ButtonClickEvent += (sender, e) =>
            {
                string oldName = Common.LocalDevice.Current.GetDeviceMacName(listNewDevice[0]);
                string oldName = HdlDeviceCommonLogic.Current.GetDeviceMacName(listNewDevice[0]);
                if (btnNote.Text.Trim() == string.Empty)
                {
                    btnNote.Text = oldName;
@@ -236,7 +255,7 @@
        /// </summary>
        private void AddAllMenuRow()
        {
            if (UserCenterResourse.UserInfo.AuthorityNo == 1)
            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1)
            {
                //添加【临时密码】行
                this.AddTempPasswordRow();
@@ -279,7 +298,7 @@
                };
                actionNone = async () =>
                {
                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock);
                };
                HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
            };
@@ -312,7 +331,7 @@
            btnswitch.ButtonClickEvent += async (sender, e) =>
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1)
                {
                    if (btnswitch.IsSelected == true)
                    {
@@ -376,7 +395,7 @@
            var doorLock = this.listNewDevice[0] as ZigBee.Device.DoorLock;
            btnRow.ButtonClickEvent += async (sender, e) =>
            {
                if (UserCenterResourse.UserInfo.AuthorityNo == 1)
                if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 1)
                {
                    var tempPage = new Shared.Phone.UserCenter.DoorLock.TimeSettignPage(doorLock, "DoorLockTime");
                    Shared.Phone.UserView.HomePage.Instance.AddChidren(tempPage);
@@ -408,14 +427,14 @@
        /// 设备重命名
        /// </summary>
        /// <param name="i_deviceName">deviceName.</param>
        private async void DeviceReName(string i_deviceName, bool closeForm)
        private void DeviceReName(string i_deviceName, bool closeForm)
        {
            //开启进度条
            this.ShowProgressBar();
            //修改MAC名
            string deviceName = i_deviceName.Trim();
            var result = await Common.LocalDevice.Current.ReMacName(listNewDevice, deviceName);
            var result = HdlDeviceCommonLogic.Current.ReMacName(listNewDevice, deviceName);
            //关闭进度条
            this.CloseProgressBar();
@@ -464,6 +483,16 @@
            }
        }
        #endregion
        #region 移除方法
        /// <summary>
        /// 重写移除方法
        /// </summary>
        public override void RemoveFromParent()
        {
            base.RemoveFromParent();
        }
        #endregion
    }
}