using System;
using Shared;
using HDL_ON.UI.CSS;
namespace HDL_ON.UI
{
///
/// UpdateTipDialog
///
public class UpdateTipDialog : Dialog
{
public UpdateTipDialog()
{
}
///
/// 初始化Dialog
///
///
///
///
///
///
///
///
void ShowDialogBase(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction, bool isForceUpdate, 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 btnTitle = 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(btnTitle);
Button btnTip = new Button()
{
Gravity = Gravity.CenterHorizontal,
Y = btnTitle.Bottom,
Height = Application.GetMinRealAverage(17),
TextAlignment = TextAlignment.Center,
TextColor = CSS_Color.PromptingColor1,
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
Text = tipStr
};
contentView.AddChidren(btnTip);
int btnMesY = btnTip.Bottom + Application.GetMinRealAverage(5);
int lineY = Application.GetRealHeight(258);
VerticalScrolViewLayout mesView = new VerticalScrolViewLayout()
{
X = Application.GetRealWidth(16),
Y = btnMesY,
Width = contentView.Width - Application.GetRealWidth(32),
Height = lineY - btnMesY - Application.GetMinRealAverage(5),
};
contentView.AddChidren(mesView);
TextButton btnMes = new TextButton()
{
//Gravity = Gravity.CenterHorizontal,
Width = mesView.Width,
//Height = mesView.Height,
Height = Application.GetRealWidth(20),
TextAlignment = TextAlignment.TopLeft,
TextColor = CSS_Color.TextualColor,
TextSize = CSS_FontSize.TextFontSize,
Text = msgStr,
//BackgroundColor = CSS_Color.AuxiliaryColor2
};
mesView.AddChidren(btnMes);
//动态计算高度
var needHeight = btnMes.GetMoreLineNeedHeight();
if(needHeight < mesView.Height)
{
needHeight = mesView.Height;
}
btnMes.IsMoreLines = true;
btnMes.Height = needHeight;
//mesView.AddChidren(btnMes);
Button btnLine = new Button()
{
Y = lineY,
Height = Application.GetRealHeight(1),
Width = contentView.Width,
BackgroundColor = CSS_Color.DividingLineColor,
};
contentView.AddChidren(btnLine);
if (!isForceUpdate)
{
int Width144 = Application.GetRealWidth(144);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Width144,
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 = contentView.Width - Width144,
Y = btnLine.Y,
Width = Width144,
Height = Application.GetRealHeight(45),
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();
};
}
else
{
Button btnConfirm = new Button()
{
Y = btnLine.Y,
Width = contentView.Width,
Height = Application.GetRealHeight(45),
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 | HDLUtils.RectCornerBottomLeft;
btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
btnConfirm.MouseUpEventHandler += (sender, e) =>
{
//dialog禁止关闭
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 ShowUpdateDialog(string titleStr, string tipStr, string msgStr, Action okAction, Action cancelAction = null)
{
this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, cancelAction, false);
}
///
/// 加载强制更新Dialog
/// Dialog不关闭
///
///
///
///
///
///
public void ShowForcedUpdateDialog(string titleStr, string tipStr, string msgStr, Action okAction)
{
this.ShowDialogBase(titleStr, tipStr, msgStr, okAction, null, true);
}
///
/// 初始化Dialog
///
///
///
///
///
///
///
///
void ShowTipDialogBase(string titleStr, string msgStr, Action okAction, int confirmID = StringId.Close)
{
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 btnTitle = 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(btnTitle);
int btnMesY = btnTitle.Bottom + Application.GetMinRealAverage(5);
int lineY = Application.GetRealHeight(258);
VerticalScrolViewLayout mesView = new VerticalScrolViewLayout()
{
X = Application.GetRealWidth(16),
Y = btnMesY,
Width = contentView.Width - Application.GetRealWidth(32),
Height = lineY - btnMesY - Application.GetMinRealAverage(5),
};
contentView.AddChidren(mesView);
Button btnMes = new Button()
{
Gravity = Gravity.CenterHorizontal,
Width = mesView.Width,
Height = mesView.Height,
TextAlignment = TextAlignment.TopLeft,
TextColor = CSS_Color.TextualColor,
TextSize = CSS_FontSize.TextFontSize,
IsMoreLines = true,
Text = msgStr,
BackgroundColor = CSS_Color.AuxiliaryColor2
};
mesView.AddChidren(btnMes);
Button btnLine = new Button()
{
Y = lineY,
Height = Application.GetRealHeight(1),
Width = contentView.Width,
BackgroundColor = CSS_Color.DividingLineColor,
};
contentView.AddChidren(btnLine);
Button btnConfirm = new Button()
{
Y = btnLine.Y,
Width = contentView.Width,
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 | HDLUtils.RectCornerBottomLeft;
btnConfirm.SetCornerWithSameRadius((uint)Application.GetMinRealAverage(10), mRectCornerID);
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 ShowTipDialog(string titleStr, string msgStr, Action okAction)
{
this.ShowTipDialogBase(titleStr, msgStr, okAction);
}
}
}