| | |
| | | /// </summary> |
| | | public class CornerFramLayout : BaseFramLayout |
| | | { |
| | | public const int cornerValue = 17; |
| | | private int topMargin; |
| | | private int leftMargin; |
| | | private int bottomMargin; |
| | | private int rightMargin; |
| | | |
| | | /// <summary> |
| | | /// 一行几个元素 |
| | | /// </summary> |
| | | private int mRowNumber; |
| | | |
| | | private List<int> mList; |
| | | |
| | | public CornerFramLayout(int width, int height) |
| | | public Action<int> selectAction = null; |
| | | /// <summary> |
| | | /// 当前选择的索引(内部使用) |
| | | /// </summary> |
| | | private int CurrnetSelectIndex = -1; |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="width">容器宽度</param> |
| | | /// <param name="height">容器高度</param> |
| | | ///<param name="rowNumber">一行几个元素</param> |
| | | ///<param name="rowNumber">圆角值</param> |
| | | public CornerFramLayout(int width, int height, int rowNumber,int radius=0) |
| | | { |
| | | this.BackgroundColor = MusicColor.WhiteColor; |
| | | this.Width = Application.GetRealWidth(width); |
| | | this.Height = Application.GetRealHeight(height); |
| | | this.Radius = (uint)Application.GetRealHeight(cornerValue); |
| | | this.Radius = (uint)Application.GetRealHeight(radius); |
| | | this.mRowNumber = rowNumber; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 设置边距 |
| | | /// 设置内边距 |
| | | /// </summary> |
| | | /// <param name="top">上边距</param> |
| | | /// <param name="bottom">下边距</param> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置列表数据 |
| | | /// 设置列表数据(请在初始化完成之前调用) |
| | | /// </summary> |
| | | /// <param name="list"></param> |
| | | public void SetList(List<int> list) |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 加载按键界面 |
| | | /// 动态加载按键界面 |
| | | /// </summary> |
| | | /// <param name="rowNumber">一行几个元素</param> |
| | | /// <param name="action">回调</param> |
| | | public void LoadButtonPage(int rowNumber, Action<int> action) |
| | | public void LoadButtonPage() |
| | | { |
| | | if (rowNumber == 0) |
| | | if (this.mRowNumber == 0) |
| | | { |
| | | return; |
| | | } |
| | | this.mRowNumber = rowNumber; |
| | | int line = 0; |
| | | int xCount = 0; |
| | | for (int i = 1; i <= this.mList.Count; i++) |
| | | { |
| | | ButtonFramLayout buttonFram = new ButtonFramLayout(); |
| | | ButtonFramLayout buttonFram = new ButtonFramLayout(); |
| | | this.AddChidren(buttonFram); |
| | | buttonFram.Tag = i - 1; |
| | | buttonFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(ButtonFramLayout.heightFrameLayout * line); |
| | |
| | | buttonFram.GetNameButton().Text = i.ToString(); |
| | | |
| | | xCount++; |
| | | if (i % rowNumber == 0) |
| | | if (i % this.mRowNumber == 0) |
| | | { |
| | | |
| | | line++; |
| | |
| | | } |
| | | buttonFram.SetClickListener((fl, btnIcon, btnName) => |
| | | { |
| | | action.Invoke((int)buttonFram.Tag); |
| | | selectAction?.Invoke((int)buttonFram.Tag); |
| | | }); |
| | | |
| | | //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) |
| | | //{ |
| | | // selectAction?.Invoke((int)buttonFram.Tag); |
| | | //} |
| | | |
| | | |
| | | } |
| | | //this.AdjustRealHeight(this.bottomMargin); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 动态加载图片界面 |
| | | /// </summary> |
| | | public void LoadImagePage() |
| | | { |
| | | if (this.mRowNumber == 0) |
| | | { |
| | | return; |
| | | } |
| | | int line = 0; |
| | | int xCount = 0; |
| | | for (int i = 1; i <= this.mList.Count; i++) |
| | | { |
| | | ImageFramlayout imageFram = new ImageFramlayout(); |
| | | imageFram.AddView(this); |
| | | //this.AddChidren(imageFram); |
| | | imageFram.Tag = i - 1; |
| | | imageFram.Y = Application.GetRealHeight(this.topMargin)+ Application.GetRealHeight((ImageFramlayout.heightFrameLayout + 20) * line); |
| | | imageFram.X = Application.GetRealWidth((ImageFramlayout.widthFrameLayout + 8) * xCount); |
| | | //imageFram.AddImageView(); |
| | | //imageFram.AddScoreButton(); |
| | | //imageFram.AddNameButton(); |
| | | imageFram.btnName.Text = i.ToString(); |
| | | |
| | | xCount++; |
| | | if (i % this.mRowNumber == 0) |
| | | { |
| | | |
| | | line++; |
| | | xCount = 0; |
| | | } |
| | | imageFram.SetClickListener((fl) => |
| | | { |
| | | selectAction?.Invoke((int)imageFram.Tag); |
| | | }); |
| | | |
| | | //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) |
| | | //{ |
| | | // selectAction?.Invoke((int)imageFram.Tag); |
| | | //} |
| | | |
| | | |
| | | } |
| | | } |
| | | /// <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> |