gxc
2019-12-20 eb9cf55fc8568cb2d4b4bfac9deb617ce766a7a5
ZigbeeApp/Shared/Phone/Device/Category/Category.cs
@@ -103,6 +103,26 @@
        /// </summary>
        private Button selectFloorBtn;
        /// <summary>
        /// 相同类型的设备列表
        /// </summary>
        private Dictionary<int, List<DeviceUI>> typeDeviceDic;
        /// <summary>
        /// 设备类型的图id
        /// </summary>
        private Dictionary<int, DeviceConcreteType> typeIdDic;
        /// <summary>
        /// dList
        /// </summary>
        private List<DeviceUI> devList;
        /// <summary>
        /// sceneList
        /// </summary>
        private List<SceneUI> sceneList;
        /// <summary>
        /// 当前选中房间
        /// </summary>
        private Common.Room room;
        #endregion
        #region ◆ 接口____________________________
@@ -456,6 +476,8 @@
        /// <param name="selectedBtn">选中那个界面 0--功能 1--场景 2--自动化 </param>
        public void Show(int selectedBtn = 1)
        {
            InitData();
            RemoveAll();
            #region topview
@@ -510,19 +532,21 @@
            midFL.AddChidren(functionSceneAutoBG);
            //场景
            sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left, 34, 150, 68);
            sceneBtn = new ButtonLineForm(CommonFormResouce.X_Left, 34);
            functionSceneAutoBG.AddChidren(sceneBtn);
            sceneBtn.Init();
            sceneBtn.SetTitle(R.MyInternationalizationString.Scence);
            //功能
            functionBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 34, 150, 68);
            functionBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 + 20, 34);
            functionSceneAutoBG.AddChidren(functionBtn);
            functionBtn.Init();
            functionBtn.SetTitle(R.MyInternationalizationString.Function);
            functionBtn.X = sceneBtn.Right;
            //自动化
            automationBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 * 2 + 20+50, 34, 150, 68);
            automationBtn = new ButtonLineForm(CommonFormResouce.X_Left + 150 * 2 + 20+50, 34);
            automationBtn.Init();
            automationBtn.SetTitle(R.MyInternationalizationString.Automation);
            automationBtn.X = functionBtn.Right;
            //隐藏自动化
            if (UserCenter.UserCenterResourse.UserInfo.AuthorityNo != 3)
            {
@@ -537,6 +561,8 @@
                Gravity = Gravity.CenterVertical,
                TextAlignment = TextAlignment.CenterRight,
                TextColor = ZigbeeColor.Current.GXCTextBlackColor,
                TextSize=14,
                IsBold=true
            };
            selectFloorBtn = new Button()
@@ -583,6 +609,7 @@
            #endregion
            //绑定按钮事件
            BindEvent();
        }
        #endregion
@@ -756,6 +783,38 @@
            }
        }
        /// <summary>
        /// InitData
        /// </summary>
        private void InitData()
        {
            typeDeviceDic = new Dictionary<int, List<DeviceUI>> { };
            typeIdDic = new Dictionary<int, DeviceConcreteType> { };
        }
        /// <summary>
        /// RefreshData
        /// </summary>
        private void RefreshData(Common.Room room)
        {
            devList = room.DeviceUIList;
            sceneList = room.SceneUIList;
            var sameDevList = new List<DeviceUI> { };
            typeDeviceDic.Clear();
            typeIdDic.Clear();
            foreach (var device in devList)
            {
                var info = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { device.CommonDevice });
                if(info.BeloneType== DeviceBeloneType.A干接点 || info.BeloneType==DeviceBeloneType.A中继器)
                {
                    continue;
                }
                sameDevList.Add(device);
                typeDeviceDic[info.BeloneTextId] = sameDevList;
                typeIdDic[info.BeloneTextId] = info.ConcreteType;
            }
        }
        #endregion
        #region ◆ 功能____________________________
@@ -802,41 +861,95 @@
        /// <param name="room"></param>
        private void RefreshFunction(Common.Room room)
        {
            RefreshData(room);
            //移除监听
            RemoveAllUpdateControlDeviceStatuAction();
            functionSceneBodyView.RemoveAll();
            if (room.DeviceUIList.Count == 0)
            if (typeDeviceDic.Count == 0)
            {
                ShowNoFunctionTip();
            }
            else
            {
                var functionTypeView1 = new FrameLayout
                {
                    X = Application.GetRealWidth(CommonFormResouce.X_Left),
                    Height = Application.GetRealHeight(160),
                    Width = Application.GetRealWidth(1028),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                };
                functionSceneBodyView.AddChidren(functionTypeView1);
                functionTypeView1.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft);
                var functionTypeView2 = new FrameLayout
                {
                    X = Application.GetRealWidth(CommonFormResouce.X_Left),
                    Y = Application.GetRealHeight(150),
                    Height = Application.GetRealHeight(279 - 150),
                    Width = Application.GetRealWidth(1028),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                };
                functionSceneBodyView.AddChidren(functionTypeView2);
                functionTypeView2.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerBottomLeft);
                functionTypeScrowView = new HorizontalScrolViewLayout
                {
                    X = Application.GetRealWidth(CommonFormResouce.X_Left),
                    Height = Application.GetRealHeight(279),
                    Width = Application.GetRealWidth(1028),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                };
                functionSceneBodyView.AddChidren(functionTypeScrowView);
                //functionSceneBodyView.SetCornerWithSameRadius(Application.GetRealHeight(50), HDLUtils.RectCornerBottomLeft);
                deviceListScrolView = new VerticalScrolViewLayout
                {
                    X = Application.GetRealWidth(CommonFormResouce.X_Left),
                    Y = Application.GetRealHeight(35+275),
                    Width = Application.GetRealWidth(1028),
                    Height = Application.GetRealHeight(938) - 1,
                    Height = Application.GetRealHeight(939),
                    BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor
                };
                functionSceneBodyView.AddChidren(deviceListScrolView);
                //deviceListScrolView.SetCornerWithSameRadius(Application.GetRealHeight(50), HDLUtils.RectCornerTopLeft);
                deviceListScrolView.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft);
                tempFunctionTypeBtn = new FunctionButton();
                tempFunctionTypeBtn.Init("","");
                EventHandler<MouseEventArgs> ShowSameTypeFunction = (object typeSender, MouseEventArgs mouseEventArgs) =>
                foreach (var deviceType in typeIdDic)
                {
                    typeRowLayout = new FrameLayout()
                    {
                        Width = Application.GetRealWidth(220),
                    };
                    functionTypeScrowView.AddChidren(typeRowLayout);
                    functionTypeIMG = new FunctionButton()
                    {
                        Tag = deviceType.Key
                    };
                    string imgPath = string.Empty;
                    string imgSeletedPath = string.Empty;
                    Common.LocalDevice.Current.GetDeviceBeloneIcon(deviceType.Value, ref imgPath, ref imgSeletedPath);
                    functionTypeIMG.Init(imgPath, imgSeletedPath);
                    functionTypeIMG.SetTitle(deviceType.Key);
                    typeRowLayout.AddChidren(functionTypeIMG);
                    functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
                    if (typeRowLayout.ChildrenCount == 1)
                    {
                        ShowSameTypeFunction(functionTypeIMG.ImageBtn, null);
                    }
                }
            }
        }
        /// <summary>
        /// 显示相同类型的功能
        /// </summary>
        /// <param name="typeSender">typeSender.</param>
        /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param>
        private void ShowSameTypeFunction(object typeSender, MouseEventArgs mouseEventArgs)
                {
                    tempFunctionTypeBtn.IsSelected = false;
                    tempFunctionTypeBtn = (typeSender as Button).Parent as FunctionButton;
@@ -845,20 +958,8 @@
                    deviceListScrolView.RemoveAll();
                    var sameTypeList = new List<DeviceUI> { };
                    foreach (var devieceUI in room.DeviceUIList)
                    {
                        if (devieceUI == null || devieceUI.CommonDevice == null)
                        {
                            continue;
                        }
                        if (devieceUI.CommonDevice.Type.ToString() == (typeSender as Button).Tag.ToString())
                        {
                            if (!sameTypeList.Contains(devieceUI))
                            {
                                sameTypeList.Add(devieceUI);
                            }
                        }
                    }
            sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())];
                    for (int i=0;i<sameTypeList.Count;i++)
                    {
                        var deviceUI = sameTypeList[i];
@@ -1505,33 +1606,6 @@
                        })
                        { IsBackground=true}.Start();
                    }
                };
                foreach (var deviceType in Common.Room.GetdeviceTypes(room))
                {
                    typeRowLayout = new FrameLayout()
                    {
                        Width = Application.GetRealWidth(CommonPage.AppRealWidth / 5),
                        Tag = deviceType
                    };
                    functionTypeScrowView.AddChidren(typeRowLayout);
                    functionTypeIMG = new FunctionButton()
                    {
                        Tag = deviceType
                    };
                    functionTypeIMG.Init(DeviceUI.GetDeviceTypeUnSelectedImagePath(deviceType), DeviceUI.GetDeviceTypeUnSelectedImagePath(deviceType));
                    functionTypeIMG.SetTitle(DeviceUI.GetDeviceTypeName(deviceType));
                    typeRowLayout.AddChidren(functionTypeIMG);
                    functionTypeIMG.ClickBtn.MouseUpEventHandler += ShowSameTypeFunction;
                    if (deviceType == room.DeviceUIList[0].CommonDevice.Type)
                    {
                        ShowSameTypeFunction(functionTypeIMG.ImageBtn, null);
                    }
                }
            }
        }
        /// <summary>
@@ -1587,6 +1661,7 @@
                if (room.IsLove)
                {
                    roomBtn.IsSelected = true;
                    this.room = room;
                    curBtn = roomBtn;
                    if(sceneBtn.IsSelected)
@@ -1608,6 +1683,7 @@
                    (sender as Button).IsSelected = true;
                    curBtn.IsSelected = false;
                    curBtn = sender as Button;
                    this.room = room;
                    if (sceneBtn.IsSelected)
                    {
                        RefreshScene(room);
@@ -1618,7 +1694,6 @@
                    }
                };
            }
        }
        #endregion