From 9904031f5291daaf56985146bb671f25e18ebbdf Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 02 四月 2020 19:51:31 +0800 Subject: [PATCH] 最新代码 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/RoomDeviceGroupMenuControl.cs | 42 +++++++++++++++++++++++++++++++----------- 1 files changed, 31 insertions(+), 11 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/RoomDeviceGroupMenuControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/RoomDeviceGroupMenuControl.cs index 3412d86..d0599a6 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/RoomDeviceGroupMenuControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/RoomDeviceGroupMenuControl.cs @@ -100,7 +100,8 @@ frameTemp.Width = ControlCommonResourse.XXLeft / 2; scrolContr.AddChidren(frameTemp); - int defultIndex = 0; + var btnTempWidth = new ButtonBase(); + btnTempWidth.TextSize = 12; if (this.dicRoom != null) { //鍒濆鍖栨埧闂存ā寮忕殑鎺т欢 @@ -110,9 +111,11 @@ { //鍒濆鍊� oldSelectKeys = keys; - defultIndex = keys; } - this.DoInitControl(scrolContr, keys, dicRoom[keys].Name); + + //璁$畻瀛楃鐨勭湡瀹炲搴� + btnTempWidth.Text = dicRoom[keys].Name; + this.DoInitControl(scrolContr, keys, dicRoom[keys].Name, btnTempWidth.GetRealWidthByText()); } } else @@ -125,14 +128,15 @@ { //鍒濆鍊� oldSelectKeys = keys; - defultIndex = index; } - this.DoInitControl(scrolContr, keys, Language.StringByID(keys)); + //璁$畻瀛楃鐨勭湡瀹炲搴� + btnTempWidth.Text = Language.StringByID(keys); + this.DoInitControl(scrolContr, keys, btnTempWidth.Text, btnTempWidth.GetRealWidthByText()); index++; } } //璁╂帶浠舵粦鍔ㄥ埌鎸囧畾鐨勭储寮曚綅缃� - scrolContr.ScrollToViewIndex(defultIndex); + scrolContr.ScrollToViewIndex(oldSelectKeys + 1); } /// <summary> @@ -141,14 +145,24 @@ /// <param name="scrolContr">鍒楄〃鎺т欢</param> /// <param name="keys">瀛楀吀鐨勪富閿�</param> /// <param name="text">鏄剧ず鏂囨湰</param> - private void DoInitControl(HorizontalScrolViewLayout scrolContr, int keys, string text) + /// <param name="textWidth">鏂囨湰鐪熷疄瀹藉害</param> + private void DoInitControl(HorizontalScrolViewLayout scrolContr, int keys, string text, int textWidth) { + //甯﹀簳鍥炬帶浠剁殑鏈�灏忓搴� + int minWidth = Application.GetRealWidth(255); + //甯﹀簳鍥炬帶浠剁殑鐪熷疄瀹藉害 <鏂囧瓧鐨勫搴︾殑璁$畻 frameBack.Width - (int)(frameBack.Height * 0.47)> + int realWidth = textWidth + (int)(Application.GetRealHeight(159) * 0.47); + if (realWidth < minWidth) + { + realWidth = minWidth; + } + //甯﹀浘鐗囩殑 var frameBack = new FrameLayoutControl(); frameBack.UseClickStatu = false; frameBack.Gravity = Gravity.Center; frameBack.Height = Application.GetRealHeight(159); - frameBack.Width = Application.GetRealWidth(255); + frameBack.Width = realWidth; if (oldSelectKeys == keys) { frameBack.BackgroundImagePath = "Item/RoomIconBackgroundSelected.png"; @@ -160,7 +174,7 @@ } scrolContr.AddChidren(frameBack); //鏂囧瓧 - var btnText = new NormalViewControl(frameBack.Width - (int)(frameBack.Height * 0.47), frameBack.Height, false); + var btnText = new NormalViewControl(textWidth, frameBack.Height, false); btnText.Gravity = Gravity.CenterHorizontal; btnText.Text = text; btnText.TextSize = 12; @@ -256,10 +270,16 @@ } else if (keys != string.Empty) { + int i = 0; int textId = Convert.ToInt32(keys); - if (dicDevice.ContainsKey(textId) == true) + foreach (int rId in dicDevice.Keys) { - oldSelectKeys = textId; + if (rId == textId) + { + oldSelectKeys = i; + break; + } + i++; } } } -- Gitblit v1.8.0