using Shared;
using HDL_ON.UI.CSS;
using System;
using System.Collections.Generic;
using System.Text;
namespace HDL_ON.Stan
{
///
/// 底部项目编辑控件
///
public class BottomItemEditorControl : BottomDialogCommon
{
#region ■ 变量声明___________________________
///
/// 结束事件(0:点击了取消 1:点击了确定)
///
public Action FinishEvent = null;
///
/// 列表控件
///
private VerticalListControl listView = null;
#endregion
#region ■ 初始化_____________________________
///
/// 有标题的弹窗型菜单编辑控件
///
/// 菜单行数(不含标题)
/// 标题
/// 点击背景时,是否关闭弹窗
public BottomItemEditorControl(int i_RowCount, string i_title, bool clickBackClose = true)
{
//最大显示7个
base.RowCount = i_RowCount > 7 ? 7 : i_RowCount;
base.ClickBackClose = clickBackClose;
base.StrTitle = i_title;
}
///
/// 初始化控件
///
private void InitControl()
{
//已经初始化
if (base.btnCancel != null) { return; }
//初始化底层控件
var frameWhiteBack = base.InitBaseControl();
//取消
base.btnCancel.ButtonClickEvent += (sender, e) =>
{
base.Close();
this.FinishEvent?.Invoke(0);
this.FinishEvent = null;
};
//确认
base.btnConfirm.ButtonClickEvent += (sender, e) =>
{
base.Close();
this.FinishEvent?.Invoke(1);
this.FinishEvent = null;
};
//列表控件
this.listView = new VerticalListControl();
listView.Y = btnConfirm.Bottom;
listView.Height = this.RowCount * this.RowHeight;
frameWhiteBack.AddChidren(listView);
}
#endregion
#region ■ 添加菜单___________________________
///
/// 添加菜单行
///
/// 左边显示的文字
/// 右边显示的值(
/// 单击菜单执行的事件(参数为右边显示值的那个控件)
public void AddRowMenu(string i_textView, string i_textValue, Action clickEvent)
{
//先初始化控件
this.InitControl();
//它的上一行
var rowBefor = this.listView.GetChildren(this.listView.ChildrenCount - 1) as FrameRowControl;
if (rowBefor != null)
{
//画底线
var btnLine = rowBefor.AddBottomLine();
btnLine.Width = rowBefor.Width - Application.GetRealWidth(20) * 2;
btnLine.Gravity = Gravity.CenterHorizontal;
}
//行
var rowContr = new FrameRowControl();
rowContr.LeftOffset = Application.GetRealWidth(20) - HdlControlResourse.XXLeft;
rowContr.RightOffset = - rowContr.LeftOffset;
rowContr.Width = this.listView.Width;
rowContr.Height = this.RowHeight;
this.listView.AddChidren(rowContr);
//显示文本
var btnView = rowContr.AddLeftCaption(i_textView, 150);
btnView.Width = btnView.GetRealWidthByText();
btnView.TextColor = CSS_Color.FirstLevelTitleColor;
//添加右箭头
rowContr.AddRightArrow();
//添加右边的文本
var btnValue = rowContr.AddMostRightView(i_textValue, 150);
rowContr.ButtonClickEvent += (sender, e) =>
{
clickEvent?.Invoke(btnValue);
};
}
#endregion
#region ■ 一般方法___________________________
///
/// 关闭界面
///
public override void Close()
{
base.Close();
this.FinishEvent = null;
}
#endregion
}
}