From ba275a7b58e56c61820ffccc86571447b2997e52 Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期四, 05 八月 2021 16:18:00 +0800 Subject: [PATCH] 2021-08-05 1.更新 --- HDL_ON/UI/UI0-Stan/Controls/MessageControls/ShowMsgControl.cs | 181 ++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 160 insertions(+), 21 deletions(-) diff --git a/HDL_ON/UI/UI0-Stan/Controls/MessageControls/ShowMsgControl.cs b/HDL_ON/UI/UI0-Stan/Controls/MessageControls/ShowMsgControl.cs index 521bfb9..b888536 100644 --- a/HDL_ON/UI/UI0-Stan/Controls/MessageControls/ShowMsgControl.cs +++ b/HDL_ON/UI/UI0-Stan/Controls/MessageControls/ShowMsgControl.cs @@ -63,7 +63,7 @@ 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) @@ -92,8 +92,21 @@ 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 { } } @@ -120,6 +133,13 @@ btnTemp.Text = msgText.Replace("\r\n", string.Empty); //鑾峰彇杩欎釜鏄剧ず鐨勫唴瀹圭殑楂樺害 int rowCount = btnTemp.GetRealRowCountByText(); + //鍐嶇湅鐪嬪畠鍘熸潵鎸夋崲琛岀鍒嗗壊涓哄嚑琛� + var myArry = msgText.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); + //鐪嬬湅璋佺殑琛屾暟澶�,灏辩敤璋佺殑 + if (myArry.Length > rowCount) + { + rowCount = myArry.Length; + } int contentHeight = rowCount * Application.GetRealHeight(18); if (rowCount <= 2) { @@ -141,8 +161,9 @@ 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; @@ -256,15 +277,143 @@ 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); + //钃濇箹榛戣壊鑳屾櫙鐨刌杞翠负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) { @@ -296,35 +445,25 @@ } /// <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); }); -- Gitblit v1.8.0