using Shared;
|
using HDL_ON.UI.CSS;
|
using System;
|
using System.Collections.Generic;
|
using System.Text;
|
|
namespace HDL_ON.Stan
|
{
|
/// <summary>
|
/// 底部项目编辑控件
|
/// </summary>
|
public class BottomItemEditorControl : BottomDialogCommon
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 结束事件(0:点击了取消 1:点击了确定)
|
/// </summary>
|
public Action<int> FinishEvent = null;
|
/// <summary>
|
/// 列表控件
|
/// </summary>
|
private VerticalListControl listView = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 有标题的弹窗型菜单编辑控件
|
/// </summary>
|
/// <param name="i_RowCount">菜单行数(不含标题)</param>
|
/// <param name="i_title">标题</param>
|
/// <param name="clickBackClose">点击背景时,是否关闭弹窗</param>
|
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;
|
}
|
|
/// <summary>
|
/// 初始化控件
|
/// </summary>
|
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 ■ 添加菜单___________________________
|
|
/// <summary>
|
/// 添加菜单行
|
/// </summary>
|
/// <param name="i_textView">左边显示的文字</param>
|
/// <param name="i_textValue">右边显示的值(</param>
|
/// <param name="clickEvent">单击菜单执行的事件(参数为右边显示值的那个控件)</param>
|
public void AddRowMenu(string i_textView, string i_textValue, Action<NormalViewControl> 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 ■ 一般方法___________________________
|
|
/// <summary>
|
/// 关闭界面
|
/// </summary>
|
public override void Close()
|
{
|
base.Close();
|
this.FinishEvent = null;
|
}
|
|
#endregion
|
}
|
}
|