namespace Yw.WinFrmUI { /// /// 水力工况信息ViewModel /// public class HydroWorkingInfoViewModel { /// /// /// public HydroWorkingInfoViewModel() { this.Waterboxs = new List(); this.Pumps = new List(); this.Valves = new List(); this.Monitors = new List(); } /// /// 水箱 /// public List Waterboxs { get; set; } /// /// 水泵 /// public List Pumps { get; set; } /// /// 阀门 /// public List Valves { get; set; } /// /// 监测 /// public List Monitors { get; set; } /// /// 获取所有组件工况信息列表 /// public List GetAllVisualWorkingInfoList() { var list = new List(); this.Waterboxs?.ForEach(x => list.Add(x)); this.Pumps?.ForEach(x => list.Add(x)); this.Valves?.ForEach(x => list.Add(x)); return list; } /// /// 添加组件工况信息 /// public bool AppendVisualWorkingInfo(HydroVisualWorkingInfoViewModel workingInfo) { if (workingInfo == null) { return false; } if (workingInfo is HydroWaterboxWorkingInfoViewModel waterbox) { if (this.Waterboxs.Exists(x => x.Code == waterbox.Code)) { return false; } this.Waterboxs.Add(waterbox); return true; } else if (workingInfo is HydroPumpWorkingInfoViewModel pump) { if (this.Pumps.Exists(x => x.Code == pump.Code)) { return false; } this.Pumps.Add(pump); return true; } else if (workingInfo is HydroValveWorkingInfoViewModel valve) { if (this.Valves.Exists(x => x.Code == valve.Code)) { return false; } this.Valves.Add(valve); return true; } return false; } } }