黄学彪
2020-03-06 a5b3c4bae726ef6770d4bfcbf2f4b50a37ed4a15
ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs
@@ -21,19 +21,6 @@
        private TopFrameLayout top;
        private Button selectAllBtn;
        private FrameLayout itemView;
        /// <summary>
        /// low_High
        /// </summary>
        private const int low_High = 127;
        /// <summary>
        /// 功能
        /// </summary>
        private ButtonLineForm functionBtn;
        /// <summary>
        /// 场景
        /// </summary>
        private ButtonLineForm sceneBtn;
        /// <summary>
        /// 中部背景bodyView
        /// </summary>
@@ -61,7 +48,7 @@
        /// <summary>
        /// dList
        /// </summary>
        private List<DeviceUI> devList;
        private List<CommonDevice> devList;
        /// <summary>
        /// sceneList
        /// </summary>
@@ -70,11 +57,15 @@
        /// <summary>
        /// 相同类型的设备列表
        /// </summary>
        private Dictionary<int ,List<DeviceUI>> typeDeviceDic;
        private Dictionary<int ,List<CommonDevice>> typeDeviceDic;
        /// <summary>
        /// 设备类型的图id
        /// </summary>
        private Dictionary<int, DeviceConcreteType> typeIdDic;
        /// <summary>
        /// 当前选择的分支  1:场景 2:功能
        /// </summary>
        private int NowSelectIndex = 1;
        #endregion
@@ -102,7 +93,7 @@
        /// </summary>
        private void InitData()
        {
            typeDeviceDic = new Dictionary<int, List<DeviceUI>> { };
            typeDeviceDic = new Dictionary<int, List<CommonDevice>> { };
            typeIdDic = new Dictionary<int, DeviceConcreteType> { };
            RefreshData();
@@ -113,8 +104,8 @@
        /// </summary>
        private void RefreshData()
        {
            devList = Shared.Common.Room.CurrentRoom.GetUnalloctedDeviceUIs();
            sceneList = Shared.Common.Room.CurrentRoom.GetUnalloctedScenes();
            devList = UserCenter.HdlRoomLogic.Current.GetUnalloctedDevice();
            sceneList = UserCenter.HdlSceneLogic.Current.GetUnalloctedScenes();
            typeDeviceDic.Clear();
            typeIdDic.Clear();
            if (devList == null)
@@ -123,10 +114,10 @@
            }
            foreach (var device in devList)
            {
                var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device?.CommonDevice);
                var info = Common.LocalDevice.Current.GetDeviceBelongEnumInfo(device);
                if (typeDeviceDic.ContainsKey(info.BeloneTextId) == false)
                {
                    var sameDevList = new List<DeviceUI> { };
                    var sameDevList = new List<CommonDevice> { };
                    sameDevList.Add(device);
                    typeDeviceDic[info.BeloneTextId] = sameDevList;
                }
@@ -137,15 +128,6 @@
                typeIdDic[info.BeloneTextId] = info.ConcreteType;
            }
        }
        ///// <summary>
        ///// RefreshView
        ///// </summary>
        //public void RefreshView()
        //{
        //    InitData();
        //    RefreshBodyView();
        //}
        #region Add____________________________________
@@ -177,32 +159,15 @@
            };
            AddChidren(bodyFrameLayout);
            var functionSceneBG = new FrameLayout()
            //场景功能切换控件
            var btnSceneFunctionSwitch = new UserCenter.SceneFunctionSwitchControl();
            btnSceneFunctionSwitch.Y = Application.GetRealHeight(43);
            bodyFrameLayout.AddChidren(btnSceneFunctionSwitch);
            btnSceneFunctionSwitch.SelectTabEvent += (index) =>
            {
                Height = Application.GetRealHeight(low_High),
                BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor
                this.NowSelectIndex = index;
                this.RefreshBodyView();
            };
            bodyFrameLayout.AddChidren(functionSceneBG);
            //场景
            sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left, 43);
            functionSceneBG.AddChidren(sceneBtn);
            sceneBtn.Init();
            sceneBtn.SetTitle(R.MyInternationalizationString.Scence);
            sceneBtn.IsSelected = true;
            //功能
            functionBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 43);
            functionSceneBG.AddChidren(functionBtn);
            functionBtn.Init();
            functionBtn.SetTitle(R.MyInternationalizationString.Function);
            functionBtn.IsSelected = false;
            functionBtn.X = sceneBtn.Right;
            //选择功能分栏
            functionBtn.NameBtn.MouseUpEventHandler += FunctionBtn_MouseUpEventHandler;
            //选择场景分栏
            sceneBtn.NameBtn.MouseUpEventHandler += SceneBtn_MouseUpEventHandler;
            //功能和场景bodyView
            functionSceneBodyView = new FrameLayout()
@@ -213,32 +178,8 @@
            };
            bodyFrameLayout.AddChidren(functionSceneBodyView);
            RefreshBodyView();
        }
        /// <summary>
        /// 选择功能分栏
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void FunctionBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
        {
            functionBtn.IsSelected = true;
            sceneBtn.IsSelected = false;
            RefreshBodyView();
        }
        /// <summary>
        /// 选择场景分栏
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void SceneBtn_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs)
        {
            functionBtn.IsSelected = false;
            sceneBtn.IsSelected = true;
            RefreshBodyView();
            //开始初始化场景功能切换控件
            btnSceneFunctionSwitch.InitControl();
        }
        #endregion
@@ -251,11 +192,11 @@
        {
            functionSceneBodyView.RemoveAll();
            if (functionBtn.IsSelected)
            if (this.NowSelectIndex == 2)
            {
                ShowFunction();
            }
            else if (sceneBtn.IsSelected)
            else if (this.NowSelectIndex == 1)
            {
                ShowScene();
            }
@@ -363,8 +304,8 @@
            deviceListScrolView.RemoveAll();
            var sameTypeList = new List<DeviceUI> { };
            var selectedList = new List<DeviceUI> { };
            var sameTypeList = new List<CommonDevice> { };
            var selectedList = new List<CommonDevice> { };
            sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())];
            foreach (var deviceUI in sameTypeList)
@@ -378,7 +319,7 @@
                var deviceRow = new SelectFunctionView(0, 35);
                deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath);
                deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI.CommonDevice));
                deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI));
                deviceTypeRowLayout.AddChidren(deviceRow);
                EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
@@ -474,7 +415,7 @@
                {
                    foreach (var d in selectedList)
                    {
                        r.AddDevice(d.CommonDevice, true);
                        UserCenter.HdlRoomLogic.Current.AddDevice(r, d, true);
                        deviceListScrolView.RemoveViewByTag(d);
                    }
@@ -539,7 +480,7 @@
            {
                var sceneScrolView = new VerticalScrolViewLayout
                {
                    Y = Application.GetRealHeight(22),
                    Y = Application.GetRealHeight(81),
                    Height=Application.GetRealHeight(1405-22)
                };
                functionSceneBodyView.AddChidren(sceneScrolView);
@@ -548,7 +489,7 @@
                    var sceneFL = new FrameLayout()
                    {
                        Width = Application.GetRealWidth(CommonFormResouce.AppRealWidth),
                        Height = Application.GetRealHeight(397 + 58),
                        Height = Application.GetRealHeight(397 + 46),
                        Gravity = Gravity.CenterHorizontal,
                        BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor,
                        Tag = sceneUI,
@@ -559,7 +500,6 @@
                    var sceneImg = new ImageView()
                    {
                        X = Application.GetRealWidth(179),
                        Y = Application.GetRealHeight(58),
                        Width = Application.GetRealWidth(844),
                        Height = Application.GetRealHeight(397),
                        ImagePath = sceneUI.IconPath,
@@ -567,10 +507,16 @@
                    };
                    sceneFL.AddChidren(sceneImg);
                    //阴影
                    var btnShadow = new UserCenter.PicViewControl(sceneImg.Width + Application.GetRealWidth(14 * 2), sceneImg.Height + Application.GetRealHeight(43), false);
                    btnShadow.X = sceneImg.X - Application.GetRealWidth(14);
                    btnShadow.UnSelectedImagePath = "Scene/SceneShadow.png";
                    sceneFL.AddChidren(btnShadow);
                    var selectedBtn = new Button
                    {
                        X = Application.GetRealWidth(919),
                        Y = Application.GetRealHeight(92),
                        Y = Application.GetRealHeight(45),
                        Width = Application.GetMinRealAverage(60),
                        Height = Application.GetMinRealAverage(60),
                        UnSelectedImagePath = "Room/ItemUnSelected.png",
@@ -581,10 +527,11 @@
                    var leftFL = new FrameLayout
                    {
                        X = Application.GetRealWidth(CommonFormResouce.X_Left),
                        Y = Application.GetRealHeight(58 + 58),
                        Y = Application.GetRealHeight(58),
                        Width = Application.GetRealWidth(251),
                        Height = Application.GetRealHeight(282),
                        BackgroundColor = ZigbeeColor.Current.GXCBlackBackgroundColor2
                        BackgroundColor = 0xd6333333,
                        Radius = (uint)Application.GetRealHeight(17)
                    };
                    sceneFL.AddChidren(leftFL);
@@ -705,7 +652,7 @@
                    {
                        foreach (var s in selectedList)
                        {
                            r.AddScene(s);
                            UserCenter.HdlSceneLogic.Current.AddScene(r, s);
                            sceneScrolView.RemoveViewByTag(s);
                        }
                        RefreshData();