From 8f677b1741b78e4de4c95373fc02587a05d7b5ca Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 16 八月 2024 17:52:08 +0800
Subject: [PATCH] 2d尝试,功能基本实现,还差绘制特定区域

---
 WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/00-core/CacheHelper.cs |  220 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 191 insertions(+), 29 deletions(-)

diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/00-core/CacheHelper.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/00-core/CacheHelper.cs
index 2d7a16a..4a7b2e8 100644
--- a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/00-core/CacheHelper.cs
+++ b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/00-core/CacheHelper.cs
@@ -3,7 +3,7 @@
     /// <summary>
     /// 缂撳瓨杈呭姪绫�
     /// </summary>
-    public class CacheHelper
+    internal class CacheHelper
     {
         /// <summary>
         /// HydroL2d
@@ -13,23 +13,7 @@
             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>
         /// 杩炴帴鑺傜偣濉厖鐢诲埛
@@ -40,13 +24,51 @@
             {
                 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>
         /// 姘村簱鍥剧墖
@@ -60,13 +82,60 @@
                     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>
         /// 姘存睜鍥剧墖
@@ -80,13 +149,60 @@
                     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>
         /// 绠¢亾绾跨敾绗�
@@ -97,14 +213,54 @@
             {
                 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>
         /// 姘存车绾跨敾绗�
@@ -115,8 +271,8 @@
             {
                 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;
@@ -136,13 +292,17 @@
                     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>
         /// 闃�闂ㄧ嚎鐢荤瑪
@@ -153,8 +313,8 @@
             {
                 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;
@@ -174,7 +334,7 @@
                     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;
@@ -182,6 +342,8 @@
         }
         private static Image _valveImage = null;
 
+        #endregion
+
 
     }
 }

--
Gitblit v1.9.3