namespace Yw.WinFrmUI { /// /// 水力工况信息ViewModel /// public class HydroWorkingInfoViewModel { /// /// /// public HydroWorkingInfoViewModel() { this.Waterboxs = new List(); this.Pumps = new List(); this.Valves = new List(); this.Flowmeters = new List(); this.Pressmeters = new List(); } /// /// 水箱 /// public List Waterboxs { get; set; } /// /// 水泵 /// public List Pumps { get; set; } /// /// 阀门 /// public List Valves { get; set; } /// /// 流量计 /// public List Flowmeters { get; set; } /// /// 压力表 /// public List Pressmeters { get; set; } /// /// 获取所有组件工况信息列表 /// public List GetAllParterWorkingInfoList() { 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)); this.Flowmeters?.ForEach(x => list.Add(x)); this.Pressmeters?.ForEach(x => list.Add(x)); return list; } /// /// 添加组件工况信息 /// public bool AppendParterWorkingInfo(HydroParterWorkingInfoViewModel 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; } else if (workingInfo is HydroFlowmeterWorkingInfoViewModel flowmeter) { if (this.Flowmeters.Exists(x => x.Code == flowmeter.Code)) { return false; } this.Flowmeters.Add(flowmeter); return true; } else if (workingInfo is HydroPressmeterWorkingInfoViewModel pressmeter) { if (this.Pressmeters.Exists(x => x.Code == pressmeter.Code)) { return false; } this.Pressmeters.Add(pressmeter); return true; } return false; } } }