old mode 100755
new mode 100644
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | | /// <summary>
|
| | | /// 底部弹窗项目选择界面(列表数尽可能别弄那么多)
|
| | | /// </summary>
|
| | | public class BottomItemSelectForm : DialogCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 完成选择的事件(参数为选择的是列表的第几行,从0开始)
|
| | | /// </summary>
|
| | | public Action<int> FinishSelectEvent = null;
|
| | | /// <summary>
|
| | | /// 前回选择的控件
|
| | | /// </summary>
|
| | | private NormalSelectControl oldSelectContr = null;
|
| | | /// <summary>
|
| | | /// 选择取消(不是左上角),并且按下确定键时,是否调用回调函数(调用时传递的参数是 -1,默认不回调)
|
| | | /// </summary>
|
| | | public bool CancelCallEvent = false;
|
| | | /// <summary>
|
| | | /// 选择的行能否取消
|
| | | /// </summary>
|
| | | public bool SelectRowCanCancel = true;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_topText">头部标题</param>
|
| | | /// <param name="i_listText">需要显示的列表信息(列表数尽可能别弄那么多)</param> |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | { |
| | | /// <summary> |
| | | /// 底部弹窗项目选择界面 |
| | | /// </summary> |
| | | public class BottomItemSelectForm : DialogCommonForm |
| | | { |
| | | #region ■ 变量声明___________________________ |
| | | |
| | | /// <summary> |
| | | /// <para>完成选择的事件(参数为选择的是列表的第几行,从0开始)</para> |
| | | /// <para>当CancelCallEvent=true时,点击确认按钮时,参数为:-1</para> |
| | | /// </summary> |
| | | public Action<int> FinishSelectEvent = null; |
| | | /// <summary> |
| | | /// 前回选择的控件 |
| | | /// </summary> |
| | | private NormalSelectControl oldSelectContr = null; |
| | | /// <summary> |
| | | /// 选择取消(不是左下角),并且按下确定键时,是否调用回调函数(调用时传递的参数是 -1,默认不回调) |
| | | /// </summary> |
| | | public bool CancelCallEvent = false; |
| | | /// <summary> |
| | | /// 选择的行能否取消(默认可以取消) |
| | | /// </summary> |
| | | public bool SelectRowCanCancel = true; |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 初始化_____________________________ |
| | | |
| | | /// <summary> |
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建) |
| | | /// </summary> |
| | | /// <param name="i_topText">头部标题</param> |
| | | /// <param name="i_listText">需要显示的列表信息</param> |
| | | /// <param name="i_listBottomText">需要显示的列表信息(底部),如果只是单行显示,则此值设置为null(如果不为null,但是索引所指向的值为null,则该行强制单行显示)</param> |
| | | /// <param name="i_selectNo">设置哪个文本为默认选择(不设置填-1)</param> |
| | | public void ShowForm(string i_topText, List<string> i_listText, int i_selectNo) |
| | | public void ShowForm(string i_topText, List<string> i_listText, List<string> i_listBottomText, int i_selectNo) |
| | | { |
| | | //初始化中部信息 |
| | | this.InitMiddleFrame(i_topText, i_listText, i_selectNo); |
| | | this.InitMiddleFrame(i_topText, i_listText, i_listBottomText, i_selectNo); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="i_topText">头部标题</param> |
| | | /// <param name="i_listText">需要显示的列表信息</param> |
| | | /// <param name="i_listBottomtext">需要显示的列表信息(底部)</param> |
| | | /// <param name="i_selectNo">默认选择</param> |
| | | private void InitMiddleFrame(string i_topText, List<string> i_listText, int i_selectNo) |
| | | {
|
| | | //弧度的圆的一半的高度(固定)
|
| | | int halfRoundHeigth = Application.GetRealHeight(116) / 2; |
| | | //头部高度 |
| | | int topHeight = Application.GetRealHeight(195);
|
| | | //底部高度
|
| | | int bottomHeight = Application.GetRealHeight(57); |
| | | //明细高度 |
| | | int detailHeight = (ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(12)) * i_listText.Count;
|
| | |
|
| | | //搞一个透明的框
|
| | | var frameTransparent = new FrameLayout();
|
| | | frameTransparent.Y = bodyFrameLayout.Height - topHeight - bottomHeight - detailHeight; |
| | | frameTransparent.Height = topHeight + bottomHeight + detailHeight + halfRoundHeigth * 2;//高度就是要它超过,随便搞的
|
| | | frameTransparent.BackgroundColor = UserCenterColor.Current.Transparent; |
| | | bodyFrameLayout.AddChidren(frameTransparent);
|
| | |
|
| | | //明细列表的桌布,白色背景(它与实际高度小了半个弧度的圆)
|
| | | var detailBackFrame = new FrameLayout(); |
| | | detailBackFrame.Y = halfRoundHeigth; |
| | | detailBackFrame.Height = frameTransparent.Height;
|
| | | detailBackFrame.BackgroundColor = UserCenterColor.Current.White; |
| | | frameTransparent.AddChidren(detailBackFrame);
|
| | |
|
| | | //弧度的圆
|
| | | var rowRound = new FrameLayout(); |
| | | rowRound.Width = bodyFrameLayout.Width; |
| | | rowRound.Height = halfRoundHeigth * 2; |
| | | rowRound.BackgroundColor = UserCenterColor.Current.White; |
| | | rowRound.Radius = (uint)halfRoundHeigth; |
| | | frameTransparent.AddChidren(rowRound); |
| | | private void InitMiddleFrame(string i_topText, List<string> i_listText, List<string> i_listBottomtext, int i_selectNo) |
| | | { |
| | | //不能够滑动的东西 |
| | | FrameListControl listDetailView1 = null; |
| | | //能够滑动的东西 |
| | | VerticalListControl listDetailView2 = null; |
| | | |
| | | //头部信息
|
| | | var btnTitle = new NormalViewControl(detailBackFrame.Width, Application.GetRealHeight(63), false); |
| | | btnTitle.Y = Application.GetRealHeight(35); |
| | | //★★从下往上添加控件★★ |
| | | |
| | | //明细高度(初始最多只显示9行) |
| | | int detailHeight = ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(12); |
| | | if (i_listText.Count > 9) |
| | | { |
| | | //63:上部间距 58:下部间距 |
| | | detailHeight = detailHeight * 9 + Application.GetRealHeight(63 + 58); |
| | | listDetailView2 = new VerticalListControl(12); |
| | | listDetailView2.Height = detailHeight; |
| | | listDetailView2.Gravity = Gravity.BottomCenter; |
| | | listDetailView2.BackgroundColor = UserCenterColor.Current.White; |
| | | bodyFrameLayout.AddChidren(listDetailView2); |
| | | } |
| | | else |
| | | { |
| | | //63:上部间距 58:下部间距 |
| | | detailHeight = detailHeight * i_listText.Count + Application.GetRealHeight(63 + 58); |
| | | listDetailView1 = new FrameListControl(12); |
| | | listDetailView1.Height = detailHeight; |
| | | listDetailView1.Gravity = Gravity.BottomCenter; |
| | | listDetailView1.BackgroundColor = UserCenterColor.Current.White; |
| | | bodyFrameLayout.AddChidren(listDetailView1); |
| | | } |
| | | //线 |
| | | int lineYY = listDetailView1 != null ? listDetailView1.Y : listDetailView2.Y; |
| | | var btnLine = new NormalViewControl(bodyFrameLayout.Width, ControlCommonResourse.BottomLineHeight, false); |
| | | btnLine.Y = lineYY - ControlCommonResourse.BottomLineHeight; |
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; |
| | | bodyFrameLayout.AddChidren(btnLine); |
| | | |
| | | //头部白色背景 |
| | | var topBackFame = new FrameLayout(); |
| | | topBackFame.Y = btnLine.Y - Application.GetRealHeight(138); |
| | | topBackFame.BackgroundColor = UserCenterColor.Current.White; |
| | | topBackFame.Height = Application.GetRealHeight(138); |
| | | topBackFame.SetCornerWithSameRadius(Application.GetRealHeight(58), HDLUtils.RectCornerTopLeft | HDLUtils.RectCornerTopRight); |
| | | bodyFrameLayout.AddChidren(topBackFame); |
| | | |
| | | //头部信息 |
| | | var btnTitle = new NormalViewControl(topBackFame.Width, Application.GetRealHeight(65), false); |
| | | btnTitle.Y = Application.GetRealHeight(34); |
| | | btnTitle.Text = i_topText; |
| | | btnTitle.TextColor = UserCenterColor.Current.TextColor4; |
| | | btnTitle.TextSize = 16; |
| | | btnTitle.TextAlignment = TextAlignment.Center; |
| | | rowRound.AddChidren(btnTitle); |
| | | topBackFame.AddChidren(btnTitle); |
| | | |
| | | //取消 |
| | | var btnCancel = new NormalViewControl(200, 58, true); |
| | | var btnCancel = new NormalViewControl(Application.GetRealWidth(200), topBackFame.Height, false); |
| | | btnCancel.X = Application.GetRealWidth(81); |
| | | btnCancel.Y = Application.GetRealHeight(40); |
| | | btnCancel.TextColor = UserCenterColor.Current.TextGrayColor1; |
| | | btnCancel.TextID = R.MyInternationalizationString.uCancel; |
| | | rowRound.AddChidren(btnCancel); |
| | | btnCancel.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | this.CloseForm();
|
| | | };
|
| | |
|
| | | //完成
|
| | | var btnFinish = new NormalViewControl(200, 58, true); |
| | | btnFinish.X = Application.GetRealWidth(800); |
| | | btnFinish.Y = Application.GetRealHeight(40); |
| | | topBackFame.AddChidren(btnCancel); |
| | | btnCancel.ButtonClickEvent += (sender, e) => |
| | | { |
| | | this.CloseForm(); |
| | | }; |
| | | |
| | | //完成 |
| | | var btnFinish = new NormalViewControl(Application.GetRealWidth(200), topBackFame.Height, false); |
| | | btnFinish.X = topBackFame.Width - btnCancel.X - Application.GetRealWidth(200); |
| | | btnFinish.TextAlignment = TextAlignment.CenterRight; |
| | | btnFinish.TextColor = 0xfffb744a; |
| | | btnFinish.TextID = R.MyInternationalizationString.uFinish; |
| | | rowRound.AddChidren(btnFinish); |
| | | btnFinish.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (FinishSelectEvent != null && oldSelectContr != null)
|
| | | {
|
| | | //回调函数
|
| | | FinishSelectEvent.Invoke(Convert.ToInt32(oldSelectContr.MainKeys));
|
| | | }
|
| | | else if (FinishSelectEvent != null && this.CancelCallEvent == true)
|
| | | {
|
| | | //回调函数
|
| | | FinishSelectEvent.Invoke(-1);
|
| | | }
|
| | | this.CloseForm();
|
| | | };
|
| | |
|
| | | //线
|
| | | var btnLine = new NormalViewControl(detailBackFrame.Width, ControlCommonResourse.BottomLineHeight, false);
|
| | | btnLine.Y = Application.GetRealHeight(138) - ControlCommonResourse.BottomLineHeight - halfRoundHeigth;
|
| | | btnLine.BackgroundColor = UserCenterColor.Current.ButtomLine; |
| | | detailBackFrame.AddChidren(btnLine); |
| | | topBackFame.AddChidren(btnFinish); |
| | | btnFinish.ButtonClickEvent += (sender, e) => |
| | | { |
| | | if (FinishSelectEvent != null && oldSelectContr != null) |
| | | { |
| | | //回调函数 |
| | | FinishSelectEvent.Invoke(Convert.ToInt32(oldSelectContr.MainKeys)); |
| | | } |
| | | else if (FinishSelectEvent != null && this.CancelCallEvent == true) |
| | | { |
| | | //回调函数 |
| | | FinishSelectEvent.Invoke(-1); |
| | | } |
| | | this.CloseForm(); |
| | | }; |
| | | |
| | | //列表控件
|
| | | var listView = new FrameListControl(12); |
| | | listView.Height = detailHeight + bottomHeight; |
| | | listView.Y = topHeight - halfRoundHeigth; |
| | | detailBackFrame.AddChidren(listView); |
| | | for (int i = 0; i < i_listText.Count; i++)
|
| | | {
|
| | | var btnRow = new NormalSelectControl(i_listText[i], listView.rowSpace / 2);
|
| | | btnRow.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft;//向右偏移
|
| | | btnRow.RightOffset = ControlCommonResourse.XXLeft - Application.GetRealWidth(81);//向左偏移
|
| | | listView.AddChidren(btnRow);
|
| | | btnRow.InitControl();
|
| | | btnRow.MainKeys = i.ToString();
|
| | | btnRow.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //取消选择
|
| | | if (btnRow.IsSelected == true)
|
| | | {
|
| | | //允许取消的时候,才能取消
|
| | | if (this.SelectRowCanCancel == true)
|
| | | {
|
| | | btnRow.IsSelected = false;
|
| | | oldSelectContr = null;
|
| | | }
|
| | | return;
|
| | | }
|
| | | if (oldSelectContr != null)
|
| | | {
|
| | | oldSelectContr.IsSelected = false;
|
| | | }
|
| | | btnRow.IsSelected = true;
|
| | | oldSelectContr = btnRow;
|
| | | };
|
| | | //默认选择
|
| | | if (i == i_selectNo)
|
| | | {
|
| | | btnRow.IsSelected = true;
|
| | | oldSelectContr = btnRow;
|
| | | }
|
| | | if (i != i_listText.Count - 1)
|
| | | {
|
| | | //底线
|
| | | btnRow.AddBottomLine();
|
| | | }
|
| | | //添加一个白色的间距 |
| | | var frameSpace = new FrameLayout(); |
| | | frameSpace.Height = Application.GetRealHeight(63); |
| | | listDetailView1?.AddChidren(frameSpace); |
| | | listDetailView2?.AddChidren(frameSpace); |
| | | |
| | | //明细列表控件 |
| | | int rowSpace = listDetailView1 != null ? listDetailView1.rowSpace : listDetailView2.rowSpace; |
| | | for (int i = 0; i < i_listText.Count; i++) |
| | | { |
| | | NormalSelectControl btnRow = null; |
| | | if (i_listBottomtext == null || i_listBottomtext[i] == null) |
| | | { |
| | | //只显示一行 |
| | | btnRow = new NormalSelectControl(i_listText[i], rowSpace / 2); |
| | | } |
| | | else |
| | | { |
| | | //显示上下两行 |
| | | btnRow = new NormalSelectControl(i_listText[i], i_listBottomtext[i], rowSpace / 2); |
| | | } |
| | | btnRow.LeftOffset = Application.GetRealWidth(81) - ControlCommonResourse.XXLeft;//向右偏移 |
| | | btnRow.RightOffset = ControlCommonResourse.XXLeft - Application.GetRealWidth(81);//向左偏移 |
| | | listDetailView1?.AddChidren(btnRow); |
| | | listDetailView2?.AddChidren(btnRow); |
| | | |
| | | btnRow.InitControl(); |
| | | btnRow.MainKeys = i.ToString(); |
| | | btnRow.ButtonClickEvent += (sender, e) => |
| | | { |
| | | //取消选择 |
| | | if (btnRow.IsSelected == true) |
| | | { |
| | | //允许取消的时候,才能取消 |
| | | if (this.SelectRowCanCancel == true) |
| | | { |
| | | btnRow.IsSelected = false; |
| | | oldSelectContr = null; |
| | | } |
| | | return; |
| | | } |
| | | if (oldSelectContr != null) |
| | | { |
| | | oldSelectContr.IsSelected = false; |
| | | } |
| | | btnRow.IsSelected = true; |
| | | oldSelectContr = btnRow; |
| | | }; |
| | | //默认选择 |
| | | if (i == i_selectNo) |
| | | { |
| | | btnRow.IsSelected = true; |
| | | oldSelectContr = btnRow; |
| | | } |
| | | if (i != i_listText.Count - 1) |
| | | { |
| | | //底线 |
| | | btnRow.AddBottomLine(); |
| | | } |
| | | } |
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|
| | | |
| | | //如果是滑动控件,则添加底部间距 |
| | | if (listDetailView2 != null) |
| | | { |
| | | var frameSpace2 = new FrameLayout(); |
| | | frameSpace2.Height = Application.GetRealHeight(58); |
| | | listDetailView2?.AddChidren(frameSpace2); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |