namespace Yw.WinFrmUI { /// /// 颜色分级分类辅助类 /// public class HydroGradingCatalogHelper { /// /// 字典 /// public static Dictionary Dict { get { return _dict; } } //字典 private static readonly Dictionary _dict = new Dictionary() { { Yw.Hydro.ParterCatalog.Reservoir,"水库"}, { Yw.Hydro.ParterCatalog.Tank,"水池"}, { Yw.Hydro.ParterCatalog.Waterbox,"水箱"}, { Yw.Hydro.ParterCatalog.Blunthead,"闷头"}, { Yw.Hydro.ParterCatalog.Elbow,"弯头"}, { Yw.Hydro.ParterCatalog.Threelink,"三通"}, { Yw.Hydro.ParterCatalog.Fourlink,"四通"}, { Yw.Hydro.ParterCatalog.Meter,"水表"}, { Yw.Hydro.ParterCatalog.Flowmeter,"流量计"}, { Yw.Hydro.ParterCatalog.Pressmeter,"压力表"}, { Yw.Hydro.ParterCatalog.Nozzle,"喷嘴"}, { Yw.Hydro.ParterCatalog.Hydrant,"消火栓"}, { Yw.Hydro.ParterCatalog.Cooling,"冷却塔"}, { Yw.Hydro.ParterCatalog.Pipe,"管道"}, { Yw.Hydro.ParterCatalog.Translation,"过渡件"}, { Yw.Hydro.ParterCatalog.Pump,"水泵"}, { Yw.Hydro.ParterCatalog.Valve,"阀门"}, { Yw.Hydro.ParterCatalog.Exchanger,"换热器"}, { Yw.Hydro.ParterCatalog.Compressor,"压缩机"}, }; /// /// 获取名称 /// public static string GetName(string code) { if (_dict.ContainsKey(code)) { return _dict[code]; } return string.Empty; } /// /// 获取编码 /// public static string GetCode(string name) { if (_dict.ContainsValue(name)) { return _dict.FirstOrDefault(x => x.Value == name).Key; } return string.Empty; } /// /// 获取字典 /// public static Dictionary GetDict(Yw.Model.HydroModelInfo hydro) { var dict = new Dictionary(); if (hydro == null) { return dict; } if (hydro.Reservoirs != null && hydro.Reservoirs.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Reservoir, GetName(Yw.Hydro.ParterCatalog.Reservoir)); } if (hydro.Tanks != null && hydro.Tanks.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Tank, GetName(Yw.Hydro.ParterCatalog.Tank)); } if (hydro.Waterboxs != null && hydro.Waterboxs.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Waterbox, GetName(Yw.Hydro.ParterCatalog.Waterbox)); } if (hydro.Bluntheads != null && hydro.Bluntheads.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Blunthead, GetName(Yw.Hydro.ParterCatalog.Blunthead)); } if (hydro.Elbows != null && hydro.Elbows.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Elbow, GetName(Yw.Hydro.ParterCatalog.Elbow)); } if (hydro.Threelinks != null && hydro.Threelinks.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Threelink, GetName(Yw.Hydro.ParterCatalog.Threelink)); } if (hydro.Fourlinks != null && hydro.Fourlinks.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Fourlink, GetName(Yw.Hydro.ParterCatalog.Fourlink)); } if (hydro.Meters != null && hydro.Meters.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Meter, GetName(Yw.Hydro.ParterCatalog.Meter)); } if (hydro.Flowmeters != null && hydro.Flowmeters.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Flowmeter, GetName(Yw.Hydro.ParterCatalog.Flowmeter)); } if (hydro.Pressmeters != null && hydro.Pressmeters.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Pressmeter, GetName(Yw.Hydro.ParterCatalog.Pressmeter)); } if (hydro.Nozzles != null && hydro.Nozzles.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Nozzle, GetName(Yw.Hydro.ParterCatalog.Nozzle)); } if (hydro.Hydrants != null && hydro.Hydrants.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Hydrant, GetName(Yw.Hydro.ParterCatalog.Hydrant)); } if (hydro.Coolings != null && hydro.Coolings.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Cooling, GetName(Yw.Hydro.ParterCatalog.Cooling)); } if (hydro.Pipes != null && hydro.Pipes.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Pipe, GetName(Yw.Hydro.ParterCatalog.Pipe)); } if (hydro.Translations != null && hydro.Translations.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Translation, GetName(Yw.Hydro.ParterCatalog.Translation)); } if (hydro.Pumps != null && hydro.Pumps.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Pump, GetName(Yw.Hydro.ParterCatalog.Pump)); } if (hydro.Valves != null && hydro.Valves.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Valve, GetName(Yw.Hydro.ParterCatalog.Valve)); } if (hydro.Exchangers != null && hydro.Exchangers.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Exchanger, GetName(Yw.Hydro.ParterCatalog.Exchanger)); } if (hydro.Compressors != null && hydro.Compressors.Count > 0) { dict.Add(Yw.Hydro.ParterCatalog.Compressor, GetName(Yw.Hydro.ParterCatalog.Compressor)); } return dict; } } }