using System;
using Shared;
using HDL_ON.UI.CSS;
namespace HDL_ON.UI
{
///
/// 通用二次确认界面
/// 可以自定义按钮文字
///
public class TipDialog : Dialog
{
public TipDialog()
{
}
///
/// 初始化Dialog
///
///
///
///
///
///
///
///
void ShowDialogBase(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction, int cancelID = StringId.Ignore, int confirmID = StringId.Update)
{
this.BackgroundColor = CSS_Color.DialogTransparentColor1;
FrameLayout contentView = new FrameLayout()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetMinRealAverage(223),
Width = Application.GetRealWidth(288),
Height = Application.GetRealHeight(302),
BackgroundColor = CSS_Color.MainBackgroundColor,
Radius = (uint)Application.GetRealWidth(12),
BorderWidth = 0,
BorderColor = 0x00000000,
};
this.AddChidren(contentView);
Button btnTipRegisterSuccess = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetMinRealAverage(95),
Height = Application.GetMinRealAverage(30),
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.MainColor,
TextSize = CSS_FontSize.EmphasisFontSize_Secondary,
Text = titleStr
};
contentView.AddChidren(btnTipRegisterSuccess);
Button btnTip = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = btnTipRegisterSuccess.Bottom,
Height = Application.GetMinRealAverage(17),
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.PromptingColor1,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
Text = tipStr
};
contentView.AddChidren(btnTip);
Button btnMes = new Button()
{
Gravity = Gravity.CenterHorizontal,
X = Application.GetRealWidth(25),
Y = btnTip.Bottom + Application.GetMinRealAverage(28),
Width = contentView.Width - Application.GetRealWidth(50),
Height = Application.GetRealHeight(80),
TextAlignment = TextAlignment.TopLeft,
TextColor = CSS_Color.TextualColor,
TextSize = CSS_FontSize.TextFontSize,
IsMoreLines = true,
Text = msgStr,
};
contentView.AddChidren(btnMes);
Button btnLine = new Button()
{
Y = Application.GetRealHeight(258),
Height = Application.GetRealHeight(1),
Width = contentView.Width,
BackgroundColor = CSS_Color.DividingLineColor,
};
contentView.AddChidren(btnLine);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Application.GetRealWidth(144),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.TextualColor,
TextSize = CSS_FontSize.SubheadingFontSize,
TextID = cancelID,
};
contentView.AddChidren(btnCancel);
Button btnConfirm = new Button()
{
X = btnCancel.Right,
Y = btnLine.Y,
Width = Application.GetRealWidth(144),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextSize = CSS_FontSize.SubheadingFontSize,
TextColor = CSS_Color.MainBackgroundColor,
BackgroundColor = CSS_Color.MainColor,
TextID = confirmID,
};
contentView.AddChidren(btnConfirm);
//例:右下圆角 大小为50
int mRectCornerID = HDLUtils.RectCornerBottomRight;
btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
btnCancel.MouseUpEventHandler += (sender, e) =>
{
this.Close();
cancelAction?.Invoke();
};
btnConfirm.MouseUpEventHandler += (sender, e) =>
{
this.Close();
okAction?.Invoke();
};
Button btnHeadImage = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = Application.GetMinRealAverage(152),
Width = Application.GetMinRealAverage(160),
Height = Application.GetMinRealAverage(160),
BorderColor = 0x00000000,
BorderWidth = 0,
UnSelectedImagePath = "Public/Dialog/DialogTipTitleIcon_3.png",
};
this.AddChidren(btnHeadImage);
this.Show();
}
///
/// 加载提示Dialog
///
///
///
///
///
///
public void ShowDialog(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction = null)
{
this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, cancelAction);
}
}
}