From 97a43bf839f59cdda1641d61706e6e71a0c5e172 Mon Sep 17 00:00:00 2001 From: cloudflight <cloudflight@126.com> Date: 星期二, 24 十二月 2024 23:54:17 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/02-node/Junction.cs | 171 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 135 insertions(+), 36 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/02-node/Junction.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/02-node/Junction.cs index 9e0bba2..e2835ff 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/02-node/Junction.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.L2d.Core/01-network/02-node/Junction.cs @@ -17,56 +17,155 @@ public float? Height { get; set; } /// <summary> - /// 杈规棰滆壊 - /// </summary> - public Color? BorderColor { get; set; } - - /// <summary> - /// 杈规瀹藉害 - /// </summary> - public float? BorderWidth { get; set; } - - /// <summary> /// 濉厖棰滆壊 /// </summary> public Color? FillColor { get; set; } + + /// <summary> + /// 鎮仠瀹藉害 + /// </summary> + public float? HoveredWidth { get; set; } + + /// <summary> + /// 鎮仠楂樺害 + /// </summary> + public float? HoveredHeight { get; set; } + + /// <summary> + /// 鎮仠濉厖棰滆壊 + /// </summary> + public Color? HoveredFillColor { get; set; } + + /// <summary> + /// 閫夋嫨瀹藉害 + /// </summary> + public float? SelectedWidth { get; set; } + + /// <summary> + /// 閫夋嫨楂樺害 + /// </summary> + public float? SelectedHeight { get; set; } + + /// <summary> + /// 閫夋嫨濉厖棰滆壊 + /// </summary> + public Color? SelectedFillColor { get; set; } + + + private Coordinate _coordinate { get; set; }//鍧愭爣淇℃伅 + + //鑾峰彇鍧愭爣浣嶇疆 + private Coordinate GetCoordinate(Graphics g) + { + var ps = this.Position;//鍘熷鐐� + var ws = this.Width.HasValue ? this.Width.Value : CacheHelper.HydroL2d.Junction.Size.Width;//鍘熷瀹藉害 + var hs = this.Height.HasValue ? this.Height.Value : CacheHelper.HydroL2d.Junction.Size.Height;//鍘熷楂樺害 + var wz = ws / g.PageScale; //缂╂斁瀹藉害 + var hz = hs / g.PageScale;//缂╂斁楂樺害 + return Coordinate.GetCoordinate(ps, 0, new SizeF(wz, hz), StringAlignment.Center, StringAlignment.Center); + } /// <summary> /// 缁樺埗 /// </summary> public override void Draw(Graphics g) { - var fromCachePen = true; - var pen = CacheHelper.JunctionBorderPen; - if (this.BorderColor.HasValue && this.BorderWidth.HasValue) - { - pen = new Pen(this.BorderColor.Value, this.BorderWidth.Value); - fromCachePen = false; - } - var fromCacheBrush = true; - var brush = CacheHelper.JunctionFillBrush; - if (this.FillColor.HasValue) - { - brush = new SolidBrush(this.FillColor.Value); - fromCacheBrush = false; - } + _coordinate = GetCoordinate(g); - var width = this.Width.HasValue ? this.Width.Value : CacheHelper.HydroL2d.Junction.Width; - var height = this.Height.HasValue ? this.Height.Value : CacheHelper.HydroL2d.Junction.Height; - var x = this.Position.X - width / 2f; - var y = this.Position.Y - height / 2f; - var rect = new RectangleF(x, y, width, height); - g.DrawEllipse(pen, rect); - g.FillEllipse(brush, rect); + if (this.Hovered) + { + var fromCacheBrush = true; + var brush = CacheHelper.JunctionHoveredFillBrush; + if (this.HoveredFillColor.HasValue) + { + brush = new SolidBrush(this.HoveredFillColor.Value); + fromCacheBrush = false; + } - if (!fromCachePen) - { - pen.Dispose(); + var width = this.HoveredWidth.HasValue ? this.HoveredWidth.Value : CacheHelper.HydroL2d.Junction.HoveredSize.Width; + var height = this.HoveredHeight.HasValue ? this.HoveredHeight.Value : CacheHelper.HydroL2d.Junction.HoveredSize.Height; + var x = this.Position.X - width / g.PageScale / 2f; + var y = this.Position.Y - height / g.PageScale / 2f; + var rect = new RectangleF(x, y, width / g.PageScale, height / g.PageScale); + g.FillEllipse(brush, rect); + + if (!fromCacheBrush) + { + brush.Dispose(); + } } - if (!fromCacheBrush) + else if (this.Selected) { - brush.Dispose(); + var fromCacheBrush = true; + var brush = CacheHelper.JunctionSelectedFillBrush; + if (this.SelectedFillColor.HasValue) + { + brush = new SolidBrush(this.SelectedFillColor.Value); + fromCacheBrush = false; + } + + var width = this.SelectedWidth.HasValue ? this.SelectedWidth.Value : CacheHelper.HydroL2d.Junction.SelectedSize.Width; + var height = this.SelectedHeight.HasValue ? this.SelectedHeight.Value : CacheHelper.HydroL2d.Junction.SelectedSize.Height; + var x = this.Position.X - width / g.PageScale / 2f; + var y = this.Position.Y - height / g.PageScale / 2f; + var rect = new RectangleF(x, y, width / g.PageScale, height / g.PageScale); + g.FillEllipse(brush, rect); + + if (!fromCacheBrush) + { + brush.Dispose(); + } + } + else + { + var fromCacheBrush = true; + var brush = CacheHelper.JunctionFillBrush; + if (this.FillColor.HasValue) + { + brush = new SolidBrush(this.FillColor.Value); + fromCacheBrush = false; + } + + var width = this.Width.HasValue ? this.Width.Value : CacheHelper.HydroL2d.Junction.Size.Width; + var height = this.Height.HasValue ? this.Height.Value : CacheHelper.HydroL2d.Junction.Size.Height; + var x = this.Position.X - width / g.PageScale / 2f; + var y = this.Position.Y - height / g.PageScale / 2f; + var rect = new RectangleF(x, y, width / g.PageScale, height / g.PageScale); + g.FillEllipse(brush, rect); + + if (!fromCacheBrush) + { + brush.Dispose(); + } } } + + /// <summary> + /// 鍖呭惈 + /// </summary> + public override bool Contains(PointF pt) + { + if (_coordinate == null) + { + return false; + } + return _coordinate.BeforeRectf.Contains(pt); + } + + /// <summary> + /// 鐩镐氦 + /// </summary> + public override bool Intersect(RectangleF rectf) + { + if (rectf.Contains(this.Position)) + { + return true; + } + return false; + + } + + + } } -- Gitblit v1.9.3