From ff423b88a0dc521932305b5bd44b1786d3e42722 Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期四, 10 八月 2023 18:48:02 +0800 Subject: [PATCH] 2023年08月10日18:47:45 --- HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs | 80 ++++++++++++--------------------------- 1 files changed, 25 insertions(+), 55 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs index e9a76cc..d6ffea3 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs @@ -2,6 +2,7 @@ using Shared; using HDL_ON.UI.Music; using System.Collections.Generic; +using HDL_ON.UI.UI2.FuntionControlView.Aks.Entity; namespace HDL_ON.UI.UI2.FuntionControlView.Aks.CommonView { @@ -21,44 +22,42 @@ this.Width = Application.GetRealWidth(width); } - private List<string> mList = new List<string>(); /// <summary> /// 閫夋嫨浜嬩欢 /// </summary> - public Action<int> SelectTypeEvent = null; - - /// <summary> - /// 褰撳墠閫夋嫨鐨勭储寮�(鍐呴儴浣跨敤) - /// </summary> - private int CurrnetSelectIndex = -1; - + public Action<Filters> SelectTypeEvent = null; /// <summary> /// 鍒濆鍖栨帶浠� /// </summary> - public void InitControl() + /// <param name="mList">鏄剧ず鏁版嵁鍒楄〃</param> + /// <param name="defaultIndex">榛樿鍊肩储寮曡寖鍥碵0,mList.count-1],澶т簬鑼冨洿,璇ュ�艰涓烘棤鏁�</param> + public void InitControl(List<Filters> mList, int defaultIndex = -1) { - if (this.mList == null || this.mList.Count == 0) + if (mList == null || mList.Count == 0) { return; } + bool isBool = false; Button btnSelected = new Button(); - for (int i = 0; i < this.mList.Count; i++) + for (int i = 0; i < mList.Count; i++) { + + var filters = mList[i]; Button button = new Button { Height = Application.GetRealHeight(28), Width = Application.GetRealWidth(20), SelectedBackgroundColor = MusicColor.ViewColor, BackgroundColor = 0x00000000, - Text = mList[i], + Text = mList[i].filterName, TextSize = TextSize.Text14, TextColor = MusicColor.TextColor, SelectedTextColor = MusicColor.MusicTxet14SelectedColor, TextAlignment = TextAlignment.Center, Padding = new Padding(4, 4, 4, 4), Radius = (uint)Application.GetRealHeight(4), - Tag = i, + Tag = filters, }; //閲嶆柊璁$畻缁勪欢瀹藉害 @@ -77,67 +76,38 @@ btnSelected.IsSelected = false; button.IsSelected = true; btnSelected = button; - if (button.Tag == null) + if (button.Tag == null || !(button.Tag is Filters)) { return; } - SelectTypeEvent?.Invoke((int)button.Tag); + SelectTypeEvent?.Invoke((Filters)button.Tag); }; - if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) + if (defaultIndex != -1 && defaultIndex == i) { btnSelected.IsSelected = false; button.IsSelected = true; btnSelected = button; - if (button.Tag == null) - { - return; - } - SelectTypeEvent?.Invoke((int)button.Tag); + isBool = true; } } - - - } - - - /// <summary> - /// 璁剧疆鍒濆閫夋嫨(璇峰湪鍒濆鍖栧畬鎴愪箣鍓嶈皟鐢�) - /// </summary> - /// <param name="index">浠庡垪琛�0寮�濮嬭绠楃涓�涓厓绱�,璁剧疆瓒呰繃鍒楄〃鏈�澶�(new List().count-1)鍊艰涓烘棤鏁�</param> - public void SetIndex(int index = -1) - { - if (index == -1) { return; } - this.CurrnetSelectIndex = index; - - } - - /// <summary> - /// 璁剧疆鍒楄〃鏁版嵁(璇峰湪鍒濆鍖栧畬鎴愪箣鍓嶈皟鐢�) - /// </summary> - public void SetList(List<string> list) - { - if (list == null) + if (isBool) { - this.mList = new List<string>(); - } - this.mList = list; + if (defaultIndex < mList.Count) + { + //榛樿绱㈠紩鍥炶皟,鍒濆鍖栨椂鎵ц + SelectTypeEvent?.Invoke(mList[defaultIndex]); + } - } - /// <summary> - /// 娴嬭瘯鏁版嵁 - /// </summary> - public List<string> GetTestData - { - get - { - return new List<string> { "4245725454", "2", "绫诲瀷", "涓浗鐢靛奖", "鍏ㄩ儴绫诲瀷", "绫诲瀷鍙戦�佸湴鍝﹀摝鍝�", "涓浗鐢靛奖鎰熻瀵归厭褰撴瓕", "鍏ㄩ儴绫诲瀷", }; } } + + + /// <summary> /// 鎺т欢鎽ф瘉 /// </summary> -- Gitblit v1.8.0