From a5b3c4bae726ef6770d4bfcbf2f4b50a37ed4a15 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期五, 06 三月 2020 15:31:36 +0800 Subject: [PATCH] 删除了郭雪城的 DeviceUi 这个类 --- ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs | 398 +++++++++++++++++++++++++++----------------------------- 1 files changed, 193 insertions(+), 205 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs b/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs index 6346226..67b09b3 100755 --- a/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs +++ b/ZigbeeApp/Shared/Phone/Device/Room/UnallocatedRoom.cs @@ -15,27 +15,12 @@ /// bodyFrameLayout /// </summary> private FrameLayout bodyFrameLayout; + /// <summary> + /// top + /// </summary> + private TopFrameLayout top; + private Button selectAllBtn; - private Button addBtn; - - private FrameLayout itemView; - /// <summary> - /// editStatus - /// </summary> - private bool SelectAll; - - /// <summary> - /// low_High - /// </summary> - private const int low_High = 127; - /// <summary> - /// 鍔熻兘 - /// </summary> - private ButtonLineForm functionBtn; - /// <summary> - /// 鍦烘櫙 - /// </summary> - private ButtonLineForm sceneBtn; /// <summary> /// 涓儴鑳屾櫙bodyView /// </summary> @@ -63,7 +48,7 @@ /// <summary> /// dList /// </summary> - private List<DeviceUI> devList; + private List<CommonDevice> devList; /// <summary> /// sceneList /// </summary> @@ -72,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 @@ -93,10 +82,10 @@ /// </summary> public void Show() { + RemoveAll(); InitData(); AddTop(); AddBodyView(); - } /// <summary> @@ -104,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(); @@ -115,16 +104,20 @@ /// </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) + { + return; + } foreach (var device in devList) { - var info = Common.LocalDevice.Current.GetNotHdlMyDeviceEnumInfo(new List<CommonDevice> { 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; } @@ -136,15 +129,6 @@ } } - ///// <summary> - ///// RefreshView - ///// </summary> - //public void RefreshView() - //{ - // InitData(); - // RefreshBodyView(); - //} - #region Add____________________________________ /// <summary> @@ -152,7 +136,7 @@ /// </summary> public void AddTop() { - var top = new TopFrameLayout(); + top = new TopFrameLayout(); AddChidren(top); top.InitTopview(); top.SetTopTitle(R.MyInternationalizationString.Unallocated); @@ -160,21 +144,6 @@ { RemoveFromParent(); }; - - addBtn = new Button() - { - X = Application.GetRealWidth(1080-150-80), - Width = Application.GetRealWidth(150), - Height = Application.GetRealHeight(80), - Gravity = Gravity.CenterVertical, - TextColor = ZigbeeColor.Current.GXCTextBlackColor, - TextSize = CommonFormResouce.TopTitle_TextSize, - TextAlignment = TextAlignment.CenterRight, - TextID = R.MyInternationalizationString.AllSelect - }; - top.topView.AddChidren(addBtn); - - addBtn.MouseUpEventHandler += Edit_MouseUpEventHandler; } /// <summary> @@ -190,97 +159,27 @@ }; AddChidren(bodyFrameLayout); - var functionSceneBG = new FrameLayout() - { - Height = Application.GetRealHeight(low_High), - BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor + //鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + var btnSceneFunctionSwitch = new UserCenter.SceneFunctionSwitchControl(); + btnSceneFunctionSwitch.Y = Application.GetRealHeight(43); + bodyFrameLayout.AddChidren(btnSceneFunctionSwitch); + btnSceneFunctionSwitch.SelectTabEvent += (index) => + { + 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; //鍔熻兘鍜屽満鏅痓odyView functionSceneBodyView = new FrameLayout() { - Y= Application.GetRealHeight(127), + Y = Application.GetRealHeight(127), Height = Application.GetRealHeight(1607), BackgroundColor = ZigbeeColor.Current.GXCGrayBackgroundColor }; 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(); - } - - /// <summary> - /// 缂栬緫 - /// </summary> - /// <param name="sender"></param> - /// <param name="mouseEventArgs"></param> - private void Edit_MouseUpEventHandler(object sender, MouseEventArgs mouseEventArgs) - { - SelectAll = !SelectAll; - if (SelectAll) - { - addBtn.TextID = R.MyInternationalizationString.Cancel; - } - else - { - addBtn.TextID = R.MyInternationalizationString.AllSelect; - } - - if (functionBtn.IsSelected) - { - functionSceneBodyView.RemoveAll(); - ShowFunction(SelectAll); - } - else if (sceneBtn.IsSelected) - { - functionSceneBodyView.RemoveAll(); - ShowScene(SelectAll); - } + //寮�濮嬪垵濮嬪寲鍦烘櫙鍔熻兘鍒囨崲鎺т欢 + btnSceneFunctionSwitch.InitControl(); } #endregion @@ -292,14 +191,14 @@ public void RefreshBodyView() { functionSceneBodyView.RemoveAll(); - SelectAll = false; - if (functionBtn.IsSelected) + + if (this.NowSelectIndex == 2) { - ShowFunction(SelectAll); + ShowFunction(); } - else if (sceneBtn.IsSelected) + else if (this.NowSelectIndex == 1) { - ShowScene(SelectAll); + ShowScene(); } } @@ -309,9 +208,8 @@ /// <summary> /// 鍔熻兘 /// </summary> - public void ShowFunction(bool selectAll) + public void ShowFunction() { - SelectAll = selectAll; if (typeIdDic.Count == 0) { ShowNoFunctionTip(); @@ -348,7 +246,7 @@ Width = Application.GetRealWidth(1028) }; functionSceneBodyView.AddChidren(functionTypeScrowView); - + deviceListScrolView = new VerticalScrolViewLayout { X = Application.GetRealWidth(CommonFormResouce.X_Left), @@ -377,7 +275,7 @@ }; string imgPath=string.Empty; string imgSeletedPath=string.Empty; - Common.LocalDevice.Current.GetDeviceBeloneIcon(deviceType.Value, ref imgPath ,ref imgSeletedPath); + Common.LocalDevice.Current.GetDeviceObjectIcon(deviceType.Value, ref imgPath ,ref imgSeletedPath); functionTypeIMG.Init(imgPath,imgSeletedPath); functionTypeIMG.SetTitle(deviceType.Key); typeRowLayout.AddChidren(functionTypeIMG); @@ -389,6 +287,7 @@ ShowSameTypeFunction(functionTypeIMG.ImageBtn, null); } } + } } @@ -399,21 +298,16 @@ /// <param name="mouseEventArgs">The ${ParameterType} instance containing the event data.</param> private void ShowSameTypeFunction(object typeSender, MouseEventArgs mouseEventArgs) { - //閫夋嫨鍔熻兘--鐩存帴浠庢埧闂寸殑devicelist涓幏鍙� tempFunctionTypeBtn.IsSelected = false; tempFunctionTypeBtn = (typeSender as Button).Parent as FunctionButton; ((typeSender as Button).Parent as FunctionButton).IsSelected = true; 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())]; - if (SelectAll) - { - selectedList.AddRange(sameTypeList); - } foreach (var deviceUI in sameTypeList) { var deviceTypeRowLayout = new FrameLayout() @@ -425,8 +319,7 @@ var deviceRow = new SelectFunctionView(0, 35); deviceRow.Init(deviceUI.IconPath, deviceUI.OnlineIconPath); - deviceRow.SetTitle(deviceUI.CommonDevice.DeviceEpointName); - deviceRow.IsSelected = SelectAll; + deviceRow.SetTitle(Common.LocalDevice.Current.GetDeviceEpointName(deviceUI)); deviceTypeRowLayout.AddChidren(deviceRow); EventHandler<MouseEventArgs> eventHandler = (sender, e) => @@ -448,44 +341,96 @@ } }; deviceRow.ClickBtn.MouseUpEventHandler += eventHandler; - - var addBackground = new Button - { - Y = Application.GetRealHeight(1405), - Width = Application.GetMinRealAverage(1080), - Height = Application.GetMinRealAverage(202), - UnSelectedImagePath = "Room/AddBackground.png" - }; - functionSceneBodyView.AddChidren(addBackground); - var add = new Button - { - Y = Application.GetRealHeight(1428), - Width = Application.GetRealWidth(1034), - Height = Application.GetRealHeight(156), - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, - TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, - Radius = (uint)Application.GetRealHeight(35), - TextID = R.MyInternationalizationString.AddTo, - Gravity = Gravity.CenterHorizontal, - TextSize=17 - }; - functionSceneBodyView.AddChidren(add); - add.MouseUpEventHandler += (sender, e) => - { - var selectZone = new SelectZone(); - AddChidren(selectZone); - selectZone.Init(); - selectZone.ZoneAction = (r) => - { - foreach (var d in selectedList) - { - r.AddDevice(d.CommonDevice,true); - deviceListScrolView.RemoveViewByTag(d); - } - RefreshData(); - }; - }; } + + selectAllBtn?.RemoveFromParent(); + selectAllBtn = new Button() + { + X = Application.GetRealWidth(1080 - 150 - 80), + Width = Application.GetRealWidth(150), + Height = Application.GetRealHeight(80), + Gravity = Gravity.CenterVertical, + TextColor = ZigbeeColor.Current.GXCTextBlackColor, + SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor, + TextSize = CommonFormResouce.TopTitle_TextSize, + TextAlignment = TextAlignment.CenterRight, + TextID = R.MyInternationalizationString.AllSelect + }; + top.topView.AddChidren(selectAllBtn); + selectAllBtn.MouseUpEventHandler += (sender, e) => + { + try + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + for (int i = 0; i < deviceListScrolView.ChildrenCount; i++) + { + var frame = deviceListScrolView.GetChildren(i) as FrameLayout; + (frame.GetChildren(0) as SelectFunctionView).IsSelected = (sender as Button).IsSelected; + } + if ((sender as Button).IsSelected) + { + (sender as Button).TextID = R.MyInternationalizationString.Cancel; + selectedList.Clear(); + selectedList.AddRange(sameTypeList); + } + else + { + (sender as Button).TextID = R.MyInternationalizationString.AllSelect; + selectedList.Clear(); + } + } + catch + { + + } + }; + + var addBackground = new Button + { + Y = Application.GetRealHeight(1405), + Width = Application.GetMinRealAverage(1080), + Height = Application.GetMinRealAverage(202), + UnSelectedImagePath = "Room/AddBackground.png" + }; + functionSceneBodyView.AddChidren(addBackground); + var add = new Button + { + Y = Application.GetRealHeight(1428), + Width = Application.GetRealWidth(1034), + Height = Application.GetRealHeight(156), + BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, + TextColor = ZigbeeColor.Current.GXCTextSelectedColor4, + Radius = (uint)Application.GetRealHeight(35), + TextID = R.MyInternationalizationString.AddTo, + Gravity = Gravity.CenterHorizontal, + TextSize = 17 + }; + functionSceneBodyView.AddChidren(add); + add.MouseUpEventHandler += (sender, e) => + { + var selectZone = new SelectZone(); + selectZone.title = Language.StringByID(R.MyInternationalizationString.AddTo); + selectZone.Init(); + selectZone.ZoneAction += (r) => + { + foreach (var d in selectedList) + { + UserCenter.HdlRoomLogic.Current.AddDevice(r, d, true); + deviceListScrolView.RemoveViewByTag(d); + } + + if (sameTypeList.Count == selectedList.Count) + { + RefreshData(); + RefreshBodyView(); + } + else + { + RefreshData(); + sameTypeList = typeDeviceDic[int.Parse((typeSender as Button).Tag.ToString())]; + } + }; + }; } /// <summary> @@ -524,7 +469,7 @@ /// <summary> /// 閫夋嫨鍦烘櫙--鎵�鏈夋埧闂寸殑鎵�鏈夊満鏅� /// </summary> - public void ShowScene(bool selectAll) + public void ShowScene() { List<SceneUI> selectedList = new List<SceneUI>(); if (sceneList == null || sceneList.Count == 0) @@ -533,13 +478,9 @@ } else { - if (selectAll) - { - selectedList.AddRange(sceneList); - } 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,33 +500,38 @@ var sceneImg = new ImageView() { X = Application.GetRealWidth(179), - Y = Application.GetRealHeight(58), Width = Application.GetRealWidth(844), Height = Application.GetRealHeight(397), ImagePath = sceneUI.IconPath, Radius = (uint)Application.GetRealHeight(17) }; - sceneFL.AddChidren(sceneImg); + 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", SelectedImagePath = "Room/ItemSelected.png", - IsSelected = selectAll }; sceneFL.AddChidren(selectedBtn); 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); @@ -633,6 +579,48 @@ sceneImg.MouseUpEventHandler += eventHandler; } + selectAllBtn?.RemoveFromParent(); + selectAllBtn = new Button() + { + X = Application.GetRealWidth(1080 - 150 - 80), + Width = Application.GetRealWidth(150), + Height = Application.GetRealHeight(80), + Gravity = Gravity.CenterVertical, + TextColor = ZigbeeColor.Current.GXCTextBlackColor, + SelectedTextColor = ZigbeeColor.Current.GXCTextBlackColor, + TextSize = CommonFormResouce.TopTitle_TextSize, + TextAlignment = TextAlignment.CenterRight, + TextID = R.MyInternationalizationString.AllSelect + }; + top.topView.AddChidren(selectAllBtn); + selectAllBtn.MouseUpEventHandler += (sender, e) => + { + try + { + (sender as Button).IsSelected = !(sender as Button).IsSelected; + for (int i = 0; i < sceneScrolView.ChildrenCount; i++) + { + var frame = sceneScrolView.GetChildren(i) as FrameLayout; + (frame.GetChildren(1) as Button).IsSelected = (sender as Button).IsSelected; + } + + if ((sender as Button).IsSelected) + { + (sender as Button).TextID = R.MyInternationalizationString.Cancel; + selectedList.AddRange(sceneList); + } + else + { + (sender as Button).TextID = R.MyInternationalizationString.AllSelect; + selectedList.Clear(); + } + } + catch + { + + } + }; + var addBackground = new Button { Y = Application.GetRealHeight(1405), @@ -658,13 +646,13 @@ add.MouseUpEventHandler += (sender, e) => { var selectZone = new SelectZone(); - CommonPage.Instance.AddChidren(selectZone); + selectZone.title = Language.StringByID(R.MyInternationalizationString.AddTo); selectZone.Init(); - selectZone.ZoneAction = (r) => + selectZone.ZoneAction += (r) => { foreach (var s in selectedList) { - r.AddScene(s); + UserCenter.HdlSceneLogic.Current.AddScene(r, s); sceneScrolView.RemoveViewByTag(s); } RefreshData(); -- Gitblit v1.8.0