From ee888ab45a850245b1e1372375ba9040316086ab Mon Sep 17 00:00:00 2001 From: 陈嘉乐 <cjl@hdlchina.com.cn> Date: 星期四, 30 四月 2020 18:05:34 +0800 Subject: [PATCH] 2020-04-30 --- ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs | 353 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 334 insertions(+), 19 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs b/ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs index f20ec2d..0a63986 100644 --- a/ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs +++ b/ZigbeeApp/Shared/Phone/Device/Logic/LogicView/TipView.cs @@ -5,12 +5,23 @@ { public class TipView { - - - public void ShowTip(FrameLayout fLayout) + /// <summary> + /// 纭畾妗� + /// </summary> + /// <param name="action"></param> + public static void ShowConfrimTip(Action action) { - - + ///涓绘帶浠� + Dialog dialog = new Dialog(); + dialog.Show(); + ///鑳屾櫙鐨勭埗鎺т欢 + FrameLayout fLayout = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor }; + dialog.AddChidren(fLayout); + fLayout.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///寮规鐖舵帶浠� FrameLayout tipFLayout = new FrameLayout { X = Application.GetRealWidth(144), @@ -18,17 +29,17 @@ Width = Application.GetRealWidth(792), Height = Application.GetRealHeight(351 + 127), BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + Radius = (uint)Application.GetRealHeight(17) }; fLayout.AddChidren(tipFLayout); - tipFLayout.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft| HDLUtils.RectCornerTopRight| HDLUtils.RectCornerBottomLeft| HDLUtils.RectCornerBottomRight); - + ///涓婇潰蹇殑鐖舵帶浠� FrameLayout topFrame = new FrameLayout { Width = Application.GetRealWidth(792), Height = Application.GetRealHeight(351), }; tipFLayout.AddChidren(topFrame); - + ///鎻愮ず鎺т欢 Button tipBtn = new Button { TextID = R.MyInternationalizationString.Tip, @@ -41,11 +52,10 @@ Width = Application.GetRealWidth(492), }; topFrame.AddChidren(tipBtn); - - + ///鑷畾涔夋枃鏈帶浠� Button tipTextBtn = new Button { - Text=Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n"), + Text = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n"), TextAlignment = TextAlignment.Center, TextColor = ZigbeeColor.Current.LogicTipTextColor, TextSize = 14, @@ -56,7 +66,7 @@ IsMoreLines = true, }; topFrame.AddChidren(tipTextBtn); - + ///涓嬮潰蹇殑鐖舵帶浠� FrameLayout bottomFrame = new FrameLayout { Y = topFrame.Bottom, @@ -65,7 +75,7 @@ }; tipFLayout.AddChidren(bottomFrame); - + ///鍙栨秷鎺т欢 Button cancelBtn = new Button { TextAlignment = TextAlignment.Center, @@ -74,10 +84,11 @@ Height = Application.GetRealHeight(127), Width = Application.GetRealWidth(397), BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, - Text="123", + TextID = R.MyInternationalizationString.cancel, }; bottomFrame.AddChidren(cancelBtn); - cancelBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerTopLeft ); + cancelBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft); + ///纭鎺т欢 Button okBtn = new Button { TextAlignment = TextAlignment.Center, @@ -85,16 +96,320 @@ TextSize = 14, X = cancelBtn.Right, Height = Application.GetRealHeight(127), - Width = bottomFrame.Width- cancelBtn.Width, + Width = bottomFrame.Width - cancelBtn.Width, BackgroundColor = ZigbeeColor.Current.LogicBtnTypeColor, - Text = "456", + TextID = R.MyInternationalizationString.confrim, }; bottomFrame.AddChidren(okBtn); okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomRight); - cancelBtn.MouseUpEventHandler += (sender,e) => { - fLayout.RemoveFromParent(); + ///鍙栨秷鐐瑰嚮浜嬩欢 + cancelBtn.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///纭鐐瑰嚮浜嬩欢 + okBtn.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + action(); }; } + /// <summary> + /// 杈撳叆妗� + /// </summary> + /// <param name="_if">鏄惁闇�瑕佸彇娑堟寜閽�</param> + /// <param name="action"></param> + public static void ShowInputTip(bool _if, Action<string> action) + { + ///涓绘帶浠� + Dialog dialog = new Dialog(); + dialog.Show(); + ///鑳屾櫙鐨勭埗鎺т欢 + FrameLayout fLayout = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor }; + dialog.AddChidren(fLayout); + fLayout.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///寮规鐖舵帶浠� + FrameLayout tipFLayout = new FrameLayout + { + X = Application.GetRealWidth(144), + Y = Application.GetRealHeight(706), + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(351 + 127), + BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + Radius = (uint)Application.GetRealHeight(17) + }; + fLayout.AddChidren(tipFLayout); + ///涓婇潰蹇殑鐖舵帶浠� + FrameLayout topFrame = new FrameLayout + { + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(351), + }; + tipFLayout.AddChidren(topFrame); + ///鎻愮ず鎺т欢 + Button tipBtn = new Button + { + Y = Application.GetRealHeight(69), + X = Application.GetRealWidth(150), + Height = Application.GetRealHeight(63), + Width = Application.GetRealWidth(492), + TextID = R.MyInternationalizationString.invalidSetting, + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicTipColor, + TextSize = 16, + + }; + topFrame.AddChidren(tipBtn); + ///鏂囨湰1鎺т欢 + Button Text1Btn = new Button + { + Y = Application.GetRealHeight(187), + X = Application.GetRealWidth(50), + Height = Application.GetRealHeight(58), + Width = Application.GetRealWidth(242 + 94), + TextID = R.MyInternationalizationString.lockOpen, + TextAlignment = TextAlignment.CenterRight, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + + }; + topFrame.AddChidren(Text1Btn); + ///杈撳叆鏂囨湰妗� + EditText editTime = new EditText() + { + X = Application.GetRealWidth(409), + Y = Application.GetRealHeight(173), + Height = Application.GetRealHeight(81), + Width = Application.GetRealWidth(132), + Radius = (uint)Application.GetMinRealAverage(17), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + TextColor = ZigbeeColor.Current.LogicTextBlackColor, + TextAlignment = TextAlignment.Center, + TextSize = 14, + Text = "12", + IsNumberKeyboardType=true,//鍙緭鍏ユ暟瀛楃殑灞炴�� + }; + topFrame.AddChidren(editTime); + ///鏂囨湰2鎺т欢 + Button Text2Btn = new Button + { + Y = Application.GetRealHeight(187), + X = Application.GetRealWidth(564), + Height = Application.GetRealHeight(58), + Width = Application.GetRealWidth(51 + 100), + TextID = R.MyInternationalizationString.hour, + TextAlignment = TextAlignment.CenterLeft, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + + }; + topFrame.AddChidren(Text2Btn); + + ///涓嬮潰蹇殑鐖舵帶浠� + FrameLayout bottomFrame = new FrameLayout + { + Y = topFrame.Bottom, + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(127), + }; + tipFLayout.AddChidren(bottomFrame); + ///鍙栨秷鎺т欢 + Button cancelBtn = new Button + { + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + Height = Application.GetRealHeight(127), + Width = Application.GetRealWidth(397), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + TextID = R.MyInternationalizationString.cancel, + }; + bottomFrame.AddChidren(cancelBtn); + ///纭鎺т欢 + Button okBtn = new Button + { + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + TextSize = 14, + X = cancelBtn.Right, + Height = Application.GetRealHeight(127), + Width = bottomFrame.Width - cancelBtn.Width, + BackgroundColor = ZigbeeColor.Current.LogicBtnTypeColor, + TextID = R.MyInternationalizationString.confrim, + }; + bottomFrame.AddChidren(okBtn); + + if (_if) { + cancelBtn.X = Application.GetRealWidth(0); + cancelBtn.Width = Application.GetRealWidth(0); + okBtn.X = Application.GetRealWidth(0); + okBtn.Width = Application.GetRealWidth(792); + okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); + } + else + { + cancelBtn.X = Application.GetRealWidth(0); + cancelBtn.Width = Application.GetRealWidth(397); + okBtn.X = Application.GetRealWidth(397); + okBtn.Width = bottomFrame.Width - cancelBtn.Width; + cancelBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft); + okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomRight); + + } + ///鍙栨秷鐐瑰嚮浜嬩欢 + cancelBtn.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///纭鐐瑰嚮浜嬩欢 + okBtn.MouseUpEventHandler += (sender, e) => + { + if (string.IsNullOrEmpty(editTime.Text)) + { + ShowTip(Language.StringByID(R.MyInternationalizationString.timeNull),true); + return; + } + if (int.Parse(editTime.Text) < 1 || int.Parse(editTime.Text) > 12) + { ///闄愬埗杈撳叆鏁板瓧鑼冨洿; + string str = Language.StringByID(R.MyInternationalizationString.less) + Language.StringByID(R.MyInternationalizationString.or) + Language.StringByID(R.MyInternationalizationString.more); + ShowTip(str, true); + return; + + + } + dialog.Close(); + action(editTime.Text); + }; + + } + /// <summary> + /// 鎻愮ず妗� + /// </summary> + public static void ShowTip(string tipText,bool _if ) + { + ///涓绘帶浠� + Dialog dialog = new Dialog(); + dialog.Show(); + ///鑳屾櫙鐨勭埗鎺т欢 + FrameLayout fLayout = new FrameLayout { BackgroundColor = ZigbeeColor.Current.LogicTranslucentColor }; + dialog.AddChidren(fLayout); + fLayout.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///寮规鐖舵帶浠� + FrameLayout tipFLayout = new FrameLayout + { + X = Application.GetRealWidth(144), + Y = Application.GetRealHeight(706), + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(351 + 127), + BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + Radius = (uint)Application.GetRealHeight(17) + }; + fLayout.AddChidren(tipFLayout); + ///涓婇潰蹇殑鐖舵帶浠� + FrameLayout topFrame = new FrameLayout + { + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(351), + }; + tipFLayout.AddChidren(topFrame); + ///鎻愮ず鎺т欢 + Button tipBtn = new Button + { + Y = Application.GetRealHeight(69), + X = Application.GetRealWidth(150), + Height = Application.GetRealHeight(63), + Width = Application.GetRealWidth(492), + TextID = R.MyInternationalizationString.tip, + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicTipColor, + TextSize = 16, + + }; + topFrame.AddChidren(tipBtn); + ///鏂囨湰鎺т欢 + Button Text1Btn = new Button + { + Y = Application.GetRealHeight(187), + X = Application.GetRealWidth(50), + Height = Application.GetRealHeight(58), + Width = Application.GetRealWidth(792-100), + Text= tipText, + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + + }; + topFrame.AddChidren(Text1Btn); + + ///涓嬮潰蹇殑鐖舵帶浠� + FrameLayout bottomFrame = new FrameLayout + { + Y = topFrame.Bottom, + Width = Application.GetRealWidth(792), + Height = Application.GetRealHeight(127), + }; + tipFLayout.AddChidren(bottomFrame); + ///鍙栨秷鎺т欢 + Button cancelBtn = new Button + { + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicBtnCancelColor, + TextSize = 14, + Height = Application.GetRealHeight(127), + Width = Application.GetRealWidth(397), + BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor, + TextID = R.MyInternationalizationString.cancel, + }; + bottomFrame.AddChidren(cancelBtn); + ///纭鎺т欢 + Button okBtn = new Button + { + TextAlignment = TextAlignment.Center, + TextColor = ZigbeeColor.Current.LogicBlankBackgroundColor, + TextSize = 14, + X = cancelBtn.Right, + Height = Application.GetRealHeight(127), + Width = bottomFrame.Width - cancelBtn.Width, + BackgroundColor = ZigbeeColor.Current.LogicBtnTypeColor, + TextID = R.MyInternationalizationString.confrim, + }; + bottomFrame.AddChidren(okBtn); + + if (_if) + { + cancelBtn.X = Application.GetRealWidth(0); + cancelBtn.Width = Application.GetRealWidth(0); + okBtn.X = Application.GetRealWidth(0); + okBtn.Width = Application.GetRealWidth(792); + okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft | HDLUtils.RectCornerBottomRight); + } + else + { + cancelBtn.X = Application.GetRealWidth(0); + cancelBtn.Width = Application.GetRealWidth(397); + okBtn.X = Application.GetRealWidth(397); + okBtn.Width = bottomFrame.Width - cancelBtn.Width; + cancelBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft); + okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomRight); + + } + ///鍙栨秷鐐瑰嚮浜嬩欢 + cancelBtn.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + ///纭鐐瑰嚮浜嬩欢 + okBtn.MouseUpEventHandler += (sender, e) => + { + dialog.Close(); + }; + } } } -- Gitblit v1.8.0