| | |
| | | this.buttonOkText = i_buttonOkText == null ? Language.StringByID(StringId.Confirm) : i_buttonOkText;
|
| | | this.buttonCancelText = i_buttonCancelText == null ? Language.StringByID(StringId.Cancel) : i_buttonCancelText;
|
| | | this.msgType = i_msgType;
|
| | | this.msgText = i_msg;
|
| | | this.msgText = i_msg.Replace("{0}", "\r\n");
|
| | | this.WaitTime = i_waitTime;
|
| | |
|
| | | if (i_msgType == ShowMsgType.Tip)
|
| | |
| | | myTip = null;
|
| | | return;
|
| | | }
|
| | | //初始化控件
|
| | | this.InitMsgControl();
|
| | | if (this.msgType == ShowMsgType.TipRemind || this.msgType == ShowMsgType.TipSuccess)
|
| | | {
|
| | | //初始化控件
|
| | | this.InitExTipControl();
|
| | | }
|
| | | else if (this.msgType == ShowMsgType.ConfirmSuccess || this.msgType == ShowMsgType.ConfirmFail)
|
| | | {
|
| | | //初始化控件
|
| | | this.InitConfirmSuccessTypeContorl();
|
| | | }
|
| | | else
|
| | | {
|
| | | //初始化控件
|
| | | this.InitMsgControl();
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | }
|
| | |
| | | frameMain.AddChidren(frameCenter);
|
| | |
|
| | | //标题
|
| | | var btnTitle = new NormalViewControl(frameCenter.Width, Application.GetRealHeight(22), false);
|
| | | var btnTitle = new NormalViewControl(frameCenter.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(22), false);
|
| | | btnTitle.Y = Application.GetRealHeight(20);
|
| | | btnTitle.Gravity = Gravity.CenterHorizontal;
|
| | | btnTitle.TextColor = CSS_Color.MainColor;
|
| | | btnTitle.TextSize = CSS_FontSize.SubheadingFontSize;
|
| | | btnTitle.TextAlignment = TextAlignment.Center;
|
| | |
| | | this.StartWaitTime(btnConfirm);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化特殊的tip控件,仅支持 TipRemind 和 TipSuccess
|
| | | /// </summary>
|
| | | private void InitExTipControl()
|
| | | {
|
| | | //获取当前的界面
|
| | | var nowActionForm = MainPage.BasePageView.GetChildren(MainPage.BasePageView.ChildrenCount - 1) as ViewGroup;
|
| | | if (nowActionForm == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //主控件
|
| | | var frameMain = new NormalFrameLayout();
|
| | | frameMain.Height = nowActionForm.Height;
|
| | | frameMain.Width = nowActionForm.Width;
|
| | | nowActionForm.AddChidren(frameMain);
|
| | | frameMain.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | frameMain.RemoveFromParent();
|
| | | };
|
| | |
|
| | | //计算用
|
| | | var btnTemp = new ButtonCtrBase();
|
| | | btnTemp.Text = msgText.Replace("\r\n", string.Empty);
|
| | | //获取这个显示的内容的高度(蓝湖的黑色背景的宽度为198,然后再减去余白)
|
| | | int rowCount = btnTemp.GetRealRowCountByText(Application.GetRealWidth(198) - HdlControlResourse.XXLeft * 2);
|
| | | //再看看它原来按换行符分割为几行
|
| | | var myArry = msgText.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | //看看谁的行数多,就用谁的
|
| | | if (myArry.Length > rowCount)
|
| | | {
|
| | | rowCount = myArry.Length;
|
| | | }
|
| | | int contentHeight = rowCount * Application.GetRealHeight(20);
|
| | | //蓝湖黑色背景的Y轴为302
|
| | | var frameBlack = new FrameLayout();
|
| | | //如果是多行时,减掉一行的高度,则得出新增加的高度,然后再除以2,则为Y轴原始占比
|
| | | frameBlack.Y = Application.GetRealHeight(302) - (contentHeight - Application.GetRealHeight(20)) / 2;
|
| | | frameBlack.Width = Application.GetRealWidth(198);
|
| | | //实际计算出来的高度为 62+文本高度+16
|
| | | frameBlack.Height = Application.GetRealHeight(62) + contentHeight + Application.GetRealHeight(16);
|
| | | frameBlack.Radius = (uint)Application.GetRealWidth(12);
|
| | | frameBlack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBlack.BackgroundColor = CSS_Color.DialogTransparentColor1;
|
| | | frameMain.AddChidren(frameBlack);
|
| | |
|
| | | //图标
|
| | | var btnIcon = new IconViewControl(42);
|
| | | btnIcon.Y = Application.GetRealHeight(10);
|
| | | btnIcon.Gravity = Gravity.CenterHorizontal;
|
| | | btnIcon.UnSelectedImagePath = this.msgType == ShowMsgType.TipSuccess ? "Public/MsgIcon/TipSuccessIcon.png" : "Public/MsgIcon/TipIconWhite.png";
|
| | | frameBlack.AddChidren(btnIcon);
|
| | |
|
| | | //显示文本
|
| | | var btnText = new NormalViewControl(frameBlack.Width - HdlControlResourse.XXLeft * 2, contentHeight, false);
|
| | | btnText.Y = btnIcon.Bottom + Application.GetRealHeight(10);
|
| | | btnText.TextAlignment = TextAlignment.Center;
|
| | | btnText.TextColor = CSS_Color.MainBackgroundColor;
|
| | | btnText.Gravity = Gravity.CenterHorizontal;
|
| | | btnText.IsMoreLines = true;
|
| | | btnText.Text = this.msgText;
|
| | | frameBlack.AddChidren(btnText);
|
| | |
|
| | | //开启关闭时间
|
| | | this.StartCloseTime(frameMain);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化确认成功型控件,仅支持 ConfirmSuccess 和 ConfirmFail
|
| | | /// </summary>
|
| | | private void InitConfirmSuccessTypeContorl()
|
| | | {
|
| | | var dialogForm = new Dialog();
|
| | | dialogForm.BackgroundColor = CSS_Color.DialogTransparentColor1;
|
| | | //主控件
|
| | | var frameMain = new NormalFrameLayout();
|
| | | dialogForm.AddChidren(frameMain);
|
| | | dialogForm.Show();
|
| | |
|
| | | //白色背景
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Y = Application.GetRealHeight(223);
|
| | | frameBack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBack.Width = Application.GetRealWidth(288);
|
| | | frameBack.Height = Application.GetRealHeight(245);
|
| | | frameBack.BackgroundColor = CSS_Color.MainBackgroundColor;
|
| | | frameBack.Radius = (uint)Application.GetRealWidth(12);
|
| | | frameMain.AddChidren(frameBack);
|
| | |
|
| | | //大图标(蓝湖上,它高出白色区域70像素,因为高宽的比率是不一样的,所以需要计算一下比率)
|
| | | decimal decProportion = 70m / 160;
|
| | | var btnIcon = new IconViewControl(160);
|
| | | btnIcon.Y = frameBack.Y - (int)(decProportion * btnIcon.IconSize);
|
| | | btnIcon.Gravity = Gravity.CenterHorizontal;
|
| | | btnIcon.UnSelectedImagePath = this.msgType == ShowMsgType.ConfirmSuccess ? "Public/Dialog/DialogTipTitleIcon_1.png" : "Public/Dialog/DialogTipTitleIcon_2.png";
|
| | | frameMain.AddChidren(btnIcon);
|
| | |
|
| | | //消息
|
| | | var btnMsg = new NormalViewControl(frameMain.Width - HdlControlResourse.XXLeft * 2, Application.GetRealHeight(50), false);
|
| | | //取大图标的下部高度,然后再加间距10
|
| | | btnMsg.Y = btnIcon.Height - (frameBack.Y - btnIcon.Y) + Application.GetRealHeight(10);
|
| | | btnMsg.Gravity = Gravity.CenterHorizontal;
|
| | | btnMsg.TextAlignment = TextAlignment.TopCenter;
|
| | | btnMsg.IsMoreLines = true;
|
| | | btnMsg.TextSize = CSS_FontSize.SubheadingFontSize;
|
| | | btnMsg.TextColor = CSS_Color.MainColor;
|
| | | btnMsg.Text = this.msgText;
|
| | | frameBack.AddChidren(btnMsg);
|
| | |
|
| | | //确认按钮
|
| | | var btnConfirm = new BottomClickButton(220);
|
| | | btnConfirm.Text = this.buttonOkText;
|
| | | btnConfirm.Y = Application.GetRealHeight(169);
|
| | | frameBack.AddChidren(btnConfirm);
|
| | | btnConfirm.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //关闭界面
|
| | | dialogForm.Close();
|
| | | //回调函数
|
| | | this.ConfirmClickEvent?.Invoke();
|
| | | this.ConfirmClickEvent = null;
|
| | | this.CancelClickEvent = null;
|
| | | };
|
| | |
|
| | | //开启等待时间
|
| | | this.StartWaitTime(btnConfirm);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 开启等待时间_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启等待时间(此函数只用于安卓)
|
| | | /// 开启等待时间
|
| | | /// </summary>
|
| | | /// <param name="btnConfirm">确认按钮</param>
|
| | | private void StartWaitTime(NormalViewControl btnConfirm)
|
| | | private void StartWaitTime(ButtonCtrBase btnConfirm)
|
| | | {
|
| | | if (this.WaitTime <= 0)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 开启等待时间
|
| | | /// 开启关闭时间
|
| | | /// </summary>
|
| | | /// <param name="btnConfirm">确认按钮</param>
|
| | | private void StartWaitTime(ButtonCtrBase btnConfirm)
|
| | | /// <param name="frameMain">主界面</param>
|
| | | private void StartCloseTime(FrameLayout frameMain)
|
| | | {
|
| | | if (this.WaitTime <= 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //不能点击
|
| | | btnConfirm.CanClick = false;
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //显示剩余等待时间
|
| | | while (btnConfirm.Parent != null && this.WaitTime >= 0)
|
| | | while (frameMain.Parent != null && this.WaitTime >= 0)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnConfirm.Text = this.buttonOkText + "(" + this.WaitTime + ")";
|
| | | }, ShowErrorMode.NO);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | this.WaitTime--;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //可以点击
|
| | | btnConfirm.Text = this.buttonOkText;
|
| | | btnConfirm.CanClick = true;
|
| | | frameMain?.RemoveFromParent();
|
| | |
|
| | | }, ShowErrorMode.NO);
|
| | | });
|