xm
2020-07-21 9a4b76398009cf76c508d61f7e48fb6f5cb7ac2d
ZigbeeApp/Shared/Phone/UserCenter/DoorLock/FunctionSetting.cs
@@ -1,29 +1,38 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.UserCenter.DoorLock
{
    public class FunctionSetting : DoorLockCommonLayout, ZigBee.Common.IStatus
    public class FunctionSetting : DoorLockCommonLayout
    {
        #region ◆ 构造函数__________________________
        #region  构造函数
        /// <summary>
        /// 构造函数
        /// </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;
            ZigBee.Device.ZbGateway.StatusList.Add(this);
        }
        #endregion
        #region ◆ 变量申明__________________________
        #region  变量申明
        public ZigBee.Device.DoorLock doorLock = null;
        /// <summary>
        /// 当前房间
        /// </summary>
        Room currentRoom;
        /// <summary>
        /// 设备UI对象
        /// </summary>
        CommonDevice deviceUI;
        /// <summary>
        /// 设备需要保存的设备名字
        /// </summary>
@@ -53,7 +62,7 @@
        FrameLayout bottomFrameLayout;
        #endregion
        #region ◆ UI显示 __________________________
        #region  UI显示
        /// <summary>
        /// UI显示 
        /// </summary>
@@ -74,18 +83,15 @@
        }
        #endregion
        #region ◆ 中部显示 __________________________
        #region  中部显示
        public void MidFrameLayoutContent()
        {
            var MidTopFrameLayout = new FrameLayout()
            {
                X = Application.GetRealWidth(449),
                Y = Application.GetRealHeight(58),
                Width = Application.GetRealWidth(184),
                Height = Application.GetRealHeight(184),
                BackgroundImagePath = "DoorLock/DoorlockPicture.png",
            };
            this.midFrameLayout.AddChidren(MidTopFrameLayout);
            //图片
            var btnPic = new DeviceInfoIconControl();
            btnPic.Y = Application.GetRealHeight(92);
            btnPic.Gravity = Gravity.CenterHorizontal;
            this.midFrameLayout.AddChidren(btnPic);
            btnPic.InitControl(doorLock);
            var btnDeviceText = new Button()
            {
@@ -102,7 +108,7 @@
        }
        #endregion
        #region ◆ 底部显示 __________________________
        #region  底部显示
        public void BottomFrameLayout()
        {
            #region  UI 
@@ -133,13 +139,13 @@
                Y = Application.GetRealHeight(170),
            };
            bottomFrameLayout.AddChidren(listview);
            #endregion
            #endregion
            FunctionDetail(doorLock);
        }
        #endregion
        #region ◆ 功能显示 __________________________
        #region  功能显示
        void FunctionDetail(ZigBee.Device.DoorLock doorLock)
        {
            listview.RemoveAll();
@@ -175,20 +181,28 @@
            var listCheck = new List<string>();
            rowBeloneArea.SelectRoomEvent += (roomKeys) =>
            {
                //选择未分配时,清空
                if (roomKeys == string.Empty) { listCheck = new List<string>(); }
                foreach (var device in this.listNewDevice)
                {
                    var room = Room.CurrentRoom.GetRoomByDevice(device);
                {
                    if (roomKeys == string.Empty)
                    {
                        //如果选择的是未分配,则它的全部回路无条件全部清空房间
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                        continue;
                    }
                    var room = HdlRoomLogic.Current.GetRoomByDevice(device);
                    string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
                    if (room == null)
                    {
                        //这里有点特殊,如果回路没有设置有区域的时候,才设置
                        listCheck.Add(mainKeys);
                        Room.CurrentRoom.ChangedRoom(device, roomKeys);
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                    else if (listCheck.Contains(mainKeys) == true)
                    {
                        //如果这个回路之前都还没有区域,在本界面还没有关闭之前,可以无条件随便变更
                        Room.CurrentRoom.ChangedRoom(device, roomKeys);
                        HdlRoomLogic.Current.ChangedRoom(device, roomKeys);
                    }
                }
                //保存设备房间索引
@@ -196,7 +210,7 @@
            };
            //设备模块
            caption = Language.StringByID(R.MyInternationalizationString.BelongModel);
            caption = Language.StringByID(R.MyInternationalizationString.BelongDevice);
            deviceName = Common.LocalDevice.Current.GetDeviceObjectText(listNewDevice);
            var btnType = new FrameCaptionViewControl(caption, deviceName, listview.rowSpace / 2);
            btnType.UseClickStatu = false;
@@ -234,7 +248,7 @@
        }
        #endregion
        #region 添加全部菜单
        #region  添加全部菜单
        /// <summary>
        /// 添加全部菜单
        /// </summary>
@@ -283,7 +297,7 @@
                };
                actionNone = async () =>
                {
                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock, action);
                    Shared.Phone.UserCenter.DoorLock.DoorLockCommonLayout.SecurityRequest(doorLock);
                };
                HdlCheckLogic.Current.CheckSecondarySecurity(action, actionNone);
            };
@@ -407,19 +421,19 @@
        #endregion
        #region ◆ 设备重命名__________________________
        #region  设备重命名
        /// <summary>
        /// 设备重命名
        /// </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 = Common.LocalDevice.Current.ReMacName(listNewDevice, deviceName);
            //关闭进度条
            this.CloseProgressBar();
@@ -448,60 +462,34 @@
        }
        #endregion
        #region ◆ 行数超过容器时,补一个空白FrameLayout__________________________
        #region  行数超过容器时,补一个空白FrameLayout
        /// <summary>
        /// 行数超过容器时,补一个空白FrameLayout,使之能滑动
        /// </summary> 
        void FinishInitControl(FrameLayout bodyFrameLayout, VerticalListControl listview)
        {
            var btnFinish = new BottomClickButton();
            btnFinish.Y = Application.GetRealHeight(1054);
            if (listview.ChildrenCount > 0)
            {
                var realHeight = listview.GetChildren(0).Height * listview.ChildrenCount;
                if (bodyFrameLayout.Height - btnFinish.Y + realHeight > listview.Height)
                if (bodyFrameLayout.Height - Application.GetRealHeight(1054) + realHeight > listview.Height)
                {
                    //促使被挡住的菜单能够向上滑动
                    var frameTemp = new FrameLayout();
                    frameTemp.Height = bodyFrameLayout.Height - btnFinish.Y + Application.GetRealHeight(115);
                    frameTemp.Height = bodyFrameLayout.Height - Application.GetRealHeight(1054) + Application.GetRealHeight(115);
                    listview.AddChidren(frameTemp);
                }
            }
        }
        #endregion
        #region ◆ 接口实现__________________________
        #region 移除方法
        /// <summary>
        /// 处理变化事件 --将弃用 改用DeviceInfoChange()
        /// 重写移除方法
        /// </summary>
        /// <returns>The changed.</returns>
        /// <param name="common">Common.</param>
        public void Changed(CommonDevice common)
        public override void RemoveFromParent()
        {
        }
        /// <summary>
        /// 处理变化事件
        /// </summary>
        /// <param name="common"></param>
        /// <param name="typeTag"></param>
        public void DeviceInfoChange(CommonDevice common, string typeTag)
        {
        }
        /// <summary>
        /// Changeds the IL ogic status.
        /// </summary>
        /// <param name="logic">Logic.</param>
        public void ChangedILogicStatus(ZigBee.Device.Logic logic)
        {
        }
        /// <summary>
        /// Changeds the IS cene status.
        /// </summary>
        /// <param name="scene">Scene.</param>
        public void ChangedISceneStatus(Scene scene)
        {
            base.RemoveFromParent();
        }
        #endregion
    }