黄学彪
2020-12-16 0d9f64668fd7350d6a21fd157e32009a96d98134
ZigbeeApp/Shared/Phone/MainPage/UnallocatedRoomForm.cs
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using System;
using System.Collections.Generic;
using Shared.Common;
using Shared.Phone.Device.CommonForm;
using Shared.Phone.UserCenter;
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.MainPage
{
using Shared.Phone.UserView;
using ZigBee.Device;
namespace Shared.Phone.MainPage
{
    /// <summary>
    /// 未分配的管理界面
    /// </summary>
    public class UnallocatedRoomForm : EditorCommonForm
    /// </summary>
    public class UnallocatedRoomForm : EditorCommonForm
    {
        #region ■ 变量声明___________________________
@@ -72,46 +72,46 @@
        #region ■ 初始化_____________________________
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        /// <summary>
        /// 画面显示(底层会固定调用此方法,借以完成画面创建)
        /// </summary>
        public void ShowForm()
        {
            //初始化头部控件
            this.InitTopFrameLayout();
            //初始化中部控件
            this.InitBodyFrameLayout();
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.Unallocated));
            //初始化全选控件
            this.InitAllSelectControl();
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
            this.InitTopFrameLayout();
            //初始化中部控件
            this.InitBodyFrameLayout();
            //设置头部信息
            base.SetTitleText(Language.StringByID(R.MyInternationalizationString.Unallocated));
            //初始化全选控件
            this.InitAllSelectControl();
            //初始化中部信息
            this.InitMiddleFrame();
        }
        /// <summary>
        /// 初始化中部信息
        /// </summary>
        private void InitMiddleFrame()
        {
            var tabControl = new SceneFunctionSwitchControl();
            tabControl.Y = Application.GetRealHeight(40);
            bodyFrameLayout.AddChidren(tabControl);
            //初始化场景桌布
            this.SceneBodyTableControl = new NormalFrameLayout();
            SceneBodyTableControl.Y = tabControl.Bottom;
            SceneBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
            this.SceneBodyTableControl = new NormalFrameLayout();
            SceneBodyTableControl.Y = tabControl.Bottom;
            SceneBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
            bodyFrameLayout.AddChidren(SceneBodyTableControl);
            //初始化设备桌布
            this.DeviceBodyTableControl = new NormalFrameLayout();
            DeviceBodyTableControl.Y = tabControl.Bottom;
            DeviceBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
            bodyFrameLayout.AddChidren(DeviceBodyTableControl);
            this.DeviceBodyTableControl = new NormalFrameLayout();
            DeviceBodyTableControl.Y = tabControl.Bottom;
            DeviceBodyTableControl.Height = bodyFrameLayout.Height - tabControl.Bottom;
            bodyFrameLayout.AddChidren(DeviceBodyTableControl);
            tabControl.SelectTabEvent += (index) =>
            {
                //场景
@@ -130,17 +130,17 @@
                    //检测各控件状态
                    this.CheckControlsStatu(this.nowSelectDeviceInfo);
                }
            };
            };
            //开始初始化场景功能切换控件
            var listTitle = new List<string>();
            listTitle.Add(Language.StringByID(R.MyInternationalizationString.uScence));
            listTitle.Add(Language.StringByID(R.MyInternationalizationString.uFunction));
            //他会自动回调事件
            tabControl.InitControl(listTitle);
            //他会自动回调事件
            tabControl.InitControl(listTitle);
        }
        #endregion
        #endregion
        #region ■ 场景分支___________________________
@@ -271,7 +271,7 @@
                //设备的背景容器
                var frameDeviceBack = new FrameLayout();
                frameDeviceBack.X = ControlCommonResourse.XXLeft;
                frameDeviceBack.X = HdlControlResourse.XXLeft;
                frameDeviceBack.Y = Application.GetRealHeight(369);
                frameDeviceBack.BackgroundColor = UserCenterColor.Current.White;
                frameDeviceBack.Width = bodyFrameLayout.Width;
@@ -300,7 +300,7 @@
        {
            //头部的白色背景
            var functionBack1 = new FrameLayout();
            functionBack1.X = ControlCommonResourse.XXLeft;
            functionBack1.X = HdlControlResourse.XXLeft;
            functionBack1.Y = Application.GetRealHeight(55);
            functionBack1.Height = Application.GetRealHeight(160);
            functionBack1.Width = Application.GetRealWidth(1028);
@@ -308,7 +308,7 @@
            DeviceBodyTableControl.AddChidren(functionBack1);
            functionBack1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
            var functionBack2 = new FrameLayout();
            functionBack2.X = ControlCommonResourse.XXLeft;
            functionBack2.X = HdlControlResourse.XXLeft;
            functionBack2.Y = functionBack1.Bottom - Application.GetRealHeight(50);
            functionBack2.Height = Application.GetRealHeight(279 - 160 + 50);
            functionBack2.Width = Application.GetRealWidth(1028);
@@ -318,7 +318,7 @@
            //左右滑动的控件
            var HorizontalView = new HorizontalScrolViewLayout();
            HorizontalView.X = Application.GetRealWidth(CommonFormResouce.X_Left);
            HorizontalView.X = HdlControlResourse.XXLeft;
            HorizontalView.Y = Application.GetRealHeight(55);
            HorizontalView.Height = Application.GetRealHeight(279);
            HorizontalView.Width = Application.GetRealWidth(1028);
@@ -391,7 +391,7 @@
            //初始化设备列表控件
            foreach (var deviceKey in rowInfo.listDeviceKeys)
            {
                var device = LocalDevice.Current.GetDevice(deviceKey);
                var device = HdlDeviceCommonLogic.Current.GetDevice(deviceKey);
                var deviceRow = new Controls.DeviceSelectUnallocatedControl(listDeviceView.rowSpace / 2);
                listDeviceView.AddChidren(deviceRow);
                deviceRow.InitControl(device);
@@ -489,12 +489,12 @@
                            if (this.canSelectAll == true)
                            {
                                //添加缓存
                                dicSelectDevice[LocalDevice.Current.GetDeviceMainKeys(device)] = device;
                                dicSelectDevice[HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device)] = device;
                            }
                            else
                            {
                                //移除缓存
                                dicSelectDevice.Remove(LocalDevice.Current.GetDeviceMainKeys(device));
                                dicSelectDevice.Remove(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
                            }
                        }
                    }
@@ -504,55 +504,55 @@
            };
        }
        #endregion
        #endregion
        #region ■ [添加到]控件_______________________
        #region ■ [添加到]控件_______________________
        /// <summary>
        /// 初始化添加到控件
        /// </summary>
        /// </summary>
        private void InitAddToControl()
        {
            //添加到 的背景图控件
            this.frameAddBackGroud = new FrameLayoutStatuControl();
            frameAddBackGroud.UseClickStatu = false;
            frameAddBackGroud.Height = Application.GetRealHeight(202);
            frameAddBackGroud.Gravity = Gravity.BottomCenter;
            frameAddBackGroud.BackgroundImagePath = "Room/AddBackground.png";
            bodyFrameLayout.AddChidren(frameAddBackGroud);
            frameAddBackGroud.Visible = false;
            //添加到 按钮
            var btnAdd = new NormalViewControl(1034, 156, true);
            btnAdd.Gravity = Gravity.Center;
            //添加到 的背景图控件
            this.frameAddBackGroud = new FrameLayoutStatuControl();
            frameAddBackGroud.UseClickStatu = false;
            frameAddBackGroud.Height = Application.GetRealHeight(202);
            frameAddBackGroud.Gravity = Gravity.BottomCenter;
            frameAddBackGroud.BackgroundImagePath = "Room/AddBackground.png";
            bodyFrameLayout.AddChidren(frameAddBackGroud);
            frameAddBackGroud.Visible = false;
            //添加到 按钮
            var btnAdd = new NormalViewControl(1034, 156, true);
            btnAdd.Gravity = Gravity.Center;
            btnAdd.BackgroundColor = UserCenterColor.Current.White;
            btnAdd.TextColor = ZigbeeColor.Current.GXCTextSelectedColor4;
            btnAdd.TextAlignment = TextAlignment.Center;
            btnAdd.TextID = R.MyInternationalizationString.AddTo;
            btnAdd.TextSize = 17;
            btnAdd.Radius = (uint)Application.GetRealHeight(35);
            btnAdd.TextColor = ZigbeeColor.Current.GXCTextSelectedColor4;
            btnAdd.TextAlignment = TextAlignment.Center;
            btnAdd.TextID = R.MyInternationalizationString.AddTo;
            btnAdd.TextSize = 17;
            btnAdd.Radius = (uint)Application.GetRealHeight(35);
            frameAddBackGroud.AddChidren(btnAdd, ChidrenBindMode.BindEvent);
            frameAddBackGroud.ButtonClickEvent += (sender, e) =>
            {
                HdlControlLogic.Current.ShowBottomListRoomView(string.Empty, Language.StringByID(R.MyInternationalizationString.AddTo), (selectId, selectName) =>
                {
                HdlControlLogic.Current.ShowBottomListRoomView(string.Empty, Language.StringByID(R.MyInternationalizationString.AddTo), (selectId, selectName) =>
                {
                    if (selectId == string.Empty)
                    {
                        //选择的是未分配
                        return;
                    }
                    //变更了当前房间的东西,主页需要刷新
                    }
                    //变更了当前房间的东西,主页需要刷新
                    if (HdlRoomLogic.Current.NowMainPageRoom.Id == selectId)
                    {
                        this.dataHadChanged = true;
                    }
                    //保存选择的设备和场景
                    var room = HdlRoomLogic.Current.GetRoomById(selectId);
                    }
                    //保存选择的设备和场景
                    var room = HdlRoomLogic.Current.GetRoomById(selectId);
                    this.SaveSelectDeviceAndScene(room);
                    //分类界面需要刷新
                    UserPage.Instance.RefreshCategoryForm = true;
                    //上传空间区域信息
                    HdlRoomLogic.Current.SetRoomInfoToGateway();
                    HdlRoomLogic.Current.SetRoomInfoToGateway();
                });
            };
        }
@@ -634,11 +634,11 @@
            //全部的设备
            var listDevice = HdlRoomLogic.Current.GetUnalloctedDevice();
            //根据设备所属类型排序
            listDevice = LocalDevice.Current.SortDeviceByBelongType(listDevice);
            listDevice = HdlDeviceCommonLogic.Current.SortDeviceByBelongType(listDevice);
            var dic = new Dictionary<string, DeviceRowInfo>();
            foreach (var device in listDevice)
            {
                var typeInfo = LocalDevice.Current.GetDeviceBelongEnumInfo(device);
                var typeInfo = HdlDeviceCommonLogic.Current.GetDeviceBelongEnumInfo(device);
                //按所属ID分组
                if (dic.ContainsKey(typeInfo.BeloneText) == false)
                {
@@ -646,12 +646,12 @@
                    string path1 = string.Empty;
                    string path2 = string.Empty;
                    //获取图片
                    Common.LocalDevice.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
                    HdlDeviceCommonLogic.Current.GetDeviceFunctionTypeMenuIcon(typeInfo, ref path1, ref path2);
                    dic[typeInfo.BeloneText].IconPath = path1;
                    dic[typeInfo.BeloneText].IconPathSelected = path2;
                    dic[typeInfo.BeloneText].Text = typeInfo.BeloneText;
                }
                dic[typeInfo.BeloneText].listDeviceKeys.Add(LocalDevice.Current.GetDeviceMainKeys(device));
                dic[typeInfo.BeloneText].listDeviceKeys.Add(HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device));
            }
            return dic;
        }
@@ -774,6 +774,6 @@
            public List<string> listDeviceKeys = new List<string>();
        }
        #endregion
    }
}
        #endregion
    }
}