From 3f6685c77beeb12baf840733fb890860f4c26e7c Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 25 七月 2024 17:25:59 +0800 Subject: [PATCH] 2024年07月25日17:24:45 --- HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs | 102 +++++++++++++++++++++----------------------------- 1 files changed, 43 insertions(+), 59 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs b/HDL_ON/UI/UI2/FuntionControlView/Aks/CommonView/HorizontalFramLayout.cs index 4f09852..76a22bc 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 { @@ -10,49 +11,54 @@ /// </summary> public class HorizontalFramLayout : HorizontalScrolViewLayout { - public HorizontalFramLayout() + /// <summary> + /// + /// </summary> + /// <param name="width">瀹瑰櫒瀹藉害</param> + /// <param name="height">瀹瑰櫒楂樺害</param> + public HorizontalFramLayout(int width, int height) { - this.Height = Application.GetRealHeight(28); + this.Height = Application.GetRealHeight(height); + 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, + SelectedBackgroundColor = MusicColor.MusicTxet14SelectedColor, BackgroundColor = 0x00000000, - Text = mList[i], + Text = mList[i].filterName, TextSize = TextSize.Text14, TextColor = MusicColor.TextColor, - SelectedTextColor = MusicColor.MusicTxet14SelectedColor, + SelectedTextColor = MusicColor.WhiteColor, TextAlignment = TextAlignment.Center, Padding = new Padding(4, 4, 4, 4), Radius = (uint)Application.GetRealHeight(4), - Tag = i, + Tag = filters, + Name = i.ToString(), }; //閲嶆柊璁$畻缁勪欢瀹藉害 @@ -68,70 +74,48 @@ this.AddChidren(btnSpacing); button.MouseDownEventHandler += (sen, e) => { + if (btnSelected.Name == button.Name) + { + //鐐瑰嚮鍚屼竴涓粍浠舵棤鏁� + return; + } 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); + var filtersSelected = (Filters)button.Tag; + + SelectTypeEvent?.Invoke(filtersSelected); }; - 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