using Yw.WinFrmUI.Bimface;
namespace HStation.WinFrmUI
{
///
/// 监测标记辅助类
///
public class SimulationMonitorMarkerHelper
{
///
///
///
public SimulationMonitorMarkerHelper
(
SimulationMonitorHelper monitorHelper,
ISimulationMonitorMarkerView view
)
{
_monitorHelper = monitorHelper;
_views = new List() { view };
}
private readonly SimulationMonitorHelper _monitorHelper = null;//监测点辅助类
private readonly List _views = null;//视图列表
///
/// 是否可见
///
public bool Visible
{
get { return _visible; }
set { _visible = value; }
}
private bool _visible = false;
///
/// 获取所有
///
public async Task> GetAll()
{
var allMonitorList = await _monitorHelper.GetAll();
var allGroupList = allMonitorList?.GroupBy(x => new { x.Relation, x.SourceType }).ToList();
var allMarkerList = allGroupList?.Select(x => new LogicMonitorMarker()
{
Code = x.Key.Relation,
SourceType = (int)x.Key.SourceType,
Description = x.Key.SourceType == Yw.Hydro.eSourceType.Docking ? $"传感器测点({x.Count()})" : $"分析测点({x.Count()})"
}).ToList();
return allMarkerList;
}
///
/// 设置
///
public async void Set()
{
if (this.Visible)
{
var allMarkerList = await GetAll();
_views.ForEach(x => x.SetLogicMonitors(allMarkerList));
}
else
{
_views.ForEach(x => x.ClearLogicMonitors());
}
}
}
}