| | |
| | | /// </summary>
|
| | | public Action ConfirmClickEvent = null;
|
| | | /// <summary>
|
| | | /// 点击取消的事件
|
| | | /// </summary>
|
| | | public Action CancelClickEvent = null;
|
| | | /// <summary>
|
| | | /// 点击背景是否关闭弹窗
|
| | | /// </summary>
|
| | | public bool CloseByClickBack = true;
|
| | | /// <summary>
|
| | | /// 信息类型
|
| | | /// </summary>
|
| | | private ShowMsgType msgType = ShowMsgType.Confirm;
|
| | |
| | | /// </summary>
|
| | | private string buttonOkText = null;
|
| | | /// <summary>
|
| | | /// 取消按钮的文本
|
| | | /// </summary>
|
| | | private string buttonCancelText = null;
|
| | | /// <summary>
|
| | | /// 提示控件
|
| | | /// </summary>
|
| | | private Tip myTip = null;
|
| | | /// <summary>
|
| | | /// 等待时间
|
| | | /// </summary>
|
| | | private int WaitTime = -1;
|
| | |
|
| | | #endregion
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="i_msgType">信息类型</param>
|
| | | /// <param name="i_msg">信息</param>
|
| | | /// <param name="buttonText">确认按钮的文本</param>
|
| | | public ShowMsgControl(ShowMsgType i_msgType, string i_msg, string buttonText = null)
|
| | | /// <param name="i_buttonOkText">确认按钮的文本</param>
|
| | | /// <param name="i_buttonCancelText">取消按钮的文本</param>
|
| | | /// <param name="i_waitTime">等待时间,单位为秒,设置确认按钮在多长时间后才能够点击</param>
|
| | | public ShowMsgControl(ShowMsgType i_msgType, string i_msg, string i_buttonOkText = null, string i_buttonCancelText = null, int i_waitTime = -1)
|
| | | {
|
| | | //确认按钮文本
|
| | | this.buttonOkText = buttonText == null ? Language.StringByID(R.MyInternationalizationString.OkMsg) : buttonText;
|
| | | this.buttonOkText = i_buttonOkText == null ? Language.StringByID(R.MyInternationalizationString.OkMsg) : i_buttonOkText;
|
| | | this.buttonCancelText = i_buttonCancelText == null ? Language.StringByID(R.MyInternationalizationString.uCancel) : i_buttonCancelText;
|
| | | this.msgType = i_msgType;
|
| | | this.msgText = i_msg;
|
| | | this.WaitTime = i_waitTime;
|
| | |
|
| | | if (i_msgType == ShowMsgType.Tip)
|
| | | {
|
| | |
| | | /// </summary>
|
| | | public void Show()
|
| | | {
|
| | | if (myTip != null)
|
| | | try
|
| | | {
|
| | | myTip.Show(Common.CommonPage.Instance);
|
| | | myTip = null;
|
| | | return;
|
| | | if (myTip != null)
|
| | | {
|
| | | myTip.Show(Common.CommonPage.Instance);
|
| | | myTip = null;
|
| | | return;
|
| | | }
|
| | | //初始化控件
|
| | | this.InitMsgControl();
|
| | | }
|
| | |
|
| | | //初始化控件
|
| | | this.InitMsgControl();
|
| | | catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// </summary>
|
| | | private void InitMsgControl()
|
| | | {
|
| | | //添加界面
|
| | | var nowForm = UserView.HomePage.Instance.GetChildren(UserView.HomePage.Instance.ChildrenCount - 1);
|
| | | if (nowForm == null || (nowForm is ViewGroup) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //主控件
|
| | | var frameMain = new FrameLayout();
|
| | | var frameMain = new NormalFrameLayout();
|
| | | frameMain.MainKey = "ShowMsg";
|
| | | frameMain.BackgroundColor = UserCenterColor.Current.DialogBackColor;
|
| | | ((ViewGroup)nowForm).AddChidren(frameMain);
|
| | | Common.CommonPage.Instance.AddChidren(frameMain);
|
| | | frameMain.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | if (this.CloseByClickBack == true)
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | this.ConfirmClickEvent = null;
|
| | | }
|
| | | };
|
| | |
|
| | | //白色背景框
|
| | | var frameBack = new FrameLayout();
|
| | |
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | frameBack.Y = Application.GetRealHeight(706);
|
| | | frameBack.Gravity = Gravity.CenterHorizontal;
|
| | | frameBack.Radius = 8;
|
| | | frameBack.Radius = (uint)Application.GetRealHeight(17);
|
| | | frameMain.AddChidren(frameBack);
|
| | | //标题
|
| | | var btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false);
|
| | |
| | | {
|
| | | btnTitle.TextID = R.MyInternationalizationString.NormalTip;
|
| | | }
|
| | | else if (msgType == ShowMsgType.Remind)
|
| | | {
|
| | | btnTitle.TextID = R.MyInternationalizationString.uRemind;
|
| | | }
|
| | |
|
| | | //消息
|
| | | var btnMsg = new NormalViewControl(frameBack.Width - Application.GetRealWidth(60 * 2), Application.GetRealHeight(180), false);
|
| | | var btnMsg = new NormalViewControl(frameBack.Width - Application.GetRealWidth(55 * 2), Application.GetRealHeight(180), false);
|
| | | btnMsg.Y = Application.GetRealHeight(141);
|
| | | btnMsg.IsMoreLines = true;
|
| | | btnMsg.TextAlignment = TextAlignment.Center;
|
| | |
| | | /// </summary>
|
| | | /// <param name="frameMain"></param>
|
| | | /// <param name="frameBack"></param>
|
| | | private void InitBottomConfirmButton(FrameLayout frameMain, FrameLayout frameBack)
|
| | | private void InitBottomConfirmButton(NormalFrameLayout frameMain, FrameLayout frameBack)
|
| | | {
|
| | | //取消
|
| | | var frameCancel = new FrameLayoutControl();
|
| | | frameCancel.Height = Application.GetRealHeight(127);
|
| | | frameCancel.Width = Application.GetRealWidth(396);
|
| | | frameCancel.Gravity = Gravity.BottomLeft;
|
| | | frameCancel.Radius = 8;
|
| | | frameCancel.BackgroundColor = 0xfff5f6fa;
|
| | | frameBack.AddChidren(frameCancel);
|
| | | //把上圆角覆盖为方角
|
| | | var btnTopTemp1 = new NormalViewControl(frameCancel.Width, Application.GetRealHeight(40), false);
|
| | | btnTopTemp1.BackgroundColor = 0xfff5f6fa;
|
| | | frameCancel.AddChidren(btnTopTemp1, ChidrenBindMode.BindEventOnly);
|
| | | //把右下圆角覆盖为方角
|
| | | var btnBomTemp1 = new NormalViewControl(frameCancel.Width / 2, Application.GetRealHeight(40), false);
|
| | | btnBomTemp1.BackgroundColor = 0xfff5f6fa;
|
| | | btnBomTemp1.Gravity = Gravity.BottomRight;
|
| | | frameCancel.AddChidren(btnBomTemp1, ChidrenBindMode.BindEventOnly);
|
| | | //取消按钮
|
| | | var btnCancel = new NormalViewControl(frameCancel.Width - Application.GetRealWidth(10), Application.GetRealHeight(60), false);
|
| | | btnCancel.Gravity = Gravity.Center;
|
| | | btnCancel.TextColor = UserCenterColor.Current.TextGrayColor1;
|
| | | btnCancel.TextID = R.MyInternationalizationString.uCancel;
|
| | | btnCancel.TextAlignment = TextAlignment.Center;
|
| | | btnCancel.BackgroundColor = 0xfff5f6fa;
|
| | | frameCancel.AddChidren(btnCancel, ChidrenBindMode.BindEventOnly);
|
| | | frameCancel.ButtonClickEvent += (sender, e) =>
|
| | | var btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127));
|
| | | frameBack.AddChidren(btnCancel);
|
| | | btnCancel.InitControl(this.buttonCancelText);
|
| | | btnCancel.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | //回调函数
|
| | | this.CancelClickEvent?.Invoke();
|
| | | this.ConfirmClickEvent = null;
|
| | | };
|
| | | //重写控件点击状态
|
| | | frameCancel.SelectStatuEvent += (statu) =>
|
| | | {
|
| | | if (statu == true)
|
| | | {
|
| | | frameCancel.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnTopTemp1.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnBomTemp1.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnCancel.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | }
|
| | | else
|
| | | {
|
| | | frameCancel.BackgroundColor = 0xfff5f6fa;
|
| | | btnTopTemp1.BackgroundColor = 0xfff5f6fa;
|
| | | btnBomTemp1.BackgroundColor = 0xfff5f6fa;
|
| | | btnCancel.BackgroundColor = 0xfff5f6fa;
|
| | | }
|
| | | this.CancelClickEvent = null;
|
| | | };
|
| | |
|
| | | //确认
|
| | | var frameConfirm = new FrameLayoutControl();
|
| | | frameConfirm.Height = Application.GetRealHeight(127);
|
| | | frameConfirm.Width = Application.GetRealWidth(396);
|
| | | frameConfirm.Gravity = Gravity.BottomRight;
|
| | | frameConfirm.Radius = 8;
|
| | | frameConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | frameBack.AddChidren(frameConfirm);
|
| | | //把上圆角覆盖为方角
|
| | | var btnTopTemp2 = new NormalViewControl(frameConfirm.Width, Application.GetRealHeight(40), false);
|
| | | btnTopTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | frameConfirm.AddChidren(btnTopTemp2, ChidrenBindMode.BindEventOnly);
|
| | | //把左下圆角覆盖为方角
|
| | | var btnBomTemp2 = new NormalViewControl(frameConfirm.Width / 2, Application.GetRealHeight(40), false);
|
| | | btnBomTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnBomTemp2.Gravity = Gravity.BottomLeft;
|
| | | frameConfirm.AddChidren(btnBomTemp2, ChidrenBindMode.BindEventOnly);
|
| | | //确认按钮
|
| | | var btnConfirm = new NormalViewControl(frameConfirm.Width - Application.GetRealWidth(10), Application.GetRealHeight(60), false);
|
| | | btnConfirm.Gravity = Gravity.Center;
|
| | | btnConfirm.TextColor = UserCenterColor.Current.White;
|
| | | btnConfirm.Text = buttonOkText;
|
| | | btnConfirm.TextAlignment = TextAlignment.Center;
|
| | | frameConfirm.AddChidren(btnConfirm, ChidrenBindMode.BindEventOnly);
|
| | | frameConfirm.ButtonClickEvent += (sender, e) =>
|
| | | //确定按钮
|
| | | var btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height);
|
| | | frameBack.AddChidren(btnConfirm);
|
| | | btnConfirm.InitControl(this.buttonOkText);
|
| | | btnConfirm.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | //回调函数
|
| | | this.ConfirmClickEvent?.Invoke();
|
| | | this.ConfirmClickEvent = null;
|
| | | this.CancelClickEvent = null;
|
| | | };
|
| | | //重写控件点击状态
|
| | | frameConfirm.SelectStatuEvent += (statu) =>
|
| | | {
|
| | | if (statu == true)
|
| | | {
|
| | | frameConfirm.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnTopTemp2.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnBomTemp2.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | btnConfirm.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor;
|
| | | }
|
| | | else
|
| | | {
|
| | | frameConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnTopTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnBomTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | }
|
| | | };
|
| | | //开启等待时间
|
| | | this.StartWaitTime(btnConfirm);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// </summary>
|
| | | /// <param name="frameMain"></param>
|
| | | /// <param name="frameBack"></param>
|
| | | private void InitBottomNormalButton(FrameLayout frameMain, FrameLayout frameBack)
|
| | | private void InitBottomNormalButton(NormalFrameLayout frameMain, FrameLayout frameBack)
|
| | | {
|
| | | #if Android
|
| | | //确认
|
| | | var frameConfirm = new FrameLayoutControl();
|
| | | var frameConfirm = new FrameLayoutStatuControl();
|
| | | frameConfirm.Height = Application.GetRealHeight(127);
|
| | | frameConfirm.Width = frameBack.Width;
|
| | | frameConfirm.Y = Application.GetRealHeight(351);
|
| | | frameConfirm.Radius = 8;
|
| | | frameConfirm.Gravity = Gravity.BottomCenter;
|
| | | frameConfirm.RadiusEx = 17;
|
| | | frameConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | frameBack.AddChidren(frameConfirm);
|
| | | //把上圆角覆盖为方角
|
| | | var btnTopTemp2 = new NormalViewControl(frameConfirm.Width, Application.GetRealHeight(35), false);
|
| | | btnTopTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | frameConfirm.AddChidren(btnTopTemp2, ChidrenBindMode.BindEventOnly);
|
| | | frameConfirm.AddChidren(btnTopTemp2, ChidrenBindMode.BindEvent);
|
| | | //确认按钮
|
| | | var btnConfirm = new NormalViewControl(frameConfirm.Width - Application.GetRealWidth(10), Application.GetRealHeight(60), false);
|
| | | btnConfirm.Gravity = Gravity.Center;
|
| | | btnConfirm.TextColor = UserCenterColor.Current.White;
|
| | | btnConfirm.Text = buttonOkText;
|
| | | btnConfirm.TextAlignment = TextAlignment.Center;
|
| | | frameConfirm.AddChidren(btnConfirm, ChidrenBindMode.BindEventOnly);
|
| | | frameConfirm.AddChidren(btnConfirm, ChidrenBindMode.BindEvent);
|
| | | frameConfirm.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | |
| | | btnConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | }
|
| | | };
|
| | | #endif
|
| | | #if iOS
|
| | | //确认按钮
|
| | | var btnConfirm = new NormalClickButton(frameBack.Width, Application.GetRealHeight(127), false);
|
| | | btnConfirm.Gravity = Gravity.BottomCenter;
|
| | | btnConfirm.TextColor = UserCenterColor.Current.White;
|
| | | btnConfirm.Text = buttonOkText;
|
| | | btnConfirm.TextAlignment = TextAlignment.Center;
|
| | | btnConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | btnConfirm.oldBackgroundColor = UserCenterColor.Current.ClickButtonDefultColor;
|
| | | frameBack.AddChidren(btnConfirm);
|
| | | btnConfirm.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //移除界面
|
| | | frameMain.RemoveFromParent();
|
| | | //回调函数
|
| | | this.ConfirmClickEvent?.Invoke();
|
| | | this.ConfirmClickEvent = null;
|
| | | };
|
| | | #endif
|
| | | //开启等待时间
|
| | | this.StartWaitTime(btnConfirm);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 开启等待时间_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 开启等待时间(此函数只用于安卓)
|
| | | /// </summary>
|
| | | /// <param name="btnConfirm">确认按钮</param>
|
| | | private void StartWaitTime(BottomRightClickButton btnConfirm)
|
| | | {
|
| | | if (this.WaitTime <= 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | btnConfirm.CanClick = false;
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //显示剩余等待时间
|
| | | while (btnConfirm.Parent != null && this.WaitTime >= 0)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnConfirm.SetButtonText(this.buttonOkText + "(" + this.WaitTime + ")");
|
| | | }, ShowErrorMode.NO);
|
| | | System.Threading.Thread.Sleep(1000);
|
| | | this.WaitTime--;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //可以点击
|
| | | btnConfirm.SetButtonText(this.buttonOkText);
|
| | | btnConfirm.CanClick = true;
|
| | | }, ShowErrorMode.NO);
|
| | | });
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 开启等待时间
|
| | | /// </summary>
|
| | | /// <param name="btnConfirm">确认按钮</param>
|
| | | private void StartWaitTime(ButtonBase btnConfirm)
|
| | | {
|
| | | if (this.WaitTime <= 0)
|
| | | {
|
| | | return;
|
| | | }
|
| | | #if Android
|
| | | ((FrameLayoutStatuControl)btnConfirm.Parent).CanClick = false;
|
| | | #endif
|
| | | #if iOS
|
| | | btnConfirm.CanClick = false;
|
| | | #endif
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //显示剩余等待时间
|
| | | while (btnConfirm.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;
|
| | | #if Android
|
| | | ((FrameLayoutStatuControl)btnConfirm.Parent).CanClick = true;
|
| | | #endif
|
| | | #if iOS
|
| | | btnConfirm.CanClick = true;
|
| | | #endif
|
| | | }, ShowErrorMode.NO);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 关闭弹窗(外部调用)_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 关闭全部的弹窗
|
| | | /// </summary>
|
| | | public static void CloseAllMsgDialog()
|
| | | {
|
| | | while (true)
|
| | | {
|
| | | var myView = Common.CommonPage.Instance.GetChildren(Common.CommonPage.Instance.ChildrenCount - 1);
|
| | | if (myView == null) { return; }
|
| | | if (myView is NormalFrameLayout)
|
| | | {
|
| | | if (((NormalFrameLayout)myView).MainKey != "ShowMsg")
|
| | | {
|
| | | return;
|
| | | }
|
| | | //移除
|
| | | myView.RemoveFromParent();
|
| | | continue;
|
| | | }
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|