| | |
| | | /// <summary> |
| | | /// 缓存辅助类 |
| | | /// </summary> |
| | | public class CacheHelper |
| | | internal class CacheHelper |
| | | { |
| | | /// <summary> |
| | | /// HydroL2d |
| | |
| | | get { return HydroL2dParasHelper.HydroL2d; } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 连接节点边框画笔 |
| | | /// </summary> |
| | | public static Pen JunctionBorderPen |
| | | { |
| | | get |
| | | { |
| | | if (_junctionBorderPen == null) |
| | | { |
| | | var borderColor = ColorTranslator.FromHtml(HydroL2d.Junction.BorderColor); |
| | | var borderWidth = HydroL2d.Junction.BorderWidth; |
| | | _junctionBorderPen = new Pen(borderColor, borderWidth); |
| | | } |
| | | return _junctionBorderPen; |
| | | } |
| | | } |
| | | private static Pen _junctionBorderPen = null; |
| | | #region 连接节点 |
| | | |
| | | /// <summary> |
| | | /// 连接节点填充画刷 |
| | |
| | | { |
| | | if (_junctionFillBrush == null) |
| | | { |
| | | var fillColor = ColorTranslator.FromHtml(HydroL2d.Junction.FillColor); |
| | | var fillColor = ColorTranslator.FromHtml(HydroL2d.Junction.Fill.Color); |
| | | _junctionFillBrush = new SolidBrush(fillColor); |
| | | } |
| | | return _junctionFillBrush; |
| | | } |
| | | } |
| | | private static Brush _junctionFillBrush = null; |
| | | |
| | | /// <summary> |
| | | /// 连接节点悬停填充画刷 |
| | | /// </summary> |
| | | public static Brush JunctionHoveredFillBrush |
| | | { |
| | | get |
| | | { |
| | | if (_junctionHoveredFillBrush == null) |
| | | { |
| | | var fillColor = ColorTranslator.FromHtml(HydroL2d.Junction.HoveredFill.Color); |
| | | _junctionHoveredFillBrush = new SolidBrush(fillColor); |
| | | } |
| | | return _junctionHoveredFillBrush; |
| | | } |
| | | } |
| | | private static Brush _junctionHoveredFillBrush = null; |
| | | |
| | | /// <summary> |
| | | /// 连接节点选择填充画刷 |
| | | /// </summary> |
| | | public static Brush JunctionSelectedFillBrush |
| | | { |
| | | get |
| | | { |
| | | if (_junctionSelectedFillBrush == null) |
| | | { |
| | | var fillColor = ColorTranslator.FromHtml(HydroL2d.Junction.SelectedFill.Color); |
| | | _junctionSelectedFillBrush = new SolidBrush(fillColor); |
| | | } |
| | | return _junctionSelectedFillBrush; |
| | | } |
| | | } |
| | | private static Brush _junctionSelectedFillBrush = null; |
| | | |
| | | #endregion |
| | | |
| | | #region 水库 |
| | | |
| | | /// <summary> |
| | | /// 水库图片 |
| | |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Reservoir.Image}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _reservoirImage = img.CloneC(HydroL2d.Reservoir.Width, HydroL2d.Reservoir.Height); |
| | | _reservoirImage = img.CloneC(HydroL2d.Reservoir.Size.Width, HydroL2d.Reservoir.Size.Height); |
| | | _reservoirImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _reservoirImage; |
| | | } |
| | | } |
| | | private static Image _reservoirImage = null; |
| | | |
| | | /// <summary> |
| | | /// 水库悬停图片 |
| | | /// </summary> |
| | | public static Image ReservoirHoveredImage |
| | | { |
| | | get |
| | | { |
| | | if (_reservoirHoveredImage == null) |
| | | { |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Reservoir.HoveredImage}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _reservoirHoveredImage = img.CloneC(HydroL2d.Reservoir.HoveredSize.Width, HydroL2d.Reservoir.HoveredSize.Height); |
| | | _reservoirHoveredImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _reservoirHoveredImage; |
| | | } |
| | | } |
| | | private static Image _reservoirHoveredImage = null; |
| | | |
| | | /// <summary> |
| | | /// 水库选择图片 |
| | | /// </summary> |
| | | public static Image ReservoirSelectedImage |
| | | { |
| | | get |
| | | { |
| | | if (_reservoirSelectedImage == null) |
| | | { |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Reservoir.SelectedImage}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _reservoirSelectedImage = img.CloneC(HydroL2d.Reservoir.SelectedSize.Width, HydroL2d.Reservoir.SelectedSize.Height); |
| | | _reservoirSelectedImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _reservoirSelectedImage; |
| | | } |
| | | } |
| | | private static Image _reservoirSelectedImage = null; |
| | | |
| | | #endregion |
| | | |
| | | #region 水池 |
| | | |
| | | /// <summary> |
| | | /// 水池图片 |
| | |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Tank.Image}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _tankImage = img.CloneC(HydroL2d.Tank.Width, HydroL2d.Tank.Height); |
| | | _tankImage = img.CloneC(HydroL2d.Tank.Size.Width, HydroL2d.Tank.Size.Height); |
| | | _tankImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _tankImage; |
| | | } |
| | | } |
| | | private static Image _tankImage = null; |
| | | |
| | | /// <summary> |
| | | /// 水池悬停图片 |
| | | /// </summary> |
| | | public static Image TankHoveredImage |
| | | { |
| | | get |
| | | { |
| | | if (_tankHoveredImage == null) |
| | | { |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Tank.HoveredImage}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _tankHoveredImage = img.CloneC(HydroL2d.Tank.HoveredSize.Width, HydroL2d.Tank.HoveredSize.Height); |
| | | _tankHoveredImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _tankHoveredImage; |
| | | } |
| | | } |
| | | private static Image _tankHoveredImage = null; |
| | | |
| | | /// <summary> |
| | | /// 水池选择图片 |
| | | /// </summary> |
| | | public static Image TankSelectedImage |
| | | { |
| | | get |
| | | { |
| | | if (_tankSelectedImage == null) |
| | | { |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Tank.SelectedImage}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _tankSelectedImage = img.CloneC(HydroL2d.Tank.SelectedSize.Width, HydroL2d.Tank.SelectedSize.Height); |
| | | _tankSelectedImage.RotateFlip(RotateFlipType.RotateNoneFlipY); |
| | | } |
| | | } |
| | | return _tankSelectedImage; |
| | | } |
| | | } |
| | | private static Image _tankSelectedImage = null; |
| | | |
| | | #endregion |
| | | |
| | | #region 管线 |
| | | |
| | | /// <summary> |
| | | /// 管道线画笔 |
| | |
| | | { |
| | | if (_pipeLinePen == null) |
| | | { |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pipe.LineColor); |
| | | var lineWidth = HydroL2d.Pipe.LineWidth; |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pipe.Line.Color); |
| | | var lineWidth = HydroL2d.Pipe.Line.Width; |
| | | _pipeLinePen = new Pen(lineColor, lineWidth); |
| | | } |
| | | return _pipeLinePen; |
| | | } |
| | | } |
| | | private static Pen _pipeLinePen = null; |
| | | |
| | | /// <summary> |
| | | /// 管道悬停线画笔 |
| | | /// </summary> |
| | | public static Pen PipeHoveredLinePen |
| | | { |
| | | get |
| | | { |
| | | if (_pipeHoveredLinePen == null) |
| | | { |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pipe.HoveredLine.Color); |
| | | var lineWidth = HydroL2d.Pipe.HoveredLine.Width; |
| | | _pipeHoveredLinePen = new Pen(lineColor, lineWidth); |
| | | } |
| | | return _pipeHoveredLinePen; |
| | | } |
| | | } |
| | | private static Pen _pipeHoveredLinePen = null; |
| | | |
| | | /// <summary> |
| | | /// 管道选择线画笔 |
| | | /// </summary> |
| | | public static Pen PipeSelectedLinePen |
| | | { |
| | | get |
| | | { |
| | | if (_pipeSelectedLinePen == null) |
| | | { |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pipe.SelectedLine.Color); |
| | | var lineWidth = HydroL2d.Pipe.SelectedLine.Width; |
| | | _pipeSelectedLinePen = new Pen(lineColor, lineWidth); |
| | | } |
| | | return _pipeSelectedLinePen; |
| | | } |
| | | } |
| | | private static Pen _pipeSelectedLinePen = null; |
| | | |
| | | #endregion |
| | | |
| | | #region 水泵 |
| | | |
| | | /// <summary> |
| | | /// 水泵线画笔 |
| | |
| | | { |
| | | if (_pumpLinePen == null) |
| | | { |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pump.LineColor); |
| | | var lineWidth = HydroL2d.Pump.LineWidth; |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Pump.Line.Color); |
| | | var lineWidth = HydroL2d.Pump.Line.Width; |
| | | _pumpLinePen = new Pen(lineColor, lineWidth); |
| | | } |
| | | return _pumpLinePen; |
| | |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Pump.Image}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _pumpImage = img.CloneC(HydroL2d.Pump.Width, HydroL2d.Pump.Height); |
| | | _pumpImage = img.CloneC(HydroL2d.Pump.Size.Width, HydroL2d.Pump.Size.Height); |
| | | } |
| | | } |
| | | return _pumpImage; |
| | | } |
| | | } |
| | | private static Image _pumpImage = null; |
| | | |
| | | #endregion |
| | | |
| | | #region 阀门 |
| | | |
| | | /// <summary> |
| | | /// 阀门线画笔 |
| | |
| | | { |
| | | if (_valveLinePen == null) |
| | | { |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Valve.LineColor); |
| | | var lineWidth = HydroL2d.Valve.LineWidth; |
| | | var lineColor = ColorTranslator.FromHtml(HydroL2d.Valve.Line.Color); |
| | | var lineWidth = HydroL2d.Valve.Line.Width; |
| | | _valveLinePen = new Pen(lineColor, lineWidth); |
| | | } |
| | | return _valveLinePen; |
| | |
| | | var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"images/l2d/{HydroL2d.Valve.Image}.png"); |
| | | using (var img = Image.FromFile(fileName)) |
| | | { |
| | | _valveImage = img.CloneC(HydroL2d.Valve.Width, HydroL2d.Valve.Height); |
| | | _valveImage = img.CloneC(HydroL2d.Valve.Size.Width, HydroL2d.Valve.Size.Height); |
| | | } |
| | | } |
| | | return _valveImage; |
| | |
| | | } |
| | | private static Image _valveImage = null; |
| | | |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | } |