From 48ba446936b51fffafa7c3600c0dadc6ac0e8c20 Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期五, 10 七月 2020 10:52:13 +0800 Subject: [PATCH] 2020-07-10-01 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/TopRightMenuControl.cs | 292 ++++++++++++++++++++++++--------------------------------- 1 files changed, 124 insertions(+), 168 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/TopRightMenuControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/TopRightMenuControl.cs index fe4e545..4593695 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/TopRightMenuControl.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/CompoundControls/TopRightMenuControl.cs @@ -5,32 +5,20 @@ namespace Shared.Phone.UserCenter { /// <summary> - /// 鍋氭垚涓�涓瓨鍦ㄤ簬鍙充笂瑙掔殑鑿滃崟鎺т欢 + /// 鍋氭垚涓�涓瓨鍦ㄤ簬鍙充笂瑙掔殑鑿滃崟鎺т欢(闈炴ゼ灞傝彍鍗�,閮藉彲浠ヤ娇鐢�) /// </summary> public class TopRightMenuControl : FrameLayout { #region 鈻� 鍙橀噺澹版槑___________________________ /// <summary> - /// 妗屽竷鎺т欢 + /// 鍒楄〃鎺т欢 /// </summary> - private FrameLayout frameTable = null; + private VerticalListControl listView = null; /// <summary> - /// 涓夎褰㈠浘鏍� + /// 鑳屾櫙瀹瑰櫒鎺т欢 /// </summary> - private PicViewControl btnTriangle = null; - /// <summary> - /// 澶撮儴鍦嗚鎺т欢 - /// </summary> - private NormalViewControl btnTopRadius = null; - /// <summary> - /// 搴曢儴鍦嗚鎺т欢 - /// </summary> - private NormalViewControl btnBottomRadius = null; - /// <summary> - /// 鍓嶅洖閫夋嫨鐨勮 - /// </summary> - private FrameLayoutControl oldRowFrame = null; + private FrameLayout frameBack = null; /// <summary> /// 琛岄珮搴� /// </summary> @@ -38,44 +26,44 @@ /// <summary> /// 琛屽搴� /// </summary> - //private int RowWidth = 449; private int RowWidth = 395; /// <summary> /// 琛屾暟 /// </summary> private int RowCount = 0; - /// <summary> - /// 鑿滃崟璁℃暟 - /// </summary> - private int menuCount = 0; - /// <summary> - /// 鍦嗚搴� - /// </summary> - private int tableRadius = Application.GetMinRealAverage(12); #endregion #region 鈻� 鍒濆鍖朹____________________________ /// <summary> - /// 鍋氭垚涓�涓瓨鍦ㄤ簬鍙充笂瑙掔殑鑿滃崟鎺т欢 + /// 鍋氭垚涓�涓瓨鍦ㄤ簬鍙充笂瑙掔殑鑿滃崟鎺т欢(闈炴ゼ灞傝彍鍗�,閮藉彲浠ヤ娇鐢�) /// </summary> - /// <param name="frame">鐖跺鍣ㄦ帶浠�</param> - /// <param name="i_RowCount">涓�鍏辨湁鍑犺</param> - /// <param name="i_width">杩欎釜鑿滃崟鏈夊瀹�</param> - public TopRightMenuControl(FrameLayout frame, int i_RowCount, int i_width = 395) + /// <param name="i_RowCount">涓�鍏辨湁鍑犺(涓嶅惈鏍囬)</param> + /// <param name="i_widthType">杩欎釜鑿滃崟鐨勫搴︽ā寮�,鐩墠鍙敮鎸� + /// <para>1: 395瀹藉害</para> + /// <para>2: 449瀹藉害</para> + /// </param> + /// <param name="titleText">鏍囬鏂囨湰(濡傛灉涓嶄负绌�,鑿滃崟妯″紡鍙樻洿涓烘嫢鏈夋爣棰樼殑妯″紡)</param> + public TopRightMenuControl(int i_RowCount, int i_widthType, string titleText = null) { this.RowCount = i_RowCount; - this.RowWidth = i_width; + if (i_widthType == 1) + { + this.RowWidth = 395; + } + else if (i_widthType == 2) + { + this.RowWidth = 449; + } //鍒濆鍖栫敾闈㈢殑鎺т欢 - this.InitFormControl(frame); + this.InitFormControl(titleText, i_widthType); } /// <summary> /// 鍒濆鍖栫敾闈㈢殑鎺т欢 /// </summary> - /// <param name="frame">鐖跺鍣ㄦ帶浠�</param> - private void InitFormControl(FrameLayout frame) + private void InitFormControl(string titleText, int i_widthType) { this.BackgroundColor = UserCenterColor.Current.DialogBackColor; this.MouseUpEventHandler += (sender2, e2) => @@ -83,43 +71,59 @@ //鍏抽棴鑷韩 this.RemoveFromParent(); }; + var frame = (FrameLayout)UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1); frame.AddChidren(this); - //妗屽竷 - this.frameTable = new FrameLayout(); - //frameTable.X = Application.GetRealWidth(596); - //frameTable.Y = Application.GetRealHeight(184); - frameTable.X = Application.GetRealWidth(662 - (RowWidth - 395)); - frameTable.Y = Application.GetRealHeight(158 + 15 + 1); - frameTable.Width = Application.GetRealWidth(RowWidth); - frameTable.Height = Application.GetRealHeight(RowHeight * this.RowCount) + (this.RowCount - 1) * ControlCommonResourse.BottomLineHeight; - frameTable.BackgroundColor = UserCenterColor.Current.White; - frameTable.Radius = (uint)tableRadius / 2; - this.AddChidren(frameTable); - - //澶撮儴鍦嗚鎺т欢 - btnTopRadius = new NormalViewControl(frameTable.Width, tableRadius * 2, false); - btnTopRadius.Radius = (uint)tableRadius; - //btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround; - frameTable.AddChidren(btnTopRadius); - if (RowCount == 1) + //鏈�澶ф樉绀�5涓� + int rowCount = this.RowCount > 5 ? 5 : this.RowCount; + if (titleText != null) { - btnTopRadius.BackgroundColor = UserCenterColor.Current.White; + //449瀹藉害鐨勬椂鍊欙紝鍗充娇鏄庣粏宸茬粡瓒呰繃浜�5涓紝浣嗘槸杩樻槸鍙互+1鐨�,鍥犱负杩欎釜妯″紡澶氫簡涓�寮犲浘鐗� + if (rowCount < 5 || i_widthType == 2) + { + //鑿滃崟+1 + rowCount++; + } } - //搴曢儴鍦嗚鎺т欢 - btnBottomRadius = new NormalViewControl(frameTable.Width, tableRadius * 2, false); - btnBottomRadius.Y = frameTable.Height - tableRadius * 2; - btnBottomRadius.Radius = (uint)tableRadius; - btnBottomRadius.BackgroundColor = UserCenterColor.Current.White; - frameTable.AddChidren(btnBottomRadius); - //涓夎褰㈠浘鏍� - btnTriangle = new PicViewControl(31, 15); - btnTriangle.X = Application.GetRealWidth(980); - //btnTriangle.Y = Application.GetRealHeight(169); - btnTriangle.Y = Application.GetRealHeight(158); - btnTriangle.UnSelectedImagePath = "Item/UpperTriangle.png"; - this.AddChidren(btnTriangle); + //鑳屾櫙 + this.frameBack = new FrameLayout(); + frameBack.X = Application.GetRealWidth(662 - (RowWidth - 395)); + frameBack.Y = Application.GetRealHeight(161); + frameBack.Width = Application.GetRealWidth(RowWidth); + frameBack.Height = Application.GetRealHeight(RowHeight * rowCount + 16); + frameBack.BackgroundImagePath = "MenuGroud/TopRightMenu" + i_widthType + "_" + rowCount + ".png"; + this.AddChidren(frameBack); + + var frameTable = new FrameLayout(); + frameTable.Y = Application.GetRealHeight(16); + frameTable.Height = Application.GetRealHeight(RowHeight * rowCount); + frameBack.AddChidren(frameTable); + + if (titleText != null) + { + var btnTitle = new NormalViewControl(frameBack.Width - Application.GetRealWidth(81), Application.GetRealHeight(58), false); + btnTitle.X = Application.GetRealWidth(81); + btnTitle.Y = Application.GetRealHeight(58 + 16); + btnTitle.Text = titleText; + frameTable.AddChidren(btnTitle); + } + + //鍒楄〃鎺т欢 + this.listView = new VerticalListControl(); + listView.Radius = (uint)Application.GetRealHeight(17); + if (titleText != null) + { + //鎷ユ湁鏍囬 + listView.Y = Application.GetRealHeight(RowHeight); + listView.Height = frameTable.Height - Application.GetRealHeight(RowHeight); + } + else + { + //娌℃湁鏍囬 + listView.Height = frameTable.Height; + } + frameTable.AddChidren(listView); } #endregion @@ -127,103 +131,73 @@ #region 鈻� 娣诲姞鑿滃崟___________________________ /// <summary> - /// 娣诲姞鑿滃崟琛� + /// 娣诲姞鑿滃崟琛�(UI濂囪懇鍙樻洿浜�,鏆楄壊鍥剧墖涓洪�変腑,榛戣壊鍥剧墖涓洪潪閫変腑) /// </summary> /// <param name="TextValue">鏄剧ず鐨勬枃瀛�</param> - /// <param name="unSelectPic">鍥剧墖</param> - /// <param name="selectPic">鍥剧墖</param> + /// <param name="selectPic">鍥剧墖(鏆楄壊鍥剧墖)</param> + /// <param name="unSelectPic">鍥剧墖(榛戣壊鍥剧墖)</param> /// <param name="action">鍗曞嚮鑿滃崟鎵ц鐨勪簨浠�</param> /// <param name="closeOnClick">鍗曞嚮鐨勬椂鍊欙紝鍏抽棴鑿滃崟</param> - public void AddRowMenu(string TextValue, string unSelectPic, string selectPic, Action action, bool closeOnClick = true) + public void AddRowMenu(string TextValue, string selectPic, string unSelectPic, Action action, bool closeOnClick = true) { - NormalViewControl btnLine = null; - if (menuCount > 0) - { - //鐢荤嚎 - btnLine = new NormalViewControl(Application.GetRealWidth(RowWidth - 81), ControlCommonResourse.BottomLineHeight, false); - btnLine.X = Application.GetRealWidth(81); - btnLine.Y = Application.GetRealHeight(RowHeight * menuCount) + menuCount * ControlCommonResourse.BottomLineHeight; - btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; - frameTable.AddChidren(btnLine); - } - menuCount++; - - var rowFrame = new FrameLayoutControl(); + var rowFrame = new FrameRowControl(); + rowFrame.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft; rowFrame.Height = Application.GetRealHeight(RowHeight); - rowFrame.Name = "Menu" + menuCount; - if (btnLine != null) - { - rowFrame.Y = btnLine.Bottom; - } - if (this.RowCount == 1) - { - //鍙湁涓�涓彍鍗� - rowFrame.Y = tableRadius; - rowFrame.Height = Application.GetRealHeight(RowHeight) - tableRadius * 2; - } - frameTable.AddChidren(rowFrame); + listView.AddChidren(rowFrame); + rowFrame.MainKeys = listView.ChildrenCount.ToString(); + //杩欓噷鐗规畩锛岀Щ闄ゆ帀鑷韩鐨勫崟鍑讳簨浠� + rowFrame.RemoveBaseClickEvent(); //鍥炬爣 - var btnIcon = new IconViewControl(81); - btnIcon.X = Application.GetRealWidth(81); - btnIcon.Gravity = Gravity.CenterVertical; + var btnIcon = rowFrame.AddLeftIcon(81); btnIcon.UnSelectedImagePath = unSelectPic; btnIcon.SelectedImagePath = selectPic; - rowFrame.AddChidren(btnIcon, ChidrenBindMode.BindEventOnly); //鏄剧ず鏂囧瓧 - var btnText = new NormalViewControl(RowWidth - 173, 58, true); + var btnText = rowFrame.AddLeftCaption(TextValue, RowWidth - 173); btnText.X = Application.GetRealWidth(173); - btnText.Text = TextValue; - btnText.Gravity = Gravity.CenterVertical; - rowFrame.AddChidren(btnText, ChidrenBindMode.BindEventOnly); - if (menuCount > 1) + //搴曠嚎 + if (listView.ChildrenCount != this.RowCount) { - btnIcon.IsSelected = false; - btnText.TextColor = UserCenterColor.Current.TextGrayColor1; + var btnLine = rowFrame.AddBottomLine(); + btnLine.X = Application.GetRealWidth(81); } - if (this.RowCount == 1) - { - //濡傛灉鍙湁涓�涓彍鍗� - } - else if (menuCount == 1) - { - //澶氫釜鑿滃崟妯″紡鐨勭涓�涓彍鍗� - rowFrame.Y = tableRadius; - rowFrame.Height -= tableRadius; - btnIcon.Y -= tableRadius / 2; - btnText.Y -= tableRadius / 2; - //绗竴涓彍鍗曢粯璁よ缃负閫夋嫨鐘舵�� - this.SetRowSelectStatu(rowFrame, true); - this.oldRowFrame = rowFrame; - } - else if (menuCount == this.RowCount) - { - //澶氫釜鑿滃崟妯″紡鐨勬渶鍚庝竴涓彍鍗� - rowFrame.Height -= tableRadius; - btnIcon.Y += tableRadius / 2; - btnText.Y += tableRadius / 2; - } + //鍒濆鐘舵�佸叏涓洪潪閫変腑鐘舵�� + this.SetRowSelectStatu(rowFrame, false); - //閫夋嫨鐘舵�� + bool happenMove = false; + //閫夋嫨鐘舵��(閲嶅啓搴曞眰鏁堟灉) rowFrame.SelectStatuEvent += (statu) => { - //false涓烘帶浠惰嚜韬嚜鍔ㄦ墽琛�,杩欓噷涓嶉渶瑕佽繕鍘� + //false涓虹姸鎬佽繕鍘�,浣嗘槸鐘舵�佽繕鍘熸斁鍦ㄩ紶鏍囧脊璧蜂簨浠堕噷闈� if (statu == true) { //璁剧疆涓洪�夋嫨鐘舵�� this.SetRowSelectStatu(rowFrame, true); - this.oldRowFrame = rowFrame; + happenMove = false; } }; - //鎸夐敭鐐瑰嚮 rowFrame.ButtonClickEvent += (sender, e) => { + //璁剧疆涓洪潪閫夋嫨鐘舵�� + this.SetRowSelectStatu(rowFrame, false); + if (closeOnClick == true) { this.RemoveFromParent(); } action?.Invoke(); + }; + + //寮�濮嬭Е鍙戠Щ鍔ㄤ簨浠�(杩欎釜浜嬩欢浼氶绻佺殑瑙﹀彂) + btnIcon.ButtonHappenMoveEvent += () => + { + if (happenMove == false) + { + //璁剧疆涓洪潪閫夋嫨鐘舵�� + this.SetRowSelectStatu(rowFrame, false); + } + happenMove = true; }; } #endregion @@ -235,7 +209,7 @@ /// </summary> /// <param name="frame">琛屾帶浠�</param> /// <param name="select">閫夋嫨鐨勭姸鎬�</param> - private void SetRowSelectStatu(FrameLayoutControl frame, bool select) + private void SetRowSelectStatu(FrameRowControl frame, bool select) { //鍥炬爣 var btnIcon = (IconViewControl)frame.GetChildren(0); @@ -247,48 +221,30 @@ var btnText = (NormalViewControl)frame.GetChildren(1); if (btnText != null) { - //btnText.TextColor = select == true ? UserCenterColor.Current.TextColor3 : UserCenterColor.Current.TextColor1; - btnText.TextColor = select == true ? UserCenterColor.Current.TextColor1 : UserCenterColor.Current.TextGrayColor1; + btnText.TextColor = select == true ? UserCenterColor.Current.TextGrayColor1 : UserCenterColor.Current.TextColor1; + btnText.IsBold = !select; } - //鑳屾櫙鑹� - //frame.BackgroundColor = select == true ? UserCenterColor.Current.BlackBackGround : UserCenterColor.Current.White; + } - if (this.RowCount == 1) - { - //濡傛灉鍙湁涓�涓彍鍗曠殑璇� - //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround; - //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround; - return; - } - //鍓嶅洖閫夋嫨鐨勮彍鍗曚负null,鎴栬�呮槸鐩稿悓鐨勪笢瑗�,鍒欎笉澶勭悊 - if (this.oldRowFrame == null || this.oldRowFrame.Name == frame.Name) - { - return; - } + #endregion - if (frame.Name == "Menu1") - { - //濡傛灉鐐瑰嚮鐨勬槸绗竴涓彍鍗曠殑璇�,鍙橀粦鑹� - //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround; - } - else - { - //鍙樺洖鐧借壊 - //this.btnTopRadius.BackgroundColor = UserCenterColor.Current.White; - } + #region 鈻� 涓�鑸柟娉昣__________________________ - if (frame.Name == "Menu" + this.RowCount) + /// <summary> + /// 閲嶆柊璁剧疆鐧借壊閮ㄥ垎鐨勫潗鏍� + /// </summary> + /// <param name="XX">鐪熷疄鍊�(涓嶆敼鍙樼殑璇濆~-1)</param> + /// <param name="YY">鐪熷疄鍊�(涓嶆敼鍙樼殑璇濆~-1)</param> + public void SetLocation(int XX = -1, int YY = -1) + { + if (XX != -1) { - //濡傛灉鐐瑰嚮鐨勬槸鏈�鍚庝竴涓彍鍗曠殑璇�,鍙橀粦鑹� - //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.BlackBackGround; + frameBack.X = XX; } - else + if (YY != -1) { - //鍙樺洖鐧借壊 - //this.btnBottomRadius.BackgroundColor = UserCenterColor.Current.White; + frameBack.Y = YY; } - //鍓嶅洖閫夋嫨鐨勮杩樺師 - this.SetRowSelectStatu(this.oldRowFrame, false); } #endregion -- Gitblit v1.8.0