using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using Shared;
namespace HDL_ON.UI.Music.View
{
public class TipView
{
///
/// 大框圆角值
///
public int RradiusFrameLayout = 15;
///
/// 小框圆角值
///
public int radiusEditFrameLayout = 4;
///
/// 输入框
///
/// 标题文本
/// 输入文本
/// 输入框文本为空自定义提示错误文本
/// 检索已存在名称自定义提示错误文本
/// 回调函数
/// 被检索列表
/// 回调函数
public void InputBox(int titleId, string tnputEditTxet,int errorId_IsNullOrEmpty, int errorId_PresenceP, List List, Action confirmAction)
{
Dialog dialog = new Dialog()
{
BackgroundColor = Color.PopupBackgroundColor,
};
FrameLayout whiteView = new FrameLayout()
{
//Gravity = Gravity.Center,
X=Application.GetRealWidth(53),
Y = Application.GetRealHeight(264),
Width = Application.GetRealWidth(270),
Height = Application.GetRealHeight(172),
BackgroundColor = Color.WhiteColor,
BorderColor = 0x00000000,
BorderWidth = 0,
Radius = (uint)Application.GetRealHeight(RradiusFrameLayout),
};
dialog.AddChidren(whiteView);
Button btnTitle = new Button()
{
Y = Application.GetRealHeight(20),
X=Application.GetRealWidth(35),
Height = Application.GetRealHeight(22),
Width=Application.GetRealWidth(200),
TextColor =Color.SelectedColor,
TextSize =TextSize.Text16,
TextAlignment = TextAlignment.Center,
TextID = titleId,
};
whiteView.AddChidren(btnTitle);
FrameLayout editBjView = new FrameLayout()
{
// Gravity = Gravity.CenterHorizontal,
Y = btnTitle.Bottom + Application.GetRealHeight(16),
X=Application.GetRealWidth(24),
Width = Application.GetRealWidth(222),
Height = Application.GetRealHeight(40),
BackgroundColor =Color.ViewColor,
BorderColor = 0x00000000,
BorderWidth = 0,
Radius = (uint)Application.GetMinRealAverage(radiusEditFrameLayout),
};
whiteView.AddChidren(editBjView);
EditText editText = new EditText()
{
X = Application.GetRealWidth(12),
Y=Application.GetRealHeight(10),
Width = Application.GetRealWidth(160),
Height=Application.GetRealHeight(20),
Text = tnputEditTxet,
TextColor = Color.TextColor,
TextSize = TextSize.Text14,
TextAlignment=TextAlignment.CenterLeft,
};
editBjView.AddChidren(editText);
Button clearIconBtn = new Button
{
X = Application.GetRealWidth(194),
Y = Application.GetRealHeight(8),
Width = Application.GetMinRealAverage(24),
Height = Application.GetMinRealAverage(24),
UnSelectedImagePath = "MusicIcon/clear.png",
};
editBjView.AddChidren(clearIconBtn);
clearIconBtn.MouseUpEventHandler += (sender, e) =>
{
editText.Text = "";
};
Button btnLine = new Button()
{
Y = whiteView.Height-Application.GetRealHeight(44+1),
Height = Application.GetRealHeight(1),
BackgroundColor =Color.LineColor,
};
whiteView.AddChidren(btnLine);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.TextCancelColor,
TextSize = TextSize.Text16,
TextID = StringId.cancelMusic,
Gravity = Gravity.BottomLeft,
};
whiteView.AddChidren(btnCancel);
btnCancel.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomLeft);
Button btnConfirm = new Button()
{
X = btnCancel.Right,
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.WhiteColor,
IsBold = true,
TextSize = TextSize.Text16,
TextID = StringId.confirmMusic,
BackgroundColor = Color.SelectedColor,
Gravity = Gravity.BottomRight,
};
whiteView.AddChidren(btnConfirm);
btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight);
dialog.Show();
btnCancel.MouseUpEventHandler += (sender, e) =>
{
dialog.Close();
};
Button btnTip = new Button
{
Width = Application.GetRealWidth(0),
};
whiteView.AddChidren(btnTip);//一直错误,一直猛点,一直加控件
btnConfirm.MouseUpEventHandler += (sender, e) =>
{
string listNameText = editText.Text.Trim();
if (string.IsNullOrEmpty(listNameText) || List.Contains(listNameText))
{
string tipMsgString = "";
if (string.IsNullOrEmpty(editText.Text.Trim()))
{
tipMsgString = Language.StringByID(errorId_IsNullOrEmpty);
}
else
{
tipMsgString = Language.StringByID(errorId_PresenceP);
}
whiteView.Height = Application.GetRealHeight(183);
btnLine.Y = whiteView.Height - Application.GetRealHeight(44 + 1);
btnCancel.Y = btnLine.Bottom;
btnCancel.Gravity = Gravity.BottomLeft;
btnConfirm.Y = btnLine.Bottom;
btnConfirm.Gravity = Gravity.BottomRight;
btnTip.X = Application.GetRealWidth(24);
btnTip.Y = editBjView.Bottom + Application.GetRealHeight(12);
btnTip.Width = Application.GetRealWidth(222);
btnTip.Height = Application.GetRealHeight(17);
btnTip.Text = tipMsgString;
btnTip.TextColor = Color.RedColor;
btnTip.TextSize = TextSize.Text12;
btnTip.TextAlignment = TextAlignment.CenterLeft;
return;
}
confirmAction(editText.Text.Trim());
dialog.Close();
};
}
///
/// 输入框
///
/// 标题文本
/// 输入文本
/// 输入框本文为空自定义提示错误文本
/// 回调函数
public void InputBox(int titleId, string tnputEditTxet, int errorId_IsNullOrEmpty, Action confirmAction)
{
Dialog dialog = new Dialog()
{
BackgroundColor = Color.PopupBackgroundColor,
};
FrameLayout whiteView = new FrameLayout()
{
//Gravity = Gravity.Center,
X = Application.GetRealWidth(53),
Y = Application.GetRealHeight(264),
Width = Application.GetRealWidth(270),
Height = Application.GetRealHeight(172),
BackgroundColor = Color.WhiteColor,
BorderColor = 0x00000000,
BorderWidth = 0,
Radius = (uint)Application.GetRealHeight(RradiusFrameLayout),
};
dialog.AddChidren(whiteView);
Button btnTitle = new Button()
{
Y = Application.GetRealHeight(20),
X = Application.GetRealWidth(35),
Height = Application.GetRealHeight(22),
Width = Application.GetRealWidth(200),
TextColor = Color.SelectedColor,
TextSize = TextSize.Text16,
TextAlignment = TextAlignment.Center,
TextID = titleId,
};
whiteView.AddChidren(btnTitle);
FrameLayout editBjView = new FrameLayout()
{
// Gravity = Gravity.CenterHorizontal,
Y = btnTitle.Bottom + Application.GetRealHeight(16),
X = Application.GetRealWidth(24),
Width = Application.GetRealWidth(222),
Height = Application.GetRealHeight(40),
BackgroundColor = Color.ViewColor,
BorderColor = 0x00000000,
BorderWidth = 0,
Radius = (uint)Application.GetMinRealAverage(radiusEditFrameLayout),
};
whiteView.AddChidren(editBjView);
EditText editText = new EditText()
{
X = Application.GetRealWidth(12),
Y = Application.GetRealHeight(10),
Width = Application.GetRealWidth(160),
Height = Application.GetRealHeight(20),
Text = tnputEditTxet,
TextColor = Color.TextColor,
TextSize = TextSize.Text14,
TextAlignment = TextAlignment.CenterLeft,
};
editBjView.AddChidren(editText);
Button clearIconBtn = new Button
{
X = Application.GetRealWidth(194),
Y = Application.GetRealHeight(8),
Width = Application.GetMinRealAverage(24),
Height = Application.GetMinRealAverage(24),
UnSelectedImagePath = "MusicIcon/clear.png",
};
editBjView.AddChidren(clearIconBtn);
clearIconBtn.MouseUpEventHandler += (sender, e) =>
{
editText.Text = "";
};
Button btnLine = new Button()
{
Y = whiteView.Height - Application.GetRealHeight(44 + 1),
Height = Application.GetRealHeight(1),
BackgroundColor = Color.LineColor,
};
whiteView.AddChidren(btnLine);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.TextCancelColor,
TextSize = TextSize.Text16,
TextID = StringId.cancelMusic,
Gravity = Gravity.BottomLeft,
};
whiteView.AddChidren(btnCancel);
btnCancel.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomLeft);
Button btnConfirm = new Button()
{
X = btnCancel.Right,
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.WhiteColor,
IsBold = true,
TextSize = TextSize.Text16,
TextID = StringId.confirmMusic,
BackgroundColor = Color.SelectedColor,
Gravity=Gravity.BottomRight,
};
whiteView.AddChidren(btnConfirm);
btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight);
dialog.Show();
btnCancel.MouseUpEventHandler += (sender, e) =>
{
dialog.Close();
};
Button btnTip = new Button
{
Width = Application.GetRealWidth(0),
};
whiteView.AddChidren(btnTip);//一直错误,一直猛点,一直加控件
btnConfirm.MouseUpEventHandler += (sender, e) =>
{
if (string.IsNullOrEmpty(editText.Text.Trim()))
{
whiteView.Height = Application.GetRealHeight(183);
btnLine.Y = whiteView.Height - Application.GetRealHeight(44 + 1);
btnCancel.Y = btnLine.Bottom;
btnCancel.Gravity = Gravity.BottomLeft;
btnConfirm.Y = btnLine.Bottom;
btnConfirm.Gravity = Gravity.BottomRight;
btnTip.X = Application.GetRealWidth(24);
btnTip.Y = editBjView.Bottom + Application.GetRealHeight(12);
btnTip.Width = Application.GetRealWidth(222);
btnTip.Height = Application.GetRealHeight(17);
btnTip.Text = Language.StringByID(errorId_IsNullOrEmpty);
btnTip.TextColor = Color.RedColor;
btnTip.TextSize = TextSize.Text12;
btnTip.TextAlignment = TextAlignment.CenterLeft;
return;
}
confirmAction(editText.Text.Trim());
dialog.Close();
};
}
///
/// 确定提示框
///
/// 标题文本
/// 自定义提示文本
/// 回调函数
public void TipBox(int titleId, int tipTxet, Action confirmAction)
{
Dialog dialog = new Dialog()
{
BackgroundColor = Color.PopupBackgroundColor,
};
FrameLayout whiteView = new FrameLayout()
{
//Gravity = Gravity.Center,
X = Application.GetRealWidth(53),
Y = Application.GetRealHeight(264),
Width = Application.GetRealWidth(270),
Height = Application.GetRealHeight(140),
BackgroundColor = Color.WhiteColor,
BorderColor = 0x00000000,
BorderWidth = 0,
Radius = (uint)Application.GetRealHeight(RradiusFrameLayout),
};
dialog.AddChidren(whiteView);
Button titleBtn = new Button()
{
Y = Application.GetRealHeight(20),
X = Application.GetRealWidth(35),
Height = Application.GetRealHeight(22),
Width = Application.GetRealWidth(270 - 35 * 2),
TextColor = Color.SelectedColor,
TextSize = TextSize.Text16,
TextAlignment = TextAlignment.Center,
TextID = titleId,
};
whiteView.AddChidren(titleBtn);
Button tipBtn = new Button()
{
Y = titleBtn.Bottom + Application.GetRealHeight(8),
X = Application.GetRealWidth(20),
Height = Application.GetRealHeight(22),
Width = Application.GetRealWidth(270 - 20 * 2),
TextColor = Color.TextCancelColor,
TextSize = TextSize.Text12,
TextAlignment = TextAlignment.Center,
TextID = tipTxet,
};
whiteView.AddChidren(tipBtn);
Button btnLine = new Button()
{
Y = whiteView.Height - Application.GetRealHeight(44 + 1),
Height = Application.GetRealHeight(1),
BackgroundColor = Color.LineColor,
};
whiteView.AddChidren(btnLine);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.TextCancelColor,
TextSize = TextSize.Text16,
TextID = StringId.cancelMusic,
Gravity = Gravity.BottomLeft,
};
whiteView.AddChidren(btnCancel);
btnCancel.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomLeft);
Button btnConfirm = new Button()
{
X = btnCancel.Right,
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = Color.WhiteColor,
IsBold = true,
TextSize = TextSize.Text16,
TextID = StringId.confirmMusic,
BackgroundColor = Color.SelectedColor,
Gravity = Gravity.BottomRight,
};
whiteView.AddChidren(btnConfirm);
btnConfirm.SetCornerWithSameRadius(Application.GetRealHeight(RradiusFrameLayout), HDLUtils.RectCornerBottomRight);
dialog.Show();
btnCancel.MouseUpEventHandler += (sender, e) =>
{
dialog.Close();
};
btnConfirm.MouseUpEventHandler += (sender, e) =>
{
confirmAction();
dialog.Close();
};
}
}
}