using System;
|
using System.Collections.Generic;
|
using Shared;
|
namespace HDL_ON.UI.UI2.Intelligence.Automation
|
{
|
public class Security : FrameLayout
|
{
|
public Security()
|
{
|
Tag = "Logic";
|
}
|
public void Show()
|
{
|
|
LogicView.TopView topView = new LogicView.TopView();
|
this.AddChidren(topView.FLayoutView());
|
topView.clickBackBtn.MouseUpEventHandler += (e, sen) =>
|
{
|
RemoveFromParent();
|
};
|
topView.topNameBtn.TextID = StringId.addSecurityLogic;
|
|
VerticalScrolViewLayout viewLayout = new VerticalScrolViewLayout
|
{
|
Y = Application.GetRealHeight(64),
|
Width = Application.GetRealWidth(LogicView.TextSize.view375),
|
Height = Application.GetRealHeight(LogicView.TextSize.view667 - 64),
|
BackgroundColor = CSS.CSS_Color.viewMiddle,
|
};
|
this.AddChidren(viewLayout);
|
var securityList = LogicMethod.CurrLogicMethod.GetSecurityList();
|
for (int i = 0; i < securityList.Count; i++)
|
{
|
var security = securityList[i];
|
LogicView.SelectTypeView securityView = new LogicView.SelectTypeView();
|
securityView.btnText.Text = security.name;
|
securityView.btnIcon.UnSelectedImagePath = "LogicIcon/security.png";
|
viewLayout.AddChidren(securityView.FLayoutView());
|
securityView.btnClick.MouseUpEventHandler += (sen, e) =>
|
{
|
SecurityMethod(this, security.sid);
|
};
|
}
|
|
}
|
|
|
/// <summary>
|
/// 添加安防
|
/// </summary>
|
public void SecurityMethod(FrameLayout frameLayout,string sid, bool edit = false, int index1 = -1)
|
{
|
string stateStr = "";
|
if (edit && index1 != -1)
|
{
|
Output output = Logic.currlogic.output[index1];
|
sid = output.sid;
|
for (int i = 0; i < output.status.Count; i++)
|
{
|
var dic = output.status[i];
|
if (dic.ContainsKey("value"))
|
{
|
if (dic["value"] == "enable")
|
{
|
stateStr = Language.StringByID(StringId.bufang);
|
|
}
|
else
|
{
|
stateStr = Language.StringByID(StringId.chefang);
|
}
|
}
|
}
|
}
|
PublicInterface conditionView = new PublicInterface();
|
var strList = conditionView.GetViewList("security");
|
conditionView.SingleSelectionShow(frameLayout, strList, Language.StringByID(StringId.addSecurityLogic), stateStr
|
, (stateValue) =>
|
{
|
|
string selecttionMode = "";
|
if (stateValue == Language.StringByID(StringId.bufang))
|
{
|
selecttionMode = "enable";
|
}
|
else
|
{
|
selecttionMode = "disable";
|
}
|
//封装数据
|
Output outputDevice = new Output();
|
outputDevice.target_type = "3";
|
outputDevice.sid = sid;
|
outputDevice.status = new List<Dictionary<string, string>> { new Dictionary<string, string> { { "key", "security" }, { "value", selecttionMode } } };
|
AddOutput(outputDevice, true);
|
LogicMethod.CurrLogicMethod.RemoveAllView();
|
AddLogic addLogic = new AddLogic();
|
MainPage.BasePageView.AddChidren(addLogic);
|
addLogic.Show();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
|
});
|
|
}
|
|
/// <summary>
|
/// 添加目标
|
/// </summary>
|
/// <param name="target"></param>
|
/// <param name="bool_if">表示启用不同条件</param>
|
private void AddOutput(Output target, bool bool_if = false)
|
{
|
int indexValue = -1;
|
for (int i = 0; i < Logic.currlogic.output.Count; i++)
|
{
|
if (bool_if)
|
{
|
///安防允许一种
|
if (Logic.currlogic.output[i].target_type == target.target_type)
|
{
|
indexValue = i;
|
break;
|
}
|
}
|
else
|
{
|
if (Logic.currlogic.output[i].sid == target.sid)
|
{
|
indexValue = i;
|
break;
|
}
|
}
|
}
|
if (indexValue != -1)
|
{
|
Logic.currlogic.output.RemoveAt(indexValue);
|
Logic.currlogic.output.Insert(indexValue, target);
|
}
|
else
|
{
|
Logic.currlogic.output.Add(target);
|
}
|
|
}
|
}
|
}
|