using System;
|
using System.Collections.Generic;
|
using HDL_ON.DAL.Server;
|
using HDL_ON.Entity;
|
using HDL_ON.UI.CSS;
|
using Shared;
|
namespace HDL_ON.UI
|
{
|
public class AddAlarmDeploymentPage : FrameLayout
|
{
|
FrameLayout bodyView;
|
/// <summary>
|
/// 主题界面
|
/// </summary>
|
VerticalScrolViewLayout contentView;
|
/// <summary>
|
/// 输入条件列表区域界面
|
/// </summary>
|
VerticalScrolViewLayout inputTargetView;
|
/// <summary>
|
/// 告警目标列表区域界面
|
/// </summary>
|
VerticalScrolViewLayout outputTargetView;
|
|
|
SecurityAlarm securityAlarm;
|
Action refreshAction;
|
|
/// <summary>
|
/// 安防输出-临时
|
/// </summary>
|
List<SecurityOutput> tempOutput = new List<SecurityOutput>();
|
/// <summary>
|
/// 安防输入-临时
|
/// </summary>
|
List<SecurityInput> tempInput = new List<SecurityInput>();
|
|
|
public AddAlarmDeploymentPage(SecurityAlarm alarm, Action action)
|
{
|
bodyView = this;
|
securityAlarm = alarm;
|
refreshAction = action;
|
}
|
|
public void LoadPage(string title = "")
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
|
contentView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(527),
|
};
|
bodyView.AddChidren(contentView);
|
|
if (string.IsNullOrEmpty(title))
|
{
|
new TopViewDiv(bodyView, Language.StringByID(StringId.AddSecurity)).LoadTopView();
|
#region 布防信息
|
var deploymentTitleRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(44),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(deploymentTitleRow);
|
|
var btnDeploymentTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.DeploymentInformation,
|
IsBold = true,
|
};
|
deploymentTitleRow.AddChidren(btnDeploymentTitle);
|
|
deploymentTitleRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
#region 布防名称
|
var deploymentNameRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(deploymentNameRow);
|
|
var btnDeploymentNameTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(72),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.Name,
|
};
|
deploymentNameRow.AddChidren(btnDeploymentNameTitle);
|
btnDeploymentNameTitle.Text += ":";
|
|
var btnDeploymentName = new Button()
|
{
|
X = Application.GetRealWidth(88),
|
Width = Application.GetRealWidth(230),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.TextualColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
Text = securityAlarm.name
|
};
|
deploymentNameRow.AddChidren(btnDeploymentName);
|
deploymentNameRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
LoadEvent_EditSecurityAlarmName(btnDeploymentName);
|
#endregion
|
|
#region 触发延时
|
var delayedRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(delayedRow);
|
|
var btnDelayedTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(72),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.TriggerDelay,
|
};
|
delayedRow.AddChidren(btnDelayedTitle);
|
btnDelayedTitle.Text += ":";
|
btnDelayedTitle.Width = btnDelayedTitle.GetTextWidth()+Application.GetRealWidth(10);
|
|
var btnDelayedText = new Button()
|
{
|
X = btnDelayedTitle.Right,
|
Width = Application.GetRealWidth(330),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.TextualColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
Text = securityAlarm.delay + "s"
|
};
|
delayedRow.AddChidren(btnDelayedText);
|
btnDelayedText.MouseUpEventHandler = (sender, e) =>
|
{
|
Action<string> action = (obj) =>
|
{
|
securityAlarm.delay = obj;
|
btnDelayedText.Text = securityAlarm.delay + "s";
|
};
|
new PublicAssmebly().SetSceneDelayDialog(action, securityAlarm.delay);
|
};
|
|
var btnDelayedRight = new Button()
|
{
|
X = Application.GetRealWidth(343),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/RightIcon.png",
|
};
|
delayedRow.AddChidren(btnDelayedRight);
|
|
|
delayedRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
#endregion
|
|
#endregion
|
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8), BackgroundColor = CSS_Color.BackgroundColor });
|
}
|
else
|
{
|
new TopViewDiv(bodyView, title).LoadTopView();
|
}
|
|
//布防功能
|
iniDefenseView();
|
|
//告警目标
|
iniAlarmView();
|
|
#region 执行推送
|
///上下间隔12像素
|
contentView.AddChidren(new FrameLayout { Height = Application.GetRealHeight(12) });
|
///执行推送iew
|
FrameLayout pushView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(pushView);
|
|
|
var btnPushTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.push,
|
IsBold = true,
|
};
|
pushView.AddChidren(btnPushTitle);
|
|
var btnSwitchPush = new Button()
|
{
|
Width = Application.GetRealWidth(36),
|
Height = Application.GetRealWidth(36),
|
X = Application.GetRealWidth(323),
|
UnSelectedImagePath = "LogicIcon/off.png",
|
SelectedImagePath = "LogicIcon/on.png",
|
Gravity = Gravity.CenterVertical,
|
IsSelected = securityAlarm.noticeConfig.enable
|
};
|
pushView.AddChidren(btnSwitchPush);
|
|
|
///是否要推送点击事件
|
btnSwitchPush.MouseUpEventHandler += (sender, e) =>
|
{
|
//账号列表为空默认推送当前账号
|
if (securityAlarm.pushConfigs.Count == 0)
|
{
|
//初始化对象
|
var pushConfigs = new SecurityPushConfig();
|
//默认添加推送当前账号
|
pushConfigs.pushTarget.Add(UserInfo.Current.ID);
|
securityAlarm.pushConfigs.Add(pushConfigs);
|
}
|
btnSwitchPush.IsSelected = !btnSwitchPush.IsSelected;
|
if (btnSwitchPush.IsSelected)
|
{
|
securityAlarm.noticeConfig.enable = true;
|
}
|
else
|
{
|
securityAlarm.noticeConfig.enable = false;
|
}
|
};
|
pushView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
#endregion
|
#region 发送通知
|
///发送通知View
|
var pushMsgView = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(50),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(pushMsgView);
|
var btnPushMsgRight = new Button()
|
{
|
X = Application.GetRealWidth(343),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetMinRealAverage(16),
|
Height = Application.GetMinRealAverage(16),
|
UnSelectedImagePath = "Public/RightIcon.png",
|
};
|
pushMsgView.AddChidren(btnPushMsgRight);
|
|
|
|
var btnPushMsgTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Width = Application.GetRealWidth(372),
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextID = StringId.fasongtongzhi,
|
IsBold = true,
|
};
|
pushMsgView.AddChidren(btnPushMsgTitle);
|
|
btnPushMsgTitle.MouseUpEventHandler = (sender, e) => {
|
var inputPushText = new PushConfigPage();
|
MainPage.BasePageView.AddChidren(inputPushText);
|
inputPushText.Show(securityAlarm);
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
|
///上下间隔62像素
|
contentView.AddChidren(new FrameLayout { Height = Application.GetRealHeight(40) });
|
|
|
#endregion
|
|
|
|
|
#region 底部区域
|
var bottomView = new FrameLayout()
|
{
|
Y = Application.GetRealHeight(591),
|
Height = Application.GetRealHeight(100),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(22),
|
};
|
this.AddChidren(bottomView);
|
|
var btnConfrim = new Button()
|
{
|
X = Application.GetRealWidth(78),
|
Y = Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(220),
|
Height = Application.GetRealWidth(44),
|
Radius = (uint)Application.GetRealWidth(22),
|
BackgroundColor = CSS_Color.MainColor,
|
TextID = StringId.Confirm,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextAlignment = TextAlignment.Center,
|
};
|
bottomView.AddChidren(btnConfrim);
|
|
btnConfrim.MouseUpEventHandler = (sender, e) =>
|
{
|
if (string.IsNullOrEmpty( securityAlarm.name ))
|
{
|
var tip = new Tip()
|
{
|
Text = Language.StringByID(StringId.PleaseEnterSecurityName),// = "请输入安防名称",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
return;
|
}
|
|
if (securityAlarm.input.Count == 0)
|
{
|
var tip = new Tip()
|
{
|
Text = Language.StringByID(StringId.PleaseSelectTheDeploymentTarget),// "请选择布防目标",
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
return;
|
}
|
if (securityAlarm.output.Count == 0)
|
{
|
var tipText = "请选择告警目标";
|
if(Language.CurrentLanguage !="Chinese")
|
{
|
tipText = "Please select the alarm target";
|
}
|
var tip = new Tip()
|
{
|
Text = tipText,
|
CloseTime = 3,
|
Direction = AMPopTipDirection.None
|
};
|
tip.Show(MainPage.BaseView);
|
return;
|
}
|
|
var waitPage = new Loading();
|
waitPage.Start();
|
new System.Threading.Thread(() =>
|
{
|
try
|
{
|
|
var code = securityAlarm.SaveInfo();
|
if (code == StateCode.SUCCESS)
|
{
|
Common.ApiUtlis.Ins.GetSecurityList();
|
Application.RunOnMainThread(() =>
|
{
|
this.RemoveFromParent();
|
refreshAction?.Invoke();
|
});
|
}
|
else
|
{
|
Application.RunOnMainThread(() =>
|
{
|
IMessageCommon.Current.ShowErrorInfoAlter(code);
|
});
|
}
|
}
|
catch { }
|
finally
|
{
|
Application.RunOnMainThread(() => {
|
if (waitPage != null)
|
{
|
waitPage.RemoveFromParent();
|
waitPage = null;
|
}
|
});
|
}
|
})
|
{ IsBackground = true }.Start();
|
};
|
#endregion
|
|
}
|
|
/// <summary>
|
/// 初始化部分功能区域
|
/// </summary>
|
private void iniDefenseView()
|
{
|
|
#region 布防功能
|
var deploymentFunctionRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(44),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(deploymentFunctionRow);
|
deploymentFunctionRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
|
var btnFunctionTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.DefenseFunctionArmState,
|
IsBold = true,
|
};
|
deploymentFunctionRow.AddChidren(btnFunctionTitle);
|
|
var btnAddTarget = new Button()
|
{
|
X = Application.GetRealWidth(337),
|
Y = Application.GetRealHeight(6),
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = "FunctionIcon/ArmCenter/AddTargetIcon.png",
|
};
|
deploymentFunctionRow.AddChidren(btnAddTarget);
|
///添加输入目标
|
btnAddTarget.MouseUpEventHandler = (sender, e) => {
|
Action<SecurityAlarm> action = (outTemp) => {
|
securityAlarm = outTemp;
|
iniInputTargetView();
|
};
|
var page = new AddInputPage(securityAlarm, action);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
|
deploymentFunctionRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
inputTargetView = new VerticalScrolViewLayout()
|
{
|
ScrollEnabled = false,
|
};
|
contentView.AddChidren(inputTargetView);
|
|
iniInputTargetView();
|
|
#endregion
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8), BackgroundColor = CSS_Color.BackgroundColor });
|
|
}
|
|
/// <summary>
|
/// 初始化输入条件区域界面
|
/// </summary>
|
/// <param name=""></param>
|
private void iniInputTargetView()
|
{
|
inputTargetView.RemoveAll();
|
if (securityAlarm.input.Count > 0)
|
{
|
int count = 0;
|
foreach (var target in securityAlarm.input)
|
{
|
if (target.GetFunction() != null)
|
{
|
inputTargetView.AddChidren(new InputRow(target.GetFunction().name, target.GetFunction().GetRoomListName(), target.StateText()));
|
inputTargetView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
}
|
count++;
|
}
|
inputTargetView.Height = Application.GetRealHeight(65 * count);
|
}
|
else
|
{
|
inputTargetView.AddChidren(new Button()
|
{
|
Height = Application.GetRealHeight(65),
|
TextAlignment = TextAlignment.Center,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
TextID = StringId.ThereIsNoAssociatedTaskDeploymentStatus,
|
IsMoreLines = true,
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
});
|
|
inputTargetView.Height = Application.GetRealHeight(68);
|
//if(outputTargetView!= null)
|
//{
|
// contentView.AddChidren(outputTargetView);
|
//}
|
}
|
|
|
}
|
|
/// <summary>
|
/// 初始化告警目标区域
|
/// </summary>
|
private void iniAlarmView()
|
{
|
#region 告警目标
|
var outputRow = new FrameLayout()
|
{
|
Height = Application.GetRealHeight(44),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(outputRow);
|
outputRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
var btnOutputRowTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
TextColor = CSS_Color.MainColor,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.AlarmTargetAfterTriggering,
|
IsBold = true,
|
};
|
outputRow.AddChidren(btnOutputRowTitle);
|
|
var btnAddOutTarget = new Button()
|
{
|
X = Application.GetRealWidth(337),
|
Y = Application.GetRealHeight(6),
|
Width = Application.GetRealWidth(32),
|
Height = Application.GetRealWidth(32),
|
UnSelectedImagePath = "FunctionIcon/ArmCenter/AddTargetIcon.png",
|
};
|
outputRow.AddChidren(btnAddOutTarget);
|
|
btnAddOutTarget.MouseUpEventHandler = (sender, e) => {
|
Action<SecurityAlarm> action = (outTemp) => {
|
securityAlarm = outTemp;
|
iniAlarmListView();
|
};
|
var page = new AddOutputPage(securityAlarm, action);
|
MainPage.BasePageView.AddChidren(page);
|
page.LoadPage();
|
MainPage.BasePageView.PageIndex = MainPage.BasePageView.ChildrenCount - 1;
|
};
|
|
outputRow.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(43), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
|
|
outputTargetView = new VerticalScrolViewLayout()
|
{
|
ScrollEnabled = false,
|
Height =0,
|
};
|
contentView.AddChidren(outputTargetView);
|
|
outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count);
|
iniAlarmListView();
|
|
#endregion
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(8), BackgroundColor = CSS_Color.BackgroundColor });
|
|
}
|
|
/// <summary>
|
/// 初始化告警列表区域
|
/// </summary>
|
private void iniAlarmListView()
|
{
|
outputTargetView.RemoveAll();
|
if (securityAlarm.output.Count > 0)
|
{
|
foreach (var outTarget in securityAlarm.output)
|
{
|
if (outTarget.NoLocalData())
|
{
|
var outputRow = new OutputRow(outTarget.name, outTarget.RoomName, outTarget);
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) => {
|
var delTemp = securityAlarm.output.Find((obj) => obj.sid == outTarget.sid);
|
if(delTemp!=null)
|
{
|
securityAlarm.output.Remove(delTemp);
|
}
|
outputRow.RemoveFromParent();
|
outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count);
|
};
|
outputTargetView.AddChidren(outputRow);
|
}
|
outputTargetView.AddChidren(new Button() { Gravity = Gravity.CenterHorizontal, Y = Application.GetRealHeight(49), Height = 1, BackgroundColor = CSS_Color.DividingLineColor });
|
}
|
outputTargetView.Height = Application.GetRealHeight(65 * securityAlarm.output.Count);
|
}
|
else
|
{
|
outputTargetView.AddChidren(new Button()
|
{
|
Height = Application.GetRealHeight(65),
|
TextAlignment = TextAlignment.Center,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
TextID = StringId.ThereIsNoAssociatedTaskDeploymentStatus,
|
IsMoreLines = true,
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
});
|
outputTargetView.Height = Application.GetRealHeight(68);
|
}
|
}
|
|
|
/// <summary>
|
/// 修改安防名称
|
/// </summary>
|
void LoadEvent_EditSecurityAlarmName(Button btnDeploymentName)
|
{
|
EventHandler<MouseEventArgs> eventHandler = (sender, e) =>
|
{
|
Action<string> callBack = (str) =>
|
{
|
//名称不能为空
|
if (string.IsNullOrEmpty(str))
|
{
|
new Tip()
|
{
|
CloseTime = 1,
|
Text = Language.StringByID(StringId.NameCannotBeEmpty),
|
Direction = AMPopTipDirection.None,
|
}.Show(bodyView);
|
return;
|
}
|
|
btnDeploymentName.Text = securityAlarm.name = str;
|
|
};
|
new PublicAssmebly().LoadDialog_EditParater(StringId.Name, securityAlarm.name, callBack, StringId.NameCannotBeEmpty, 0, new List<string>());
|
};
|
btnDeploymentName.MouseUpEventHandler = eventHandler;
|
}
|
|
|
}
|
|
/// <summary>
|
/// 输入条件行控件
|
/// </summary>
|
public class InputRow : RowLayout
|
{
|
Button btnTitle;
|
|
Button btnSubTitle;
|
|
public InputRow(string title, string subtitle,string state)
|
{
|
this.LineColor = 0x00000000;
|
this.Height = Application.GetRealHeight(65);
|
this.BackgroundColor = CSS_Color.MainBackgroundColor;
|
|
btnTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(320),
|
Text = title,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
this.AddChidren(btnTitle);
|
|
btnSubTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(24),
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(320),
|
Text = subtitle,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
};
|
this.AddChidren(btnSubTitle);
|
|
|
Button btnState = new Button()
|
{
|
Width = Application.GetRealWidth(360),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
Text = state
|
};
|
this.AddChidren(btnState);
|
|
|
}
|
|
public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler)
|
{
|
this.MouseUpEventHandler = eventHandler;
|
btnTitle.MouseUpEventHandler = eventHandler;
|
btnSubTitle.MouseUpEventHandler = eventHandler;
|
}
|
}
|
|
/// <summary>
|
/// 输出条件控件
|
/// </summary>
|
public class OutputRow : RowLayout
|
{
|
Button btnTitle;
|
|
Button btnSubTitle;
|
|
Button btnState;
|
|
Button btnRightIcon;
|
|
Button btnDel;
|
|
SecurityOutput output;
|
|
public OutputRow(string title, string subtitle, SecurityOutput inOutput)
|
{
|
output = inOutput;
|
|
this.LineColor = 0x00000000;
|
this.Height = Application.GetRealHeight(65);
|
this.BackgroundColor = CSS_Color.MainBackgroundColor;
|
|
btnTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(320),
|
Text = title,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.FirstLevelTitleColor,
|
TextSize = CSS_FontSize.TextFontSize,
|
};
|
this.AddChidren(btnTitle);
|
|
btnSubTitle = new Button()
|
{
|
X = Application.GetRealWidth(16),
|
Y = Application.GetRealHeight(24),
|
Height = Application.GetRealHeight(44),
|
Width = Application.GetRealWidth(320),
|
Text = subtitle,
|
TextAlignment = TextAlignment.CenterLeft,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
|
};
|
this.AddChidren(btnSubTitle);
|
|
btnState = new Button()
|
{
|
Width = Application.GetRealWidth(323),
|
TextAlignment = TextAlignment.CenterRight,
|
TextSize = CSS_FontSize.TextFontSize,
|
TextColor = CSS_Color.PromptingColor1,
|
Text = output.StateText()
|
};
|
this.AddChidren(btnState);
|
|
btnRightIcon = new Button()
|
{
|
X = Application.GetRealWidth(339),
|
Gravity = Gravity.CenterVertical,
|
Width = Application.GetRealWidth(16),
|
Height = Application.GetRealWidth(16),
|
UnSelectedImagePath = "FunctionIcon/ArmCenter/RightIcon.png",
|
};
|
if (!string.IsNullOrEmpty(output.spk))
|
{
|
this.AddChidren(btnRightIcon);
|
}
|
|
btnState.MouseUpEventHandler = (sender, e) =>
|
{
|
if (!string.IsNullOrEmpty(output.spk))
|
{
|
ShowStateDialog();
|
}
|
};
|
btnRightIcon.MouseUpEventHandler = (sender, e) =>
|
{
|
if (!string.IsNullOrEmpty(output.spk))
|
{
|
ShowStateDialog();
|
}
|
};
|
//btnSubTitle.MouseUpEventHandler = (sender, e) =>
|
//{
|
// ShowStateDialog();
|
//};
|
|
btnDel = new Button()
|
{
|
BackgroundColor = CSS_Color.WarningColor,
|
TextColor = CSS_Color.MainBackgroundColor,
|
TextID = StringId.Del,
|
};
|
this.AddRightView(btnDel);
|
|
}
|
|
public void SetDelClick(EventHandler<MouseEventArgs> eventHandler)
|
{
|
btnDel.MouseUpEventHandler = eventHandler;
|
}
|
|
public void SetClickEvent(EventHandler<MouseEventArgs> eventHandler)
|
{
|
btnState.MouseUpEventHandler = eventHandler;
|
btnTitle.MouseUpEventHandler = eventHandler;
|
btnSubTitle.MouseUpEventHandler = eventHandler;
|
}
|
|
|
|
|
private void ShowStateDialog()
|
{
|
Dialog dialog = new Dialog();
|
|
FrameLayout contentView = new FrameLayout();
|
dialog.AddChidren(contentView);
|
contentView.MouseUpEventHandler = (sender, e) =>
|
{
|
dialog.Close();
|
};
|
|
VerticalScrolViewLayout optinView = new VerticalScrolViewLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(515),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(88),
|
Radius = (uint)Application.GetRealHeight(13),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
};
|
contentView.AddChidren(optinView);
|
|
Button btnOpen = new Button()
|
{
|
Height = Application.GetRealHeight(44),
|
TextAlignment = TextAlignment.Center,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.PromptingColor1,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
TextID = StringId.On,
|
};
|
optinView.AddChidren(btnOpen);
|
optinView.AddChidren(new Button()
|
{
|
Height = 1,
|
BackgroundColor = CSS_Color.DividingLineColor
|
});
|
|
Button btnClose = new Button()
|
{
|
Height = Application.GetRealHeight(44),
|
TextAlignment = TextAlignment.Center,
|
SelectedTextColor = CSS_Color.MainColor,
|
TextColor = CSS_Color.PromptingColor1,
|
TextID = StringId.OFF,
|
TextSize = CSS_FontSize.SubheadingFontSize,
|
};
|
optinView.AddChidren(btnClose);
|
if (output.status.Count > 0)
|
{
|
btnOpen.IsSelected = output.status[0].value.ToLower() == "on";
|
btnClose.IsSelected = !btnOpen.IsSelected;
|
}
|
|
|
Button btnCancel = new Button()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = optinView.Bottom + Application.GetRealHeight(8),
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealHeight(44),
|
Radius = (uint)Application.GetRealHeight(13),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
TextID = StringId.Cancel,
|
TextColor = CSS_Color.WarningColor,
|
IsBold = true,
|
};
|
contentView.AddChidren(btnCancel);
|
|
dialog.Show();
|
|
btnOpen.MouseUpEventHandler = (sender, e) => {
|
btnState.Text = btnOpen.Text;
|
output.status = new List<SecurityOutputStatus>()
|
{
|
new SecurityOutputStatus()
|
{
|
key = FunctionAttributeKey.OnOff,
|
value = "on",
|
}
|
};
|
dialog.Close();
|
};
|
|
btnClose.MouseUpEventHandler = (sender, e) =>
|
{
|
btnState.Text = btnClose.Text;
|
output.status = new List<SecurityOutputStatus>()
|
{
|
new SecurityOutputStatus()
|
{
|
key = FunctionAttributeKey.OnOff,
|
value = "off",
|
}
|
};
|
dialog.Close();
|
};
|
|
btnCancel.MouseUpEventHandler = (sender, e) =>
|
{
|
dialog.Close();
|
};
|
|
}
|
|
}
|
}
|