From d6fb0646531172f23648441c224cdcccd721b894 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期一, 14 十二月 2020 09:59:01 +0800
Subject: [PATCH] 请合并代码,完成晾衣架最终功能。
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs | 201 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 173 insertions(+), 28 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs
index f1d9bc5..a0dcd82 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs
@@ -15,6 +15,14 @@
/// </summary>
public Action ConfirmClickEvent = null;
/// <summary>
+ /// 鐐瑰嚮鍙栨秷鐨勪簨浠�
+ /// </summary>
+ public Action CancelClickEvent = null;
+ /// <summary>
+ /// 鐐瑰嚮鑳屾櫙鏄惁鍏抽棴寮圭獥
+ /// </summary>
+ public bool CloseByClickBack = true;
+ /// <summary>
/// 淇℃伅绫诲瀷
/// </summary>
private ShowMsgType msgType = ShowMsgType.Confirm;
@@ -27,9 +35,17 @@
/// </summary>
private string buttonOkText = null;
/// <summary>
+ /// 鍙栨秷鎸夐挳鐨勬枃鏈�
+ /// </summary>
+ private string buttonCancelText = null;
+ /// <summary>
/// 鎻愮ず鎺т欢
/// </summary>
private Tip myTip = null;
+ /// <summary>
+ /// 绛夊緟鏃堕棿
+ /// </summary>
+ private int WaitTime = -1;
#endregion
@@ -40,13 +56,17 @@
/// </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)
{
@@ -66,15 +86,18 @@
/// </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
@@ -86,16 +109,20 @@
/// </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();
@@ -104,7 +131,7 @@
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);
@@ -125,9 +152,13 @@
{
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;
@@ -153,23 +184,26 @@
/// </summary>
/// <param name="frameMain"></param>
/// <param name="frameBack"></param>
- private void InitBottomConfirmButton(FrameLayout frameMain, FrameLayout frameBack)
+ private void InitBottomConfirmButton(NormalFrameLayout frameMain, FrameLayout frameBack)
{
//鍙栨秷鎸夐挳
var btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127));
frameBack.AddChidren(btnCancel);
- btnCancel.InitControl(Language.StringByID(R.MyInternationalizationString.uCancel));
+ btnCancel.InitControl(this.buttonCancelText);
btnCancel.ButtonClickEvent += (sender, e) =>
{
//绉婚櫎鐣岄潰
frameMain.RemoveFromParent();
+ //鍥炶皟鍑芥暟
+ this.CancelClickEvent?.Invoke();
this.ConfirmClickEvent = null;
+ this.CancelClickEvent = null;
};
//纭畾鎸夐挳
var btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height);
frameBack.AddChidren(btnConfirm);
- btnConfirm.InitControl(buttonOkText);
+ btnConfirm.InitControl(this.buttonOkText);
btnConfirm.ButtonClickEvent += (sender, e) =>
{
//绉婚櫎鐣岄潰
@@ -177,7 +211,10 @@
//鍥炶皟鍑芥暟
this.ConfirmClickEvent?.Invoke();
this.ConfirmClickEvent = null;
+ this.CancelClickEvent = null;
};
+ //寮�鍚瓑寰呮椂闂�
+ this.StartWaitTime(btnConfirm);
}
/// <summary>
@@ -185,28 +222,28 @@
/// </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.Gravity = Gravity.BottomCenter;
- frameConfirm.Radius = 8;
+ 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) =>
{
//绉婚櫎鐣岄潰
@@ -251,6 +288,114 @@
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
--
Gitblit v1.8.0