| | |
| | | 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 |
| | | { |
| | |
| | | /// </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(), |
| | | }; |
| | | |
| | | //重新计算组件宽度 |
| | |
| | | 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> |