| | |
| | | /// </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 = 0, int radius = 0) |
| | | public CornerFramLayout(int width, int height, int radius = 0) |
| | | { |
| | | this.BackgroundColor = MusicColor.WhiteColor; |
| | | this.Width = Application.GetRealWidth(width); |
| | | this.Height = Application.GetRealHeight(height); |
| | | this.Radius = (uint)Application.GetRealHeight(radius); |
| | | this.mRowNumber = rowNumber; |
| | | |
| | | |
| | | } |
| | |
| | | |
| | | /// <summary> |
| | | /// 动态加载按键界面 |
| | | /// (注意:mRowNumber!=0) |
| | | /// </summary> |
| | | public void LoadButtonPage() |
| | | /// <param name="mRowNumber">一行多少个元素</param> |
| | | public void LoadButtonPage(int mRowNumber) |
| | | { |
| | | if (this.mRowNumber == 0) |
| | | if (mRowNumber == 0) |
| | | { |
| | | return; |
| | | } |
| | | this.mRowNumber = mRowNumber; |
| | | int line = 0; |
| | | int xCount = 0; |
| | | for (int i = 1; i <= this.mList.Count; i++) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | ///动态加载数字按键界面 |
| | | /// </summary> |
| | | public void LoadNumberButtonPage() |
| | | { |
| | | int currnetheightValue = 0; |
| | | int currnetWidthValue = 0; |
| | | int heightMaxValue = 84; |
| | | int widthMaxValue = 78; |
| | | //获取相对一个纬度值 |
| | | int heightDimensionValue = this.Height - Application.GetRealHeight(this.topMargin) - Application.GetRealHeight(this.bottomMargin) - Application.GetRealHeight(heightMaxValue / 2); |
| | | int widthDimensionValue = this.Width - Application.GetRealWidth(this.leftMargin) - Application.GetRealWidth(this.rightMargin) - Application.GetRealHeight(widthMaxValue / 2); |
| | | for (int i = 1; i <= this.GetNumberTextList().Count; i++) |
| | | { |
| | | var d = this.GetNumberTextList()[i - 1]; |
| | | Button button = new Button |
| | | { |
| | | Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue), |
| | | X = Application.GetRealWidth(this.leftMargin) + Application.GetRealWidth(currnetWidthValue), |
| | | Width = Application.GetRealWidth(widthMaxValue), |
| | | Height = Application.GetRealHeight(heightMaxValue), |
| | | Text = d, |
| | | TextSize = TextSize.Text20, |
| | | TextColor = MusicColor.TextColor, |
| | | TextAlignment = TextAlignment.Center, |
| | | IsBold = true, |
| | | Tag = d, |
| | | BackgroundColor = MusicColor.WhiteColor, |
| | | SelectedBackgroundColor = 0xff454635, |
| | | }; |
| | | this.AddChidren(button); |
| | | |
| | | currnetWidthValue += widthMaxValue; |
| | | if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue)) |
| | | { |
| | | currnetheightValue += heightMaxValue; |
| | | currnetWidthValue = 0; |
| | | } |
| | | button.MouseDownEventHandler += (sen, e) => |
| | | { |
| | | if (button.Tag == null || string.IsNullOrEmpty(button.Tag.ToString())) |
| | | { |
| | | return; |
| | | } |
| | | button.IsSelected = true; |
| | | selectAction?.Invoke(button.Tag.ToString()); |
| | | }; |
| | | button.MouseUpEventHandler += (sen, e) => |
| | | { |
| | | button.IsSelected = false; |
| | | }; |
| | | |
| | | //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) |
| | | //{ |
| | | // selectAction?.Invoke((int)buttonFram.Tag); |
| | | //} |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 动态加载图片界面 |
| | | /// </summary> |
| | | public void LoadImagePage() |
| | | { |
| | | if (this.mRowNumber == 0) |
| | | int currnetheightValue = 0; |
| | | int currnetWidthValue = 0; |
| | | int heightMaxValue = ImageFramlayout.heightFrameLayout; |
| | | int widthMaxValue = ImageFramlayout.widthFrameLayout; |
| | | //获取相对一个纬度值 |
| | | int heightDimensionValue = this.Height - Application.GetRealHeight(this.topMargin) - Application.GetRealHeight(this.bottomMargin) - Application.GetRealHeight(heightMaxValue / 2); |
| | | int widthDimensionValue = this.Width - Application.GetRealWidth(this.leftMargin) - Application.GetRealWidth(this.rightMargin) - Application.GetRealHeight(widthMaxValue / 2); |
| | | for (int i = 1; i <= this.mList.Count; i++) |
| | | { |
| | | var d = this.mList[i - 1]; |
| | | ImageFramlayout imageFram = new ImageFramlayout(); |
| | | imageFram.AddView(this); |
| | | imageFram.Tag = d; |
| | | imageFram.Y = Application.GetRealHeight(this.topMargin) + Application.GetRealHeight(currnetheightValue); |
| | | imageFram.X = Application.GetRealWidth(currnetWidthValue); |
| | | imageFram.btnName.Text = d; |
| | | currnetWidthValue += (widthMaxValue + 8);//8是隔间值 |
| | | if (widthDimensionValue < Application.GetRealWidth(currnetWidthValue)) |
| | | { |
| | | currnetheightValue += (heightMaxValue + 20);//20是隔间值 |
| | | currnetWidthValue = 0; |
| | | } |
| | | |
| | | imageFram.SetClickListener((fl) => |
| | | { |
| | | if (imageFram.Tag != null) |
| | | { |
| | | selectAction?.Invoke(imageFram.Tag.ToString()); |
| | | } |
| | | }); |
| | | //if (CurrnetSelectIndex != -1 && CurrnetSelectIndex == i) |
| | | //{ |
| | | // selectAction?.Invoke((int)imageFram.Tag); |
| | | //} |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 动态加载图片界面 |
| | | /// </summary> |
| | | /// <param name="mRowNumber">一行多少个元素</param> |
| | | public void LoadImagePage(int mRowNumber) |
| | | { |
| | | if (mRowNumber == 0) |
| | | { |
| | | return; |
| | | } |
| | | this.mRowNumber = mRowNumber; |
| | | int line = 0; |
| | | int xCount = 0; |
| | | for (int i = 1; i <= this.mList.Count; i++) |
| | |
| | | /// <returns></returns> |
| | | private bool IsLastColumn(int index) |
| | | { |
| | | if (this.mRowNumber == 0 || this.mList == null || this.mList.Count == 0) |
| | | { |
| | | return false; |
| | | } |
| | | int lineCount = this.mList.Count / this.mRowNumber;//得出行数 |
| | | int number = this.mList.Count % this.mRowNumber; |
| | | if (number != 0) |
| | |
| | | |
| | | } |
| | | return false; |
| | | |
| | | } |
| | | /// <summary> |
| | | /// 最后右边那一个 |
| | |
| | | /// <returns></returns> |
| | | private bool IsLastRight(int value) |
| | | { |
| | | if (this.mRowNumber == 0) |
| | | { |
| | | return false; |
| | | } |
| | | if (value % this.mRowNumber == 0) |
| | | { |
| | | return true; |
| | |
| | | |
| | | button.Width = width; |
| | | } |
| | | |
| | | |
| | | |
| | | public List<string> GetNumberTextList() |
| | | { |
| | | return new List<string> |
| | | { |
| | | "1", |
| | | "2", |
| | | "3", |
| | | Language.StringByID(StringId.pindaojia), |
| | | "4", |
| | | "5", |
| | | "6", |
| | | Language.StringByID(StringId.pindaojian), |
| | | "7", |
| | | "8", |
| | | "9", |
| | | "-/--", |
| | | "",//这个是为了占位置 |
| | | "0" |
| | | |
| | | }; |
| | | |
| | | } |
| | | } |
| | | } |