using System;
|
using System.Collections.Generic;
|
using System.Text;
|
using ZigBee.Device;
|
|
namespace Shared.Phone.UserCenter.Safety
|
{
|
/// <summary>
|
/// 报警目标设置画面
|
/// </summary>
|
public class AlarmTargetSettionForm : EditorCommonForm
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 防区ID(这个东西似乎是唯一的)
|
/// </summary>
|
private int zoonID = 0;
|
/// <summary>
|
/// 列表控件
|
/// </summary>
|
private VerticalListControl listView = null;
|
/// <summary>
|
/// 底部的【添加目标】的行
|
/// </summary>
|
private FrameRowControl frameBottomAddRow = null;
|
|
#endregion
|
|
#region ■ 初始化_____________________________
|
|
/// <summary>
|
/// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
/// </summary>
|
/// <param name="i_zoonID">防区ID</param>
|
public void ShowForm(int i_zoonID)
|
{
|
this.zoonID = i_zoonID;
|
|
//设置头部信息
|
base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAlarmTargetSettion));
|
|
//初始化中部信息
|
this.InitMiddleFrame();
|
}
|
|
/// <summary>
|
/// 初始化中部信息
|
/// </summary>
|
private void InitMiddleFrame()
|
{
|
//清空bodyFrame
|
this.ClearBodyFrame();
|
|
//根据防区ID获取本地的报警目标列表
|
var listData = HdlSafeguardLogic.Current.GetLocalAlarmTargetInfoByZoneId(this.zoonID);
|
if (listData.Count == 0)
|
{
|
//特殊特效,如果没有报警目标的话,则显示的界面效果非常的大
|
this.ShowNotAlarmTargetAppeal();
|
frameBottomAddRow = null;
|
return;
|
}
|
|
//当该防区报警时,以下目标将会响应
|
var frameBack = new FrameLayout();
|
frameBack.Height = Application.GetRealHeight(92);
|
frameBack.BackgroundColor = UserCenterColor.Current.White;
|
bodyFrameLayout.AddChidren(frameBack);
|
|
var btnTitle = new NormalViewControl(860, 49, true);
|
btnTitle.X = ControlCommonResourse.XXLeft;
|
btnTitle.Y = Application.GetRealHeight(35);
|
btnTitle.TextSize = 12;
|
btnTitle.TextColor = UserCenterColor.Current.TextGrayColor2;
|
btnTitle.TextID = R.MyInternationalizationString.uTargetViewAlarmAfterZoonAlarm;
|
frameBack.AddChidren(btnTitle);
|
|
int maxRowCount = listData.Count;
|
if (maxRowCount > 8)
|
{
|
//特效问题,它只能显示8个,超过8个只能用滑动
|
maxRowCount = 8;
|
}
|
this.listView = new VerticalListControl(29);
|
this.listView.Y = frameBack.Bottom;
|
this.listView.BackgroundColor = UserCenterColor.Current.White;
|
this.listView.Height = (ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(29)) * maxRowCount;
|
bodyFrameLayout.AddChidren(this.listView);
|
|
//添加底部 添加报警目标的菜单行
|
this.AddBottomAlarmTargetMenu();
|
|
HdlThreadLogic.Current.RunThread(() =>
|
{
|
//设置中间部分信息
|
this.SetMiddleInfo(listData);
|
});
|
}
|
|
/// <summary>
|
/// 设置中间部分信息
|
/// </summary>
|
public void SetMiddleInfo(List<Safeguard.CatActionResponseObj> listData)
|
{
|
if (this.Parent == null)
|
{
|
return;
|
}
|
|
//添加报警目标的明细行S
|
Application.RunOnMainThread(() =>
|
{
|
foreach (var data in listData)
|
{
|
//场景
|
if (data.Type == 1)
|
{
|
this.AddSceneRow(data);
|
}
|
//设备
|
if (data.Type == 0)
|
{
|
CommonDevice device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
|
if (device != null)
|
{
|
this.AddDeviceRow(data, device);
|
}
|
}
|
}
|
});
|
}
|
|
#endregion
|
|
#region ■ 报警目标菜单行_____________________
|
|
/// <summary>
|
/// 显示无报警目标特效
|
/// </summary>
|
private void ShowNotAlarmTargetAppeal()
|
{
|
var frameTemp = new FrameRowControl();
|
frameTemp.Height = Application.GetRealHeight(173);
|
frameTemp.BackgroundColor = UserCenterColor.Current.White;
|
bodyFrameLayout.AddChidren(frameTemp);
|
|
//添加目标
|
var btnText = frameTemp.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAddTarget), 400);
|
btnText.TextSize = 15;
|
|
//加号
|
var btnAdd = frameTemp.AddMostRightEmptyIcon(58, 58);
|
btnAdd.UnSelectedImagePath = "Item/Add.png";
|
|
frameTemp.ButtonClickEvent += (sender, e) =>
|
{
|
var form = new AddAlarmTargetTypeListForm();
|
form.AddForm(this.zoonID);
|
};
|
}
|
|
/// <summary>
|
/// 添加底部 添加报警目标的菜单行
|
/// </summary>
|
private void AddBottomAlarmTargetMenu()
|
{
|
//添加目标
|
frameBottomAddRow = new FrameRowControl();
|
frameBottomAddRow.Y = this.listView.Bottom;
|
frameBottomAddRow.Height = ControlCommonResourse.ListViewRowHeight + Application.GetRealHeight(29 + 29);
|
frameBottomAddRow.BackgroundColor = UserCenterColor.Current.White;
|
bodyFrameLayout.AddChidren(frameBottomAddRow);
|
|
var frameTemp = new FrameRowControl();
|
frameTemp.Gravity = Gravity.CenterVertical;
|
frameBottomAddRow.AddChidren(frameTemp);
|
var btnText = frameTemp.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAddTarget), 400);
|
btnText.TextSize = 15;
|
//加号
|
var btnAdd = frameTemp.AddMostRightEmptyIcon(58, 58);
|
btnAdd.UnSelectedImagePath = "Item/Add.png";
|
//底线
|
frameTemp.AddBottomLine();
|
|
frameTemp.ButtonClickEvent += (sender, e) =>
|
{
|
var form = new AddAlarmTargetTypeListForm();
|
form.AddForm(this.zoonID);
|
};
|
}
|
|
#endregion
|
|
#region ■ 报警目标明细行_____________________
|
|
/// <summary>
|
/// 添加报警目标的明细行
|
/// </summary>
|
private void AddAlarmTargetList(List<Safeguard.CatActionResponseObj> listData)
|
{
|
foreach (var data in listData)
|
{
|
//场景
|
if (data.Type == 1)
|
{
|
Application.RunOnMainThread(() =>
|
{
|
if (this.Parent != null)
|
{
|
this.AddSceneRow(data);
|
}
|
});
|
}
|
//设备
|
if (data.Type == 0)
|
{
|
CommonDevice device = Common.LocalDevice.Current.GetDevice(data.DeviceAddr, data.Epoint);
|
if (device == null)
|
{
|
//本地没有这个设备的话
|
continue;
|
}
|
|
Application.RunOnMainThread(() =>
|
{
|
if (this.Parent != null)
|
{
|
this.AddDeviceRow(data, device);
|
}
|
});
|
}
|
}
|
}
|
|
/// <summary>
|
/// 添加设备行
|
/// </summary>
|
/// <param name="data"></param>
|
/// <param name="device"></param>
|
private void AddDeviceRow(Safeguard.CatActionResponseObj data, CommonDevice device)
|
{
|
//行控件
|
var row = new DeviceRoomControl(device, listView.rowSpace / 2);
|
listView.AddChidren(row);
|
row.InitControl();
|
row.frameTable.UseClickStatu = false;
|
//底线
|
row.frameTable.AddBottomLine();
|
|
//删除图标
|
var btnDelete = row.frameTable.AddMostRightEmptyIcon(58, 58);
|
btnDelete.UnSelectedImagePath = "Item/DeleteIcon1.png";
|
row.frameTable.ChangedChidrenBindMode(btnDelete, ChidrenBindMode.NotBind);
|
btnDelete.ButtonClickEvent += (sender, e) =>
|
{
|
//删除
|
string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
{
|
//删除报警目标
|
this.DeleteAlarmTarget(row, data);
|
});
|
};
|
|
//状态显示
|
var btnStatu = row.frameTable.AddMostRightView("", 400);
|
if (data.TaskList.Count > 0)
|
{
|
btnStatu.Text = HdlSafeguardLogic.Current.GetLightAlarmStatuText(data.TaskList);
|
}
|
else
|
{
|
//无动作
|
btnStatu.TextID = R.MyInternationalizationString.uNotAction;
|
}
|
}
|
|
/// <summary>
|
/// 添加场景行
|
/// </summary>
|
/// <param name="data"></param>
|
private void AddSceneRow(Safeguard.CatActionResponseObj data)
|
{
|
//行控件
|
var row = new SceneRoomControl(data.ScenesId, data.ESName, listView.rowSpace / 2);
|
listView.AddChidren(row);
|
row.InitControl();
|
row.frameTable.UseClickStatu = false;
|
//底线
|
row.frameTable.AddBottomLine();
|
|
//删除图标
|
var btnDelete = row.frameTable.AddMostRightEmptyIcon(58, 58);
|
btnDelete.UnSelectedImagePath = "Item/DeleteIcon1.png";
|
row.frameTable.ChangedChidrenBindMode(btnDelete, ChidrenBindMode.NotBind);
|
btnDelete.ButtonClickEvent += (sender, e) =>
|
{
|
//删除
|
string msg = Language.StringByID(R.MyInternationalizationString.uShowDoDeleteMsg);
|
this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
{
|
//删除报警目标
|
this.DeleteAlarmTarget(row, data);
|
});
|
};
|
}
|
|
#endregion
|
|
#region ■ 删除指定报警目标___________________
|
|
/// <summary>
|
/// 删除指定报警目标
|
/// </summary>
|
/// <param name="row"></param>
|
/// <param name="delObj"></param>
|
private async void DeleteAlarmTarget(RowLayoutControl row, Safeguard.CatActionResponseObj delObj)
|
{
|
//参数
|
var Pra = new List<Safeguard.DelAlarmActionObj>();
|
var actionObj = new Safeguard.DelAlarmActionObj();
|
actionObj.DeviceAddr = delObj.DeviceAddr;
|
actionObj.Epoint = delObj.Epoint;
|
actionObj.ScenesId = delObj.ScenesId;
|
actionObj.Type = delObj.Type;
|
Pra.Add(actionObj);
|
|
//打开进度条
|
this.ShowProgressBar();
|
|
//执行删除
|
bool result = await HdlSafeguardLogic.Current.DeleteAlarmTaget(this.zoonID, Pra);
|
|
//关闭进度条
|
this.CloseProgressBar();
|
|
if (result == false)
|
{
|
return;
|
}
|
|
Application.RunOnMainThread(() =>
|
{
|
//行移除
|
row?.RemoveFromParent();
|
if (listView != null && listView.ChildrenCount == 0)
|
{
|
//重新初始化中部信息
|
this.InitMiddleFrame();
|
return;
|
}
|
var realHeight = listView.ChildrenCount * listView.GetChildren(listView.ChildrenCount - 1).Height;
|
if (realHeight < listView.Height)
|
{
|
//缩小控件高度
|
listView.Height = realHeight;
|
//移动行控件
|
frameBottomAddRow.Y = this.listView.Bottom;
|
}
|
});
|
}
|
#endregion
|
|
#region ■ 界面重新激活事件___________________
|
|
/// <summary>
|
/// 自身的上层界面关闭后,它自身处于最上层时,触发的事件
|
/// </summary>
|
public override int FormActionAgainEvent()
|
{
|
//重新刷新界面
|
this.InitMiddleFrame();
|
|
return 1;
|
}
|
|
#endregion
|
}
|
}
|