using System;
|
using System.Collections.Generic;
|
using Shared;
|
namespace HDL_ON.UI.UI2.Intelligence.Automation
|
{
|
public class PublicInterface
|
{
|
/// <summary>
|
/// 单选择
|
/// </summary>
|
/// <param name="frameLayout">父控件</param>
|
/// <param name="list">显示数据源</param>
|
/// <param name="titleText"></param>
|
/// <param name="stateText">之前状态文本</param>
|
/// <param name="action">返回值</param>
|
public void SingleSelectionShow(FrameLayout frameLayout, List<string> list, string titleText, string stateText, Action<string> action)
|
{
|
LogicView.DateView view = new LogicView.DateView();
|
view.btnTitle.Text = titleText;
|
view.FLayoutView(frameLayout, list.Count);
|
view.btnCancel.MouseUpEventHandler += (sender, e) =>
|
{
|
//移除fLayout界面
|
frameLayout.RemoveFromParent();
|
};
|
///定义一个Btn记录选中状态
|
Button checkBtn = new Button
|
{
|
Tag = "unknown",
|
};
|
for (int i = 0; i < list.Count; i++)
|
{
|
string str = list[i];
|
LogicView.CheckView checkView = new LogicView.CheckView();
|
checkView.frameLayout.Y = Application.GetRealHeight(56 + 50 * i);
|
view.frameLayout.AddChidren(checkView.FLayoutView());
|
checkView.btnText.Text = str;
|
checkView.btnClick.Tag = str;//标记
|
|
if (stateText == str)
|
{
|
//显示之前的选中状态
|
checkBtn.IsSelected = false;
|
checkView.btnCheckIcon.IsSelected = true;
|
checkBtn = checkView.btnCheckIcon;
|
checkBtn.Tag = checkView.btnClick.Tag.ToString();
|
}
|
//点击事件
|
checkView.btnClick.MouseUpEventHandler += (sender1, e1) =>
|
{
|
checkBtn.IsSelected = false;
|
checkView.btnCheckIcon.IsSelected = true;
|
checkBtn = checkView.btnCheckIcon;
|
checkBtn.Tag = checkView.btnClick.Tag.ToString();
|
};
|
|
}
|
view.btnConfirm.MouseUpEventHandler += (sender1, e1) =>
|
{
|
if (checkBtn.Tag.ToString() == "unknown")
|
{
|
return;
|
}
|
action(checkBtn.Tag.ToString());
|
//移除fLayout界面
|
frameLayout.RemoveFromParent();
|
};
|
|
}
|
/// <summary>
|
/// 多选择
|
/// </summary>
|
/// <param name="frameLayout">父控件</param>
|
/// <param name="list">显示数据源</param>
|
/// <param name="titleText"></param>
|
/// <param name="stateTextList">之前状态文本</param>
|
/// <param name="action">返回值</param>
|
public void MultiSelectShow(FrameLayout frameLayout, List<string> list, string titleText, List<string> stateTextList, Action<List<string>> action)
|
{
|
LogicView.DateView view = new LogicView.DateView();
|
view.btnTitle.Text = titleText;
|
view.FLayoutView(frameLayout, list.Count);
|
view.btnCancel.MouseUpEventHandler += (sender, e) =>
|
{
|
//移除fLayout界面
|
view.frameLayout.RemoveFromParent();
|
};
|
for (int i = 0; i < list.Count; i++)
|
{
|
string str = list[i];
|
LogicView.CheckView checkView = new LogicView.CheckView();
|
checkView.frameLayout.Y = Application.GetRealHeight(56 + 50 * i);
|
view.frameLayout.AddChidren(checkView.FLayoutView());
|
checkView.btnText.Text = str;
|
checkView.btnClick.Tag = str;//标记
|
|
if (stateTextList.Contains(str))
|
{
|
//显示之前的选中状态
|
checkView.btnCheckIcon.IsSelected = true;
|
}
|
//点击事件
|
checkView.btnClick.MouseUpEventHandler += (sender1, e1) =>
|
{
|
|
string clickIndex = checkView.btnClick.Tag.ToString();
|
checkView.btnClick.IsSelected = !checkView.btnClick.IsSelected;
|
if (checkView.btnClick.IsSelected)
|
{
|
checkView.btnCheckIcon.IsSelected = true;
|
if (!stateTextList.Contains(clickIndex))
|
{
|
//添加选中数据
|
stateTextList.Add(clickIndex);
|
}
|
}
|
else
|
{
|
checkView.btnCheckIcon.IsSelected = false;
|
if (stateTextList.Contains(clickIndex))
|
{
|
//移除选中数据
|
stateTextList.Remove(clickIndex);
|
}
|
}
|
|
};
|
|
}
|
view.btnConfirm.MouseUpEventHandler += (sender1, e1) =>
|
{
|
if (stateTextList.Count == 0)
|
{
|
return;
|
}
|
action(stateTextList);
|
//移除fLayout界面
|
frameLayout.RemoveFromParent();
|
};
|
|
}
|
|
|
}
|
}
|