using System;
using System.Collections.Generic;
using HDL_ON.UI.CSS;
using HDL_ON.UI.Music;
using Shared;
namespace HDL_ON.UI.UI2.PersonalCenter.PirDevice.View
{
public class TipView
{
///
/// 大框圆角值
///
public int RradiusFrameLayout = 15;
///
/// 小框圆角值
///
public int radiusEditFrameLayout = 4;
///
/// 输入框
///
/// 回调函数
public void InputBox(string tnputEditTxet, Action confirmAction,bool if_bool=true)
{
Dialog dialog = new Dialog()
{
BackgroundColor = MusicColor.PopupBackgroundColor,
};
FrameLayout whiteView = new FrameLayout()
{
//Gravity = Gravity.Center,
X = Application.GetRealWidth(53),
Y = Application.GetRealHeight(264),
Width = Application.GetRealWidth(270),
Height = Application.GetRealHeight(201),
BackgroundColor = MusicColor.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 = MusicColor.SelectedColor,
TextSize = TextSize.Text16,
TextAlignment = TextAlignment.Center,
TextID = StringId.shuruyaokongqimingcheng,
};
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 = MusicColor.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 = MusicColor.TextColor,
TextSize = TextSize.Text14,
TextAlignment = TextAlignment.CenterLeft,
};
editBjView.AddChidren(editText);
Button clearIconBtn = new Button
{
X = Application.GetRealWidth(194),
Y = Application.GetRealHeight(8),
Width = Application.GetRealWidth(24),
Height = Application.GetRealWidth(24),
UnSelectedImagePath = "MusicIcon/clear.png",
};
editBjView.AddChidren(clearIconBtn);
clearIconBtn.MouseUpEventHandler += (sender, e) =>
{
editText.Text = "";
};
Button btnTipText = new Button
{
X = Application.GetRealWidth(24),
Y = editBjView.Bottom + Application.GetRealHeight(12),
Width = Application.GetRealWidth(211),
Height = Application.GetRealHeight(35),
Text = Language.StringByID(StringId.fengleichazhao).Replace("{\\r\\n}", "\r\n"),
IsMoreLines = true,
TextColor = MusicColor.MusicNoTxetColor,
TextSize = TextSize.Text12,
TextAlignment = TextAlignment.CenterLeft,
};
whiteView.AddChidren(btnTipText);
Button btnLine = new Button()
{
Y = whiteView.Height -Application.GetRealHeight(44 + 1),
Height = Application.GetRealHeight(1),
BackgroundColor = MusicColor.LineColor,
};
whiteView.AddChidren(btnLine);
Button btnCancel = new Button()
{
Y = btnLine.Bottom,
Width = Application.GetRealWidth(135),
Height = Application.GetRealHeight(44),
TextAlignment = TextAlignment.Center,
TextColor = MusicColor.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 = MusicColor.WhiteColor,
IsBold = true,
TextSize = TextSize.Text16,
TextID = StringId.confirmMusic,
BackgroundColor = MusicColor.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) =>
{
if (string.IsNullOrEmpty(editText.Text.Trim()))
{
return;
}
confirmAction(editText.Text.Trim(), dialog);
if (if_bool) {
dialog.Close();
}
};
}
}
}