HDL Home App 第二版本 旧平台金堂用 正在使用
hxb
2022-08-30 25429f085093d89d543a0b90e30d0d62d1b7dac9
ZigbeeApp/Shared/Phone/Category/AdjustTargetAddDeviceForm.cs
@@ -42,6 +42,10 @@
        /// 设备列表控件
        /// </summary>
        private VerticalListControl listDeviceView = null;
        /// <summary>
        /// 当前选择的楼层
        /// </summary>
        private string nowSelectFloorId = string.Empty;
        #endregion
@@ -57,6 +61,8 @@
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.AddFunction));
            //初始化右上角的控件
            this.InitTopRightMenuControl();
            //初始化中部信息
            this.InitMiddleFrame();
        }
@@ -66,8 +72,58 @@
        /// </summary>
        private void InitMiddleFrame()
        {
            //清空body
            this.ClearBodyFrame();
            //初始化房间菜单控件
            this.InitRoomMenuControl();
        }
        /// <summary>
        /// 初始化右上角的控件
        /// </summary>
        private void InitTopRightMenuControl()
        {
            //获取楼层
            var dicFloor = HdlRoomLogic.Current.GetFloorSortList();
            if (dicFloor.Count == 0)
            {
                return;
            }
            var btnIconContr = new MostRightIconControl(69, 69);
            btnIconContr.UnSelectedImagePath = "Item/Drop_Down.png";
            topFrameLayout.AddChidren(btnIconContr);
            btnIconContr.InitControl();
            var btnFloor = new NormalViewControl(300, 69, true);
            btnFloor.Gravity = Gravity.CenterVertical;
            btnFloor.X = btnIconContr.X + btnIconContr.btnIcon.X - Application.GetRealWidth(300);
            btnFloor.TextAlignment = TextAlignment.CenterRight;
            topFrameLayout.AddChidren(btnFloor);
            foreach (var floorId in dicFloor.Keys)
            {
                //第一个楼层
                this.nowSelectFloorId = floorId;
                btnFloor.Text = dicFloor[floorId];
                break;
            }
            btnIconContr.ButtonClickEvent += (sender, e) =>
            {
                //楼层菜单
                var contr = new TopRightFloorMenuControl(dicFloor.Count, 2, this.nowSelectFloorId, Language.StringByID(R.MyInternationalizationString.SelectFloor));
                foreach (var floorId in dicFloor.Keys)
                {
                    contr.AddRowMenu(floorId, () =>
                    {
                        //记录起选择的ID
                        this.nowSelectFloorId = floorId;
                        btnFloor.Text = dicFloor[this.nowSelectFloorId];
                        //初始化中部信息
                        this.InitMiddleFrame();
                    });
                }
            };
        }
        #endregion
@@ -98,7 +154,10 @@
            roomSwitchContr.SelectRoomEvent += (selectRoom) =>
            {
                //在外面清空(特效的问题)
                this.deviceFunctionMenuContr?.RemoveAll();
                if (this.deviceFunctionMenuContr != null && this.deviceFunctionMenuContr.Parent != null)
                {
                    this.deviceFunctionMenuContr.RemoveAll();
                }
                this.listDeviceView?.RemoveAll();
                HdlThreadLogic.Current.RunMainInThread(() =>
@@ -116,7 +175,10 @@
            this.btnFinishControl = new BottomClickButton();
            btnFinishControl.TextID = R.MyInternationalizationString.uFinish;
            bodyFrameLayout.AddChidren(btnFinishControl);
            btnFinishControl.Visible = false;
            if (this.dicNewListTask == null || this.dicNewListTask.Count == 0)
            {
                btnFinishControl.Visible = false;
            }
            btnFinishControl.ButtonClickEvent += (sender, e) =>
            {
                //回调函数
@@ -136,20 +198,24 @@
        /// <returns></returns>
        private List<Room> GetCanShowRoomList()
        {
            //先将列表Dictionary化
            this.dicNewListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
            this.dicOldListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
            foreach (var data in this.listAdjustTarget)
            if (this.dicNewListTask == null)
            {
                if (data.Type == 0)
                //先将列表Dictionary化
                this.dicNewListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
                this.dicOldListTask = new Dictionary<string, List<Safeguard.TaskListInfo>>();
                foreach (var data in this.listAdjustTarget)
                {
                    //只要设备
                    string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                    dicOldListTask[mainkey] = data.TaskList;
                    if (data.Type == 0)
                    {
                        //只要设备
                        string mainkey = LocalDevice.Current.GetDeviceMainKeys(data.DeviceAddr, data.Epoint);
                        dicOldListTask[mainkey] = data.TaskList;
                    }
                }
            }
            //当前楼层的全部房间
            var lisrRoom = HdlRoomLogic.Current.GetRoomsByCurrentFloorIdAppendLoveRoom();
            var lisrRoom = HdlRoomLogic.Current.GetRoomsByFloorIdAppendLoveRoom(this.nowSelectFloorId);
            var listShowRoom = new List<Room>();
            foreach (var room in lisrRoom)
            {
@@ -181,7 +247,7 @@
            var dicGroupDevice = this.GetAllGroupDevice(room);
            //只初始化一次
            if (this.deviceFunctionMenuContr == null)
            if (this.deviceFunctionMenuContr == null || this.deviceFunctionMenuContr.Parent == null)
            {
                //设备菜单的白色背景
                var functionBack1 = new FrameLayout();
@@ -228,10 +294,10 @@
            //上一次选择的菜单和数据
            DeviceRowInfo nowSelectDeviceInfo = null;
            MainPage.Controls.DeviceFunctionUnallocatedControl oldSelectContr = null;
            foreach (int Textid in dicGroupDevice.Keys)
            MainPage.Controls.DeviceFunctionMenuControl oldSelectContr = null;
            foreach (string strText in dicGroupDevice.Keys)
            {
                var rowInfo = dicGroupDevice[Textid];
                var rowInfo = dicGroupDevice[strText];
                //设备类型的容器
                var devieFrame = new FrameLayout();
@@ -239,9 +305,9 @@
                deviceFunctionMenuContr.AddChidren(devieFrame);
                //菜单图片控件
                var deviceObjContr = new MainPage.Controls.DeviceFunctionUnallocatedControl();
                var deviceObjContr = new MainPage.Controls.DeviceFunctionMenuControl();
                devieFrame.AddChidren(deviceObjContr);
                deviceObjContr.InitControl(Language.StringByID(Textid), rowInfo.IconPath, rowInfo.IconPathSelected, rowInfo.listDeviceKeys);
                deviceObjContr.InitControl(strText, rowInfo.IconPath, rowInfo.IconPathSelected);
                deviceObjContr.ButtonClickEvent += (sender, e) =>
                {
                    //选择的是同一个东西的话,不处理
@@ -256,7 +322,7 @@
                        HdlThreadLogic.Current.RunMainInThread(() =>
                        {
                            //初始化设备列表控件
                            this.InitListDeviceControls(listDeviceView, rowInfo, room);
                            this.InitListDeviceControls(listDeviceView, rowInfo);
                        });
                    }
                };
@@ -273,7 +339,7 @@
            if (nowSelectDeviceInfo != null)
            {
                //初始化默认的设备列表控件
                this.InitListDeviceControls(listDeviceView, nowSelectDeviceInfo, room);
                this.InitListDeviceControls(listDeviceView, nowSelectDeviceInfo);
            }
        }
@@ -286,7 +352,7 @@
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="rowInfo"></param>
        private void InitListDeviceControls(VerticalListControl listView, DeviceRowInfo rowInfo, Room i_room)
        private void InitListDeviceControls(VerticalListControl listView, DeviceRowInfo rowInfo)
        {
            //先清空
            listView.RemoveAll();
@@ -333,11 +399,11 @@
            //设备图标背景控件
            var frameIconBackGroud = new FrameLayout();
            frameIconBackGroud.Height = Application.GetMinRealAverage(112);
            frameIconBackGroud.Width = Application.GetMinRealAverage(112);
            frameIconBackGroud.Height = this.GetPictrueRealSize(112);
            frameIconBackGroud.Width = this.GetPictrueRealSize(112);
            frameIconBackGroud.Gravity = Gravity.CenterVertical;
            frameIconBackGroud.X = Application.GetRealWidth(46);
            frameIconBackGroud.Radius = (uint)Application.GetMinRealAverage(112 / 2);
            frameIconBackGroud.Radius = (uint)this.GetPictrueRealSize(112 / 2);
            frameIconBackGroud.BackgroundColor = Common.ZigbeeColor.Current.GXCGrayBackgroundColor;
            rowDevice.AddChidren(frameIconBackGroud, ChidrenBindMode.NotBind);
            frameIconBackGroud.Y += rowDevice.chidrenYaxis;
@@ -348,14 +414,14 @@
            Common.LocalDevice.Current.SetDeviceIconToControl(btnDeviceIcon, device);
            frameIconBackGroud.AddChidren(btnDeviceIcon);
            //重新绑定事件
            rowDevice.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEventOnly);
            rowDevice.ChangedChidrenBindMode(frameIconBackGroud, ChidrenBindMode.BindEvent);
            //设备名字
            var btnDeviceName = new NormalViewControl(600, 60, true);
            btnDeviceName.X = Application.GetRealWidth(181);
            btnDeviceName.Gravity = Gravity.CenterVertical;
            btnDeviceName.Text = Common.LocalDevice.Current.GetDeviceEpointName(device);
            rowDevice.AddChidren(btnDeviceName, ChidrenBindMode.BindEventOnly);
            rowDevice.AddChidren(btnDeviceName, ChidrenBindMode.BindEvent);
            btnDeviceName.Y += rowDevice.chidrenYaxis;
            //底线
            var btnBottomLine = new NormalViewControl(Application.GetRealWidth(841), ControlCommonResourse.BottomLineHeight, false);
@@ -490,7 +556,7 @@
        /// 获取分组后的设备
        /// </summary>
        /// <returns></returns>
        private Dictionary<int, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
        private Dictionary<string, DeviceRowInfo> GetAllGroupDevice(Common.Room room)
        {
            //全部的设备
            var listDeviceTemp = HdlRoomLogic.Current.GetRoomListDevice(room);
@@ -506,23 +572,23 @@
            //根据设备所属类型排序
            listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice);
            var dic = new Dictionary<int, DeviceRowInfo>();
            var dic = new Dictionary<string, DeviceRowInfo>();
            foreach (var device in listDevice)
            {
                var typeInfo = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
                //按所属ID分组
                if (dic.ContainsKey(typeInfo.BeloneTextId) == false)
                if (dic.ContainsKey(typeInfo.BeloneText) == false)
                {
                    dic[typeInfo.BeloneTextId] = new DeviceRowInfo();
                    dic[typeInfo.BeloneText] = new DeviceRowInfo();
                    string path1 = string.Empty;
                    string path2 = string.Empty;
                    //获取图片
                    LocalDevice.Current.GetDeviceObjectIcon(typeInfo.ConcreteType, ref path1, ref path2);
                    dic[typeInfo.BeloneTextId].IconPath = path1;
                    dic[typeInfo.BeloneTextId].IconPathSelected = path2;
                    dic[typeInfo.BeloneTextId].TextId = typeInfo.BeloneTextId;
                    LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
                    dic[typeInfo.BeloneText].IconPath = path1;
                    dic[typeInfo.BeloneText].IconPathSelected = path2;
                    dic[typeInfo.BeloneText].TextId = typeInfo.BeloneText;
                }
                dic[typeInfo.BeloneTextId].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
                dic[typeInfo.BeloneText].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
            }
            return dic;
        }
@@ -557,6 +623,7 @@
                device.Type == DeviceType.DimmableLight ||//彩灯
                device.Type == DeviceType.OnOffOutput ||//继电器
                device.Type == DeviceType.Thermostat ||//空调
                device.Type == DeviceType.ColorTemperatureLight ||//色温灯
                device.Type == DeviceType.WindowCoveringDevice)//窗帘
            {
                string mainkey = LocalDevice.Current.GetDeviceMainKeys(device);
@@ -575,9 +642,9 @@
        private class DeviceRowInfo
        {
            /// <summary>
            /// 文本ID,目前用来做主键
            /// 文本,目前用来做主键
            /// </summary>
            public int TextId = 0;
            public string TextId = string.Empty;
            /// <summary>
            /// 图标
            /// </summary>