using System;
|
using Shared.Common;
|
|
namespace Shared.Phone.Device.Logic.LogicView
|
{
|
public class TipView
|
{
|
/// <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),
|
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
|
{
|
TextID = R.MyInternationalizationString.Tip,
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicTipColor,
|
TextSize = 16,
|
Y = Application.GetRealHeight(69),
|
X = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(63),
|
Width = Application.GetRealWidth(492),
|
};
|
topFrame.AddChidren(tipBtn);
|
///自定义文本控件
|
Button tipTextBtn = new Button
|
{
|
Text = Language.StringByID(R.MyInternationalizationString.SetDoorLockNomallyOpen).Replace("{0}", "\r\n"),
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicTipTextColor,
|
TextSize = 14,
|
Y = tipBtn.Bottom + Application.GetRealHeight(35),
|
X = Application.GetRealWidth(60),
|
Height = Application.GetRealHeight(115),
|
Width = Application.GetRealWidth(674),
|
IsMoreLines = true,
|
};
|
topFrame.AddChidren(tipTextBtn);
|
///下面快的父控件
|
FrameLayout bottomFrame = new FrameLayout
|
{
|
Y = topFrame.Bottom,
|
Width = Application.GetRealWidth(792),
|
Height = Application.GetRealHeight(127),
|
Gravity = Gravity.BottomCenter,
|
};
|
tipFLayout.AddChidren(bottomFrame);
|
|
///取消控件
|
Button cancelBtn = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
|
TextSize = 14,
|
Height = bottomFrame.Height,
|
Width = Application.GetRealWidth(397),
|
BackgroundColor = ZigbeeColor.Current.LogicMiddleBackgroundColor,
|
TextID = R.MyInternationalizationString.cancel,
|
};
|
bottomFrame.AddChidren(cancelBtn);
|
cancelBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomLeft);
|
///确认控件
|
Button okBtn = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
|
TextSize = 14,
|
X = cancelBtn.Right,
|
Height = bottomFrame.Height,
|
Width = bottomFrame.Width - cancelBtn.Width,
|
BackgroundColor = ZigbeeColor.Current.LogicBtnTypeColor,
|
TextID = R.MyInternationalizationString.confrim,
|
};
|
bottomFrame.AddChidren(okBtn);
|
okBtn.SetCornerWithSameRadius(Application.GetRealHeight(17), HDLUtils.RectCornerBottomRight);
|
///取消点击事件
|
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),
|
Gravity=Gravity.BottomCenter,
|
};
|
tipFLayout.AddChidren(bottomFrame);
|
///取消控件
|
Button cancelBtn = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
|
TextSize = 14,
|
Height = bottomFrame.Height,
|
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 = bottomFrame.Height,
|
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))
|
{
|
ShowErrorTip(Language.StringByID(R.MyInternationalizationString.timeNull),true);
|
return;
|
}
|
if (int.Parse(editTime.Text) < 1 || int.Parse(editTime.Text) > 12|| int.Parse(editTime.Text)>(int.MaxValue-1))
|
{ ///限制输入数字范围;
|
string str = Language.StringByID(R.MyInternationalizationString.less) + Language.StringByID(R.MyInternationalizationString.or) + Language.StringByID(R.MyInternationalizationString.more);
|
ShowErrorTip(str, true);
|
return;
|
|
|
}
|
action(editTime.Text);
|
dialog.Close();
|
|
};
|
|
}
|
/// <summary>
|
/// 错误提示框
|
/// </summary>
|
public static void ShowErrorTip(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),
|
Gravity = Gravity.BottomCenter,
|
};
|
tipFLayout.AddChidren(bottomFrame);
|
///取消控件
|
Button cancelBtn = new Button
|
{
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
|
TextSize = 14,
|
Height = bottomFrame.Height,
|
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 = bottomFrame.Height,
|
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();
|
};
|
}
|
/// <summary>
|
/// 闪错提示框
|
/// </summary>
|
public static void ShowFlashTip(string tipText,int timeValue=1)
|
{
|
///主控件
|
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(230),
|
Y = Application.GetRealHeight(717),
|
Width = Application.GetRealWidth(622),
|
Height = Application.GetRealHeight(317),
|
BackgroundColor = ZigbeeColor.Current.LogicBlankBackgroundColor,
|
Radius = (uint)Application.GetRealHeight(17)
|
};
|
fLayout.AddChidren(tipFLayout);
|
|
///提示控件
|
Button tipBtn = new Button
|
{
|
Y = Application.GetRealHeight(58),
|
X = Application.GetRealWidth(150),
|
Height = Application.GetRealHeight(63),
|
Width = Application.GetRealWidth(622 - 300),
|
TextID = R.MyInternationalizationString.tip,
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicTipColor,
|
TextSize = 16,
|
|
};
|
tipFLayout.AddChidren(tipBtn);
|
///文本控件
|
Button Text1Btn = new Button
|
{
|
Y = Application.GetRealHeight(156),
|
X = Application.GetRealWidth(50),
|
Height = Application.GetRealHeight(58),
|
Width = Application.GetRealWidth(622 - 100),
|
Text = tipText,
|
TextAlignment = TextAlignment.Center,
|
TextColor = ZigbeeColor.Current.LogicBtnCancelColor,
|
TextSize = 14,
|
};
|
tipFLayout.AddChidren(Text1Btn);
|
|
new System.Threading.Thread(() =>
|
{
|
System.Threading.Thread.Sleep(timeValue*1000);
|
Application.RunOnMainThread(() =>
|
{
|
dialog.Close();
|
});
|
})
|
{ IsBackground = true }.Start();
|
}
|
}
|
}
|