From c47c3ec2488961b3a006aaebcb03dba582f8b19b Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期四, 12 三月 2020 17:08:42 +0800 Subject: [PATCH] 2020-03-12-1 --- ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs | 125 ++++++++++++++++++++++++++++++----------- 1 files changed, 92 insertions(+), 33 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs b/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs index b0b9fc2..8779c91 100755 --- a/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs +++ b/ZigbeeApp/Shared/Phone/Device/Category/SelectFloor.cs @@ -8,23 +8,35 @@ { public Action<string> FloorAction; + /// <summary> + /// 鏄惁鍒囨崲涓哄綋鍓嶆ゼ灞� + /// </summary> + public bool changeFloor = true; + /// <summary> + /// 褰撳墠浼犺繃鏉ョ殑floorid + /// </summary> + public string CurFloorId = string.Empty; - public bool changeFloor; + Dialog dialogBackground; /// <summary> /// Init /// </summary> - public void Init(int x,int y,CommonForm.Direction direction=CommonForm.Direction.Left) + public void Init(int x, int y, CommonForm.Direction direction = CommonForm.Direction.Left) { - var dialog = new FrameLayout() + dialogBackground = new Dialog { BackgroundColor = ZigbeeColor.Current.GXCDailogBackGroundColor }; - AddChidren(dialog); + dialogBackground.Show(); + var dialog = new FrameLayout() + { + }; + dialogBackground.AddChidren(dialog); dialog.MouseUpEventHandler += (sender, e) => { - RemoveFromParent(); + RemoveView(); }; var bg = new Button @@ -32,33 +44,30 @@ X = Application.GetRealWidth(x), Y = Application.GetRealHeight(y), Width = Application.GetMinRealAverage(449), - Height = Application.GetMinRealAverage(783), - UnSelectedImagePath="Item/SelectFloor_Left.png" + Height = Application.GetMinRealAverage(773), + UnSelectedImagePath = "Floor/SelectFloor_Left_4.png" }; dialog.AddChidren(bg); - if (direction == CommonForm.Direction.Right) - { - bg.UnSelectedImagePath = "Item/SelectFloor_Right.png"; - } var backgroundFL = new FrameLayout { - X = Application.GetRealWidth(x+10), - Y = Application.GetRealHeight(y+23), - Width = Application.GetMinRealAverage(449-20), - Height = Application.GetMinRealAverage(783-23-10), - BackgroundColor = ZigbeeColor.Current.GXCBackgroundColor, + X = Application.GetRealWidth(x), + Y = Application.GetRealHeight(y + 23), + Width = Application.GetMinRealAverage(449), + Height = Application.GetMinRealAverage(773 - 23) }; dialog.AddChidren(backgroundFL); var tip = new Button { X = Application.GetRealWidth(80), - Width = Application.GetRealWidth(350), - Height = Application.GetRealHeight(150), + Width = Application.GetMinRealAverage(350), + Height = Application.GetMinRealAverage(150), TextColor = ZigbeeColor.Current.GXCTextBlackColor, TextAlignment = TextAlignment.CenterLeft, - TextID = R.MyInternationalizationString.SelectFloor + TextID = R.MyInternationalizationString.SelectFloor, + TextSize = 14, + IsBold = true }; backgroundFL.AddChidren(tip); @@ -66,12 +75,40 @@ { Y = tip.Bottom, Width = Application.GetMinRealAverage(449), - Height = Application.GetMinRealAverage(600) + Height = Application.GetMinRealAverage(600), + VerticalScrollBarEnabled = false }; backgroundFL.AddChidren(floorLayout); - if (Config.Instance.Home.FloorDics.Count > 0) + var floorCount = Config.Instance.Home.FloorDics.Count; + + if (floorCount > 0) { + string directStr = string.Empty; + if (direction == CommonForm.Direction.Right) + { + directStr = "Right"; + } + else + { + directStr = "Left"; + } + + if (floorCount > 5) + { + bg.UnSelectedImagePath = $"Floor/SelectFloor_{directStr}_5.png"; + bg.Height = Application.GetMinRealAverage(150*6+23); + backgroundFL.Height = Application.GetMinRealAverage(150 * 6); + floorLayout.Height = Application.GetMinRealAverage(150 * 5); + } + else + { + bg.UnSelectedImagePath = $"Floor/SelectFloor_{directStr}_{floorCount}.png"; + bg.Height = Application.GetMinRealAverage(150 * (floorCount + 1)+23); + backgroundFL.Height = Application.GetMinRealAverage(150 * (floorCount + 1)); + floorLayout.Height = Application.GetMinRealAverage(150 * floorCount); + } + foreach (var floor in Config.Instance.Home.FloorDics) { AddFloor(floorLayout, floor); @@ -83,19 +120,31 @@ /// AddFloor /// </summary> /// <param name="verticalScrolView"></param> - private void AddFloor(VerticalScrolViewLayout verticalScrolView, KeyValuePair<string, string> floor) + private void AddFloor(VerticalScrolViewLayout verticalScrolView, KeyValuePair<string, string> floor,bool isLast=false) { var frow = new CommonForm.LeftIconButtonRow(449, 150); + frow.Width = Application.GetMinRealAverage(449); + frow.Height = Application.GetMinRealAverage(150); frow.Tag = floor.Key; frow.Init("Floor/Floor.png", "Floor/FloorSelected.png", floor.Value); verticalScrolView.AddChidren(frow); - if (Config.Instance.Home.CurrentFloorId == floor.Key) + + if (string.IsNullOrEmpty(CurFloorId)) { - frow.IsSelected = true; + if (Config.Instance.Home.CurrentFloorId == floor.Key) + { + frow.IsSelected = true; + } + } + else + { + if (CurFloorId == floor.Key) + { + frow.IsSelected = true; + } } - frow.IconButton.MouseUpEventHandler += SelectFloor_MouseUpEvent; - frow.TitleButton.MouseUpEventHandler += SelectFloor_MouseUpEvent; + frow.ButtonClickEvent += SelectFloor_MouseUpEvent; } /// <summary> @@ -103,16 +152,26 @@ /// </summary> /// <param name="sender"></param> /// <param name="mouseEventArgs"></param> - private void SelectFloor_MouseUpEvent(object sender,MouseEventArgs mouseEventArgs) + private void SelectFloor_MouseUpEvent(object sender, MouseEventArgs mouseEventArgs) { - ((sender as Button).Parent as CommonForm.LeftIconButtonRow).IsSelected = true; - if(changeFloor) + (sender as CommonForm.LeftIconButtonRow).IsSelected = true; + if (changeFloor) { - Config.Instance.Home.CurrentFloorId = (sender as Button).Tag.ToString(); - Config.Instance.Home.Save(); + Config.Instance.Home.CurrentFloorId = (sender as CommonForm.LeftIconButtonRow).Tag.ToString(); + Config.Instance.Home.Save(false); + UserCenter.HdlRoomLogic.Current.RefreshRoomListView(); } - - FloorAction?.Invoke((sender as Button).Tag.ToString()); + RemoveView(); + FloorAction?.Invoke((sender as CommonForm.LeftIconButtonRow).Tag.ToString()); + + } + + /// <summary> + /// RemoveView + /// </summary> + private void RemoveView() + { + dialogBackground.Close(); RemoveFromParent(); } } -- Gitblit v1.8.0