using Yw.Vmo;
|
using Yw.WinFrmUI.Bimface;
|
|
namespace HStation.WinFrmUI
|
{
|
/// <summary>
|
/// 监测标记辅助类
|
/// </summary>
|
public class SimulationMonitorMarkerHelper
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public SimulationMonitorMarkerHelper(SimulationMonitorHelper monitorHelper, ISimulationMonitorMarkerView view)
|
{
|
_monitorHelper = monitorHelper;
|
_views = new List<ISimulationMonitorMarkerView>() { view };
|
}
|
|
private SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
|
private List<ISimulationMonitorMarkerView> _views = null;//视图列表
|
private List<LogicMonitorMarker> _allMarkerList = null;//所有标记列表
|
|
/// <summary>
|
/// 是否可见
|
/// </summary>
|
public bool Visible
|
{
|
get { return _visible; }
|
set { _visible = value; }
|
}
|
private bool _visible = false;
|
|
/// <summary>
|
/// 获取
|
/// </summary>
|
public async Task<List<LogicMonitorMarker>> Get()
|
{
|
var allMonitorList = await _monitorHelper.Get();
|
_allMarkerList = allMonitorList?.Select(x => new LogicMonitorMarker()
|
{
|
Id = x.Relation,
|
PropName = x.PropName,
|
Description = x.Description
|
}).ToList();
|
return _allMarkerList;
|
}
|
|
/// <summary>
|
/// 更新
|
/// </summary>
|
public async void Update(string code, List<HydroMonitorVmo> monitorList)
|
{
|
var allMarkerList = await Get();
|
var markerList = allMarkerList.Where(x => x.Id == code).ToList();
|
markerList?.ForEach(x =>
|
{
|
var result = monitorList?.Exists(t => t.Relation == x.Id && t.PropName == x.PropName);
|
if (!(result.HasValue && result.Value))
|
{
|
allMarkerList.Remove(x);
|
}
|
});
|
monitorList?.ForEach(x =>
|
{
|
var result = markerList?.Exists(t => t.Id == x.Relation && t.PropName == x.PropName);
|
if (!(result.HasValue && result.Value))
|
{
|
var vm = new LogicMonitorMarker()
|
{
|
Id = x.Relation,
|
PropName = x.PropName,
|
Description = x.Description
|
};
|
allMarkerList.Add(vm);
|
}
|
});
|
}
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public async void Set()
|
{
|
if (this.Visible)
|
{
|
var allMarkerList = await Get();
|
_views.ForEach(x => x.SetLogicMonitors(allMarkerList));
|
}
|
else
|
{
|
_views.ForEach(x => x.ClearLogicMonitors());
|
}
|
}
|
|
|
|
|
}
|
}
|