From 9ef48d7b2da7c408b53f73be0f6eef3cbac1c84a Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 19 十一月 2020 10:23:45 +0800 Subject: [PATCH] Evoyo.Home1.1.0120111601_Release --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SceneFunctionSwitchControl.cs | 70 ++++++++++++++++++++++++++--------- 1 files changed, 52 insertions(+), 18 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SceneFunctionSwitchControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SceneFunctionSwitchControl.cs index b503b18..b081b6c 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SceneFunctionSwitchControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/SceneFunctionSwitchControl.cs @@ -8,7 +8,7 @@ /// <para>鍦烘櫙鍜屽姛鑳戒箣闂寸浉浜掑垏鎹㈢殑Tab鎺т欢(瀹屾垚鍒濆鍖栧悗,浼氭牴鎹粯璁ら�夋嫨璋冪敤鍥炶皟鍑芥暟)</para> /// <para>2020.03.10鍙樻洿:瀹冨彉鏇翠负鏂囧瓧鍨嬭彍鍗曟帶浠�</para> /// </summary> - public class SceneFunctionSwitchControl : FrameLayout + public class SceneFunctionSwitchControl : HorizontalScrolViewLayout { #region 鈻� 鍙橀噺澹版槑___________________________ @@ -16,6 +16,10 @@ /// 閫夋嫨浜嬩欢(浠�0寮�濮�) /// </summary> public Action<int> SelectTabEvent = null; + /// <summary> + /// 鍓嶅洖閫夋嫨鐨勭储寮� + /// </summary> + public int OldSelectIndex = 0; private int m_nowSelectIndex = 0; /// <summary> @@ -49,7 +53,6 @@ public SceneFunctionSwitchControl() { this.Height = Application.GetRealHeight(90); - this.Y = Application.GetRealHeight(40); } /// <summary> @@ -60,37 +63,47 @@ public void InitControl(List<string> listTitleText, int rightSpace = 0) { if (listTitleText.Count == 0) { return; } + this.listNameControl.Clear(); + this.listLineControl.Clear(); var btnTemp = new NormalViewControl(10, 10, false); btnTemp.TextSize = 16; //鍋氭垚澶撮儴鑿滃崟鏂囧瓧 - int XX = 0; for (int i = 0; i < listTitleText.Count; i++) { btnTemp.Text = listTitleText[i]; - //寮�濮嬪垵濮嬪寲 - XX = this.InitTitleTextControl(i, listTitleText[i], btnTemp.GetRealWidthByText(), XX); + //娣诲姞鏍囬鎺т欢 + this.AddTitleTextControl(i, listTitleText[i], btnTemp.GetRealWidthByText()); } - //璋冩暣鎺т欢瀹藉害 - this.Width = XX + Application.GetRealWidth(rightSpace); + //娣诲姞鍙宠竟绌虹櫧瀹藉害 + if (rightSpace > 0) + { + //娣诲姞涓�涓棿闅旈棿璺� + var frameSpace = new FrameLayout(); + frameSpace.Width = Application.GetRealWidth(rightSpace); + this.AddChidren(frameSpace); + } //鍥炶皟鏂规硶 this.frameDefult.ButtonClickEvent?.Invoke(null, null); } /// <summary> - /// 鍒濆鍖栨爣棰樻帶浠� + /// 娣诲姞鏍囬鎺т欢 /// </summary> /// <param name="i_index"></param> /// <param name="titleText"></param> - private int InitTitleTextControl(int i_index, string titleText, int realWidth, int XX) + private void AddTitleTextControl(int i_index, string titleText, int realWidth) { + //娣诲姞涓�涓棿闅旈棿璺� + var frameSpace = new FrameLayout(); + frameSpace.Width = Application.GetRealWidth(58); + this.AddChidren(frameSpace); + //鍦烘櫙妗�(鐐瑰嚮鑼冨洿鏈夌偣灏忥紝闇�瑕佹墿澶у畠鐨勭偣鍑昏寖鍥�) var frameBack = new FrameLayoutStatuControl(); frameBack.UseClickStatu = false; - frameBack.Height = Application.GetRealHeight(90); frameBack.Width = realWidth; - frameBack.X = XX + Application.GetRealWidth(58); this.AddChidren(frameBack); //鍚嶇О var btnName = new NormalViewControl(frameBack.Width, Application.GetRealHeight(63), false); @@ -108,7 +121,7 @@ { btnName.TextColor = UserCenterColor.Current.TextGrayColor3; } - frameBack.AddChidren(btnName, ChidrenBindMode.BindEventOnly); + frameBack.AddChidren(btnName, ChidrenBindMode.BindEvent); //娣诲姞缂撳瓨 this.listNameControl.Add(btnName); @@ -118,7 +131,7 @@ btnLine.X = btnName.X + btnName.Width / 2 - Application.GetRealWidth(40) / 2; btnLine.Radius = (uint)Application.GetRealHeight(10) / 2; btnLine.BackgroundColor = UserCenterColor.Current.TextOrangeColor; - frameBack.AddChidren(btnLine, ChidrenBindMode.BindEventOnly); + frameBack.AddChidren(btnLine, ChidrenBindMode.BindEvent); if (m_nowSelectIndex != i_index) { btnLine.Visible = false; @@ -134,6 +147,7 @@ //鎵嬪姩鐐瑰嚮鐨勬墠澶勭悊 return; } + this.OldSelectIndex = this.m_nowSelectIndex; this.m_nowSelectIndex = i_index; //褰撳墠鏂囧瓧鍙樿壊 btnName.TextSize = 16; @@ -155,9 +169,6 @@ } this.SelectTabEvent?.Invoke(i_index); }; - - //杩斿洖杩欎釜鎺т欢鐨勫彸鍧愭爣 - return frameBack.Right; } #endregion @@ -170,8 +181,21 @@ public override void RemoveFromParent() { this.SelectTabEvent = null; + if (this.Parent != null) + { + base.RemoveFromParent(); + } + } - base.RemoveFromParent(); + /// <summary> + /// 鈽嗏槅绉婚櫎鍏ㄩ儴鎺т欢鈽嗏槅 + /// </summary> + public override void RemoveAll() + { + if (this.Parent != null) + { + base.RemoveAll(); + } } #endregion @@ -179,11 +203,21 @@ #region 鈻� 涓�鑸柟娉昣__________________________ /// <summary> - /// 璁剧疆鍒濆閫夋嫨(璇峰湪鍒濆鍖栧畬鎴愪箣鍓嶈皟鐢�) + /// 璁剧疆鍒濆閫夋嫨 /// </summary> /// <param name="index">浠�0寮�濮�</param> public void SetDefultIndex(int index) { + if (frameDefult != null && frameDefult.Parent != null) + { + if (index < this.listNameControl.Count) + { + this.ScrollToViewIndex(index * 2 + 1); + //璋冪敤鐐瑰嚮浜嬩欢 + this.listNameControl[index].ButtonClickEvent(null, null); + } + return; + } this.m_nowSelectIndex = index; } -- Gitblit v1.8.0