From 6fa9d69da922c8049f5acfcbb9ce9fd26811024c Mon Sep 17 00:00:00 2001 From: xm <1271024303@qq.com> Date: 星期四, 16 四月 2020 17:10:57 +0800 Subject: [PATCH] 请合并代码 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs | 265 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 265 insertions(+), 0 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs new file mode 100755 index 0000000..5f5a143 --- /dev/null +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Controls/MessageControls/ShowMsgControl.cs @@ -0,0 +1,265 @@ +锘縰sing System; +using System.Text; + +namespace Shared.Phone.UserCenter +{ + /// <summary> + /// 鏄剧ず涓�涓俊鎭 + /// </summary> + public class ShowMsgControl + { + #region 鈻� 鍙橀噺澹版槑___________________________ + + /// <summary> + /// 鐐瑰嚮纭鐨勪簨浠� + /// </summary> + public Action ConfirmClickEvent = null; + /// <summary> + /// 淇℃伅绫诲瀷 + /// </summary> + private ShowMsgType msgType = ShowMsgType.Confirm; + /// <summary> + /// 娑堟伅 + /// </summary> + private string msgText = string.Empty; + /// <summary> + /// 纭鎸夐挳鐨勬枃鏈� + /// </summary> + private string buttonOkText = null; + /// <summary> + /// 鎻愮ず鎺т欢 + /// </summary> + private Tip myTip = null; + + #endregion + + #region 鈻� 鍒濆鍖朹____________________________ + + /// <summary> + /// 鏄剧ず涓�涓渶瑕佺‘璁ょ殑淇℃伅妗� + /// </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) + { + //纭鎸夐挳鏂囨湰 + this.buttonOkText = buttonText == null ? Language.StringByID(R.MyInternationalizationString.OkMsg) : buttonText; + this.msgType = i_msgType; + this.msgText = i_msg; + + if (i_msgType == ShowMsgType.Tip) + { + myTip = new Tip(); + myTip.Direction = AMPopTipDirection.None; + myTip.CloseTime = 2; + myTip.Text = i_msg; + } + } + + #endregion + + #region 鈻� 鏄剧ず娑堟伅___________________________ + + /// <summary> + /// 鏄剧ず + /// </summary> + public void Show() + { + try + { + if (myTip != null) + { + myTip.Show(Common.CommonPage.Instance); + myTip = null; + return; + } + //鍒濆鍖栨帶浠� + this.InitMsgControl(); + } + catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex); } + } + + #endregion + + #region 鈻� 鍒濆鍖栨帶浠禵________________________ + + /// <summary> + /// 鍒濆鍖栨帶浠� + /// </summary> + private void InitMsgControl() + { + //涓绘帶浠� + var frameMain = new FrameLayout(); + frameMain.BackgroundColor = UserCenterColor.Current.DialogBackColor; + Common.CommonPage.Instance.AddChidren(frameMain); + frameMain.MouseUpEventHandler += (sender, e) => + { + //绉婚櫎鐣岄潰 + frameMain.RemoveFromParent(); + this.ConfirmClickEvent = null; + }; + + //鐧借壊鑳屾櫙妗� + var frameBack = new FrameLayout(); + frameBack.Height = Application.GetRealHeight(478); + frameBack.Width = Application.GetRealWidth(792); + frameBack.BackgroundColor = UserCenterColor.Current.White; + frameBack.Y = Application.GetRealHeight(706); + frameBack.Gravity = Gravity.CenterHorizontal; + frameBack.Radius = (uint)Application.GetRealHeight(17); + frameMain.AddChidren(frameBack); + //鏍囬 + var btnTitle = new NormalViewControl(frameBack.Width, Application.GetRealHeight(65), false); + btnTitle.Y = Application.GetRealHeight(68); + btnTitle.TextColor = 0xff333443; + btnTitle.TextAlignment = TextAlignment.Center; + btnTitle.TextSize = 16; + frameBack.AddChidren(btnTitle); + if (msgType == ShowMsgType.Normal) + { + btnTitle.TextID = R.MyInternationalizationString.NormalTip; + } + else if (msgType == ShowMsgType.Error) + { + btnTitle.TextID = R.MyInternationalizationString.ErrorTip; + } + else if (msgType == ShowMsgType.Confirm) + { + btnTitle.TextID = R.MyInternationalizationString.NormalTip; + } + else if (msgType == ShowMsgType.Remind) + { + btnTitle.TextID = R.MyInternationalizationString.uRemind; + } + + //娑堟伅 + 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; + btnMsg.TextColor = UserCenterColor.Current.TextGrayColor1; + btnMsg.Gravity = Gravity.CenterHorizontal; + btnMsg.Text = msgText; + frameBack.AddChidren(btnMsg); + + if (msgType == ShowMsgType.Confirm) + { + //鍒濆鍖栫‘璁ょ被鍨嬬殑搴曢儴鎸夐挳 + this.InitBottomConfirmButton(frameMain, frameBack); + } + else + { + //鍒濆鍖栨櫘閫氱被鍨嬬殑搴曢儴鎸夐挳 + this.InitBottomNormalButton(frameMain, frameBack); + } + } + + /// <summary> + /// 鍒濆鍖栫‘璁ょ被鍨嬬殑搴曢儴鎸夐挳 + /// </summary> + /// <param name="frameMain"></param> + /// <param name="frameBack"></param> + private void InitBottomConfirmButton(FrameLayout frameMain, FrameLayout frameBack) + { + //鍙栨秷鎸夐挳 + var btnCancel = new BottomLeftClickButton(Application.GetRealWidth(396), Application.GetRealHeight(127)); + frameBack.AddChidren(btnCancel); + btnCancel.InitControl(Language.StringByID(R.MyInternationalizationString.uCancel)); + btnCancel.ButtonClickEvent += (sender, e) => + { + //绉婚櫎鐣岄潰 + frameMain.RemoveFromParent(); + this.ConfirmClickEvent = null; + }; + + //纭畾鎸夐挳 + var btnConfirm = new BottomRightClickButton(frameBack.Width - btnCancel.Width, btnCancel.Height); + frameBack.AddChidren(btnConfirm); + btnConfirm.InitControl(buttonOkText); + btnConfirm.ButtonClickEvent += (sender, e) => + { + //绉婚櫎鐣岄潰 + frameMain.RemoveFromParent(); + //鍥炶皟鍑芥暟 + this.ConfirmClickEvent?.Invoke(); + this.ConfirmClickEvent = null; + }; + } + + /// <summary> + /// 鍒濆鍖栨櫘閫氱被鍨嬬殑搴曢儴鎸夐挳 + /// </summary> + /// <param name="frameMain"></param> + /// <param name="frameBack"></param> + private void InitBottomNormalButton(FrameLayout frameMain, FrameLayout frameBack) + { +#if Android + //纭 + var frameConfirm = new FrameLayoutControl(); + frameConfirm.Height = Application.GetRealHeight(127); + frameConfirm.Width = frameBack.Width; + 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); + //纭鎸夐挳 + 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) => + { + //绉婚櫎鐣岄潰 + frameMain.RemoveFromParent(); + //鍥炶皟鍑芥暟 + this.ConfirmClickEvent?.Invoke(); + this.ConfirmClickEvent = null; + }; + //閲嶅啓鎺т欢鐐瑰嚮鐘舵�� + frameConfirm.SelectStatuEvent += (statu) => + { + if (statu == true) + { + frameConfirm.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor; + btnTopTemp2.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor; + btnConfirm.BackgroundColor = UserCenterColor.Current.ButtonClickStatuColor; + } + else + { + frameConfirm.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor; + btnTopTemp2.BackgroundColor = UserCenterColor.Current.ClickButtonDefultColor; + 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 + } + + #endregion + } +} -- Gitblit v1.8.0