using System;
|
using System.Collections.Generic;
|
using Shared.Common;
|
using Shared.R;
|
|
namespace Shared.Phone.Device.Logic
|
{
|
public class PublicInterface
|
{
|
|
/// <summary>
|
/// 单选择
|
/// </summary>
|
/// <param name="frame">显示在哪个界面的父控件</param>
|
/// <param name="list">显示数据源</param>
|
/// <param name="titleText">标题文本</param>
|
/// <param name="stateText">之前状态文本</param>
|
/// <param name="action">返回值</param>
|
public void SingleSelectionShow(FrameLayout frame, List<string> list, int titleText, string stateText, Action<string> action)
|
{
|
FrameLayout frameLayout = new FrameLayout
|
{
|
BackgroundColor = ZigbeeColor.Current.LogicViewBackgroundColor,
|
};
|
frame.AddChidren(frameLayout);
|
CompleteView view = new CompleteView();
|
view.Btntitle.TextID = titleText;
|
frameLayout.AddChidren(view.Show(list.Count));
|
UserView.HomePage.Instance.ScrollEnabled = false;
|
view.Btncancel.MouseUpEventHandler += (sender, e) =>
|
{
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
//移除fLayout界面
|
frameLayout.RemoveFromParent();
|
};
|
///定义一个Btn记录选中状态
|
Button checkIconBtn = new Button
|
{
|
Tag = "unknown",
|
};
|
Button checkTextBtn = new Button
|
{
|
Tag = "unknown",
|
};
|
for (int i = 0; i < list.Count; i++)
|
{
|
string str = list[i];
|
mFunView mFun= new mFunView();
|
mFun.titleBtn.TextColor = ZigbeeColor.Current.LogicBtnNotSelectedColor;
|
mFun.titleBtn.SelectedTextColor = ZigbeeColor.Current.LogicBtnSelectedColor;
|
mFun.frameLayout.Y = Application.GetRealHeight(140 + 20 + 160 * i);
|
view.fraView.AddChidren(mFun.Show());
|
mFun.titleBtn.Text = str;
|
mFun.clickviewBtn.Tag = str;//标记
|
if (list.Count-1==i) {
|
//改变最后一条的颜色
|
mFun.lineBtn.BackgroundColor = ZigbeeColor.Current.LogicBackgroundColor;
|
}
|
if (stateText == str)
|
{
|
//图标改变
|
checkIconBtn.Visible = false;
|
mFun.selectedIconBtn.Visible = true;
|
checkIconBtn = mFun.selectedIconBtn;
|
checkIconBtn.Tag = mFun.clickviewBtn.Tag.ToString();
|
//字体改变
|
checkTextBtn.IsSelected = false;
|
mFun.titleBtn.IsSelected = true;
|
checkTextBtn = mFun.titleBtn;
|
|
}
|
//点击事件
|
mFun.clickviewBtn.MouseUpEventHandler += (sender1, e1) =>
|
{
|
//图标改变
|
checkIconBtn.Visible = false;
|
mFun.selectedIconBtn.Visible = true;
|
checkIconBtn = mFun.selectedIconBtn;
|
checkIconBtn.Tag = mFun.clickviewBtn.Tag.ToString();
|
//字体改变
|
checkTextBtn.IsSelected = false;
|
mFun.titleBtn.IsSelected = true;
|
checkTextBtn = mFun.titleBtn;
|
};
|
|
}
|
view.Btncomplete.MouseUpEventHandler += (sender1, e1) =>
|
{
|
if (checkIconBtn.Tag.ToString() == "unknown")
|
{
|
return;
|
}
|
action(checkIconBtn.Tag.ToString());
|
UserView.HomePage.Instance.ScrollEnabled = true;
|
//移除fLayout界面
|
frameLayout.RemoveFromParent();
|
};
|
|
}
|
|
|
/// <summary>
|
/// 获取界面列表
|
/// </summary>
|
/// <param name="isStr">自己定义自己用</param>
|
/// <returns></returns>
|
public List<string> GetViewList(string isStr)
|
{
|
List<string> list = null;
|
switch (isStr)
|
{
|
case "安防":
|
{
|
list = new List<string> {
|
Language.StringByID(MyInternationalizationString.logicathomegarrison),
|
Language.StringByID(MyInternationalizationString.logicremovehomegarrison),
|
Language.StringByID(MyInternationalizationString.withdrawal),
|
Language.StringByID(MyInternationalizationString.urgentwithdrawal),
|
};
|
}
|
break;
|
case "时间": {
|
list = new List<string> {
|
Language.StringByID(MyInternationalizationString.immediateexecution),
|
Language.StringByID(MyInternationalizationString.timeframe),
|
};
|
}
|
break;
|
case "地理围栏":
|
{
|
list = new List<string> {
|
Language.StringByID(MyInternationalizationString.athome),
|
Language.StringByID(MyInternationalizationString.leavehome),
|
};
|
}
|
break;
|
case "组合条件":
|
{
|
list = new List<string> {
|
Language.StringByID(MyInternationalizationString.Allconditions),
|
Language.StringByID(MyInternationalizationString.anycondition),
|
};
|
}
|
break;
|
|
|
}
|
return list;
|
}
|
}
|
}
|