namespace Yw.WinFrmUI { /// /// 水力工况信息ViewModel /// public class HydroWorkingInfoViewModel { /// /// /// public HydroWorkingInfoViewModel() { this.Reservoirs = new List(); this.Tanks = new List(); this.Pumps = new List(); this.Valves = new List(); this.Resistances = new List(); } /// /// 水库 /// public List Reservoirs { get; set; } /// /// 水池 /// public List Tanks { get; set; } /// /// 水泵 /// public List Pumps { get; set; } /// /// 阀门 /// public List Valves { get; set; } /// /// 阻件 /// public List Resistances { get; set; } /// /// 获取所有工况列表 /// public List GetAllWorkingList() { var list = new List(); this.Reservoirs?.ForEach(x => list.Add(x)); this.Tanks?.ForEach(x => list.Add(x)); this.Pumps?.ForEach(x => list.Add(x)); this.Valves?.ForEach(x => list.Add(x)); return list; } /// /// 添加工况 /// public bool AppendWorking(HydroWorkingVisualViewModel working) { if (working == null) { return false; } var type = working.GetType(); if (type.FullName == typeof(HydroWorkingReservoirViewModel).FullName) { if (this.Reservoirs.Exists(x => x.Code == working.Code)) { return false; } this.Reservoirs.Add(working as HydroWorkingReservoirViewModel); return true; } else if (type.FullName == typeof(HydroWorkingTankViewModel).FullName) { if (this.Tanks.Exists(x => x.Code == working.Code)) { return false; } this.Tanks.Add(working as HydroWorkingTankViewModel); return true; } else if (type.FullName == typeof(HydroWorkingPumpViewModel).FullName) { if (this.Pumps.Exists(x => x.Code == working.Code)) { return false; } this.Pumps.Add(working as HydroWorkingPumpViewModel); return true; } else if (type.FullName == typeof(HydroWorkingValveViewModel).FullName) { if (this.Valves.Exists(x => x.Code == working.Code)) { return false; } this.Valves.Add(working as HydroWorkingValveViewModel); return true; } return false; } } }