From abf1e3b3334ab47c38aa92405a11a6ec92b7847a Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期四, 31 十月 2024 17:18:37 +0800 Subject: [PATCH] bimface 水流 --- WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/04-link/Pump.cs | 215 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 185 insertions(+), 30 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/04-link/Pump.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/04-link/Pump.cs index de7eead..2108211 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/04-link/Pump.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/04-link/Pump.cs @@ -16,6 +16,26 @@ public float? LineWidth { get; set; } /// <summary> + /// 鎮仠绾胯壊 + /// </summary> + public Color? HoveredLineColor { get; set; } + + /// <summary> + /// 鎮仠绾垮 + /// </summary> + public float? HoveredLineWidth { get; set; } + + /// <summary> + /// 閫夋嫨绾胯壊 + /// </summary> + public Color? SelectedLineColor { get; set; } + + /// <summary> + /// 閫夋嫨绾垮 + /// </summary> + public float? SelectedLineWidth { get; set; } + + /// <summary> /// 鍥剧墖 /// </summary> public Image Image { get; set; } @@ -29,6 +49,38 @@ /// 楂樺害 /// </summary> public float? Height { get; set; } + + /// <summary> + /// 鎮仠鍥剧墖 + /// </summary> + public Image HoveredImage { get; set; } + + /// <summary> + /// 鎮仠瀹藉害 + /// </summary> + public float? HoveredWidth { get; set; } + + /// <summary> + /// 鎮仠楂樺害 + /// </summary> + public float? HoveredHeight { get; set; } + + /// <summary> + /// 閫夋嫨鍥剧墖 + /// </summary> + public Image SelectedImage { get; set; } + + /// <summary> + /// 閫夋嫨瀹藉害 + /// </summary> + public float? SelectedWidth { get; set; } + + /// <summary> + /// 閫夋嫨楂樺害 + /// </summary> + public float? SelectedHeight { get; set; } + + private Coordinate _coordinate { get; set; }//鍧愭爣淇℃伅 @@ -51,53 +103,156 @@ public override void Draw(Graphics g) { _coordinate = GetCoordinate(g); + #region 鐢荤嚎 - var fromCachePen = true; - var pen = CacheHelper.PumpLinePen; - if (this.LineColor.HasValue && this.LineWidth.HasValue) + if (this.Hovered) { - pen = new Pen(this.LineColor.Value, this.LineWidth.Value); - fromCachePen = false; + var fromCachePen = true; + var pen = CacheHelper.PumpHoveredLinePen; + if (this.HoveredLineColor.HasValue && this.HoveredLineWidth.HasValue) + { + pen = new Pen(this.HoveredLineColor.Value, this.HoveredLineWidth.Value); + fromCachePen = false; + } + var penWidth = pen.Width; + pen.Width = pen.Width / g.PageScale; + g.DrawLine(pen, this.StartPosition, this.EndPosition); + pen.Width = penWidth; + if (!fromCachePen) + { + pen.Dispose(); + } } - var penWidth = pen.Width; - pen.Width = pen.Width / g.PageScale; - g.DrawLine(pen, this.StartPosition, this.EndPosition); - pen.Width = penWidth; - if (!fromCachePen) + else if (this.Selected) { - pen.Dispose(); + var fromCachePen = true; + var pen = CacheHelper.PumpSelectedLinePen; + if (this.SelectedLineColor.HasValue && this.SelectedLineWidth.HasValue) + { + pen = new Pen(this.SelectedLineColor.Value, this.SelectedLineWidth.Value); + fromCachePen = false; + } + var penWidth = pen.Width; + pen.Width = pen.Width / g.PageScale; + g.DrawLine(pen, this.StartPosition, this.EndPosition); + pen.Width = penWidth; + if (!fromCachePen) + { + pen.Dispose(); + } } + else + { + var fromCachePen = true; + var pen = CacheHelper.PumpLinePen; + if (this.LineColor.HasValue && this.LineWidth.HasValue) + { + pen = new Pen(this.LineColor.Value, this.LineWidth.Value); + fromCachePen = false; + } + var penWidth = pen.Width; + pen.Width = pen.Width / g.PageScale; + g.DrawLine(pen, this.StartPosition, this.EndPosition); + pen.Width = penWidth; + if (!fromCachePen) + { + pen.Dispose(); + } + } + + #endregion #region 鐢诲浘鐗� - var img = CacheHelper.PumpImage; - if (this.Image != null) + if (this.Hovered) { - img = this.Image; + var img = CacheHelper.PumpHoveredImage; + if (this.HoveredImage != null) + { + img = this.HoveredImage; + } + var width = this.HoveredWidth.HasValue ? this.HoveredWidth.Value : CacheHelper.HydroL2d.Pump.HoveredSize.Width; + var height = this.HoveredHeight.HasValue ? this.HoveredHeight.Value : CacheHelper.HydroL2d.Pump.HoveredSize.Height; + var isNewImage = false; + if (img.Width != (int)width || img.Height != (int)height) + { + img = img.CloneC(width, height); + isNewImage = true; + } + + var pt = this.StartPosition.GetCenter(this.EndPosition); + var dx = width / g.PageScale / 2f; + var dy = height / g.PageScale / 2f; + var p0 = new PointF(pt.X - dx, pt.Y - dy); + + g.DrawImage(img, p0); + + if (isNewImage) + { + img.Dispose(); + } } - var width = this.Width.HasValue ? this.Width.Value : CacheHelper.HydroL2d.Pump.Size.Width; - var height = this.Height.HasValue ? this.Height.Value : CacheHelper.HydroL2d.Pump.Size.Height; - var isNewImage = false; - if (img.Width != (int)width || img.Height != (int)height) + else if (this.Selected) { - img = img.CloneC(width, height); - isNewImage = true; + var img = CacheHelper.PumpSelectedImage; + if (this.SelectedImage != null) + { + img = this.SelectedImage; + } + var width = this.SelectedWidth.HasValue ? this.SelectedWidth.Value : CacheHelper.HydroL2d.Pump.SelectedSize.Width; + var height = this.SelectedHeight.HasValue ? this.SelectedHeight.Value : CacheHelper.HydroL2d.Pump.SelectedSize.Height; + var isNewImage = false; + if (img.Width != (int)width || img.Height != (int)height) + { + img = img.CloneC(width, height); + isNewImage = true; + } + + var pt = this.StartPosition.GetCenter(this.EndPosition); + var dx = width / g.PageScale / 2f; + var dy = height / g.PageScale / 2f; + var p0 = new PointF(pt.X - dx, pt.Y - dy); + + g.DrawImage(img, p0); + + if (isNewImage) + { + img.Dispose(); + } + } + else + { + var img = CacheHelper.PumpImage; + if (this.Image != null) + { + img = this.Image; + } + var width = this.Width.HasValue ? this.Width.Value : CacheHelper.HydroL2d.Pump.Size.Width; + var height = this.Height.HasValue ? this.Height.Value : CacheHelper.HydroL2d.Pump.Size.Height; + var isNewImage = false; + if (img.Width != (int)width || img.Height != (int)height) + { + img = img.CloneC(width, height); + isNewImage = true; + } + + var pt = this.StartPosition.GetCenter(this.EndPosition); + var dx = width / g.PageScale / 2f; + var dy = height / g.PageScale / 2f; + var p0 = new PointF(pt.X - dx, pt.Y - dy); + + g.DrawImage(img, p0); + + if (isNewImage) + { + img.Dispose(); + } } - var pt = this.StartPosition.GetCenter(this.EndPosition); - var dx = width / g.PageScale / 2f; - var dy = height / g.PageScale / 2f; - var p0 = new PointF(pt.X - dx, pt.Y - dy); - g.DrawImage(img, p0); - - if (isNewImage) - { - img.Dispose(); - } #endregion -- Gitblit v1.9.3