From e3480050ec8569769745bb545df2b3ddb2c80d0f Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期二, 06 五月 2025 14:03:37 +0800 Subject: [PATCH] 优化水流方向功能 --- Yw.WpfUI.Hydro.L3d.Core/03-draw/00-core/12-flow-direction/FlowDirectionDraw3D.cs | 72 ++++++++++++++++++++++------------- 1 files changed, 45 insertions(+), 27 deletions(-) diff --git a/Yw.WpfUI.Hydro.L3d.Core/03-draw/00-core/12-flow-direction/FlowDirectionDraw3D.cs b/Yw.WpfUI.Hydro.L3d.Core/03-draw/00-core/12-flow-direction/FlowDirectionDraw3D.cs index 1c1ad47..c702577 100644 --- a/Yw.WpfUI.Hydro.L3d.Core/03-draw/00-core/12-flow-direction/FlowDirectionDraw3D.cs +++ b/Yw.WpfUI.Hydro.L3d.Core/03-draw/00-core/12-flow-direction/FlowDirectionDraw3D.cs @@ -12,9 +12,7 @@ { _link3d = link3d; _positive = positive; - _link3d.Visual3DChangedEvent += UpdateVisual; - UpdateVisual(); - + Attach(); } private readonly LinkDraw3D _link3d = null;//缁樺埗绠℃ @@ -25,37 +23,57 @@ public bool Positive { get { return _positive; } - set { _positive = value; } + set + { + _positive = value; + Update(); + } } private bool _positive = true; - /// <summary> - /// 鏇存柊鍙槸鍏冪礌 - /// </summary> - public void UpdateVisual() + //鏇存柊 + private void Update() { - var htmlColor = Yw.Settings.HydroL3dParasHelper.HydroL3d.Flow.Direction.HtmlColor; - var color = htmlColor.ToMediaColor(); - this.Material = DrawMaterialHelper.GetMaterial(color); - - var center = _link3d.Drawer.StartPosition + (_link3d.Drawer.EndPosition - _link3d.Drawer.StartPosition) / 2d; - var start = _link3d.Drawer.StartPosition + (center - _link3d.Drawer.StartPosition) / 2d; - var end = center + (_link3d.Drawer.EndPosition - center) / 2d; - - if (this.Positive) + var start = _link3d.GetStartPosition(); + var end = _link3d.GetEndPosition(); + if (start.HasValue && end.HasValue) { - //this.Point1 = start; - //this.Point2 = end; - } - else - { - //this.Point1 = start; - //this.Point2 = end; - } + var center = start.Value + (end.Value - start.Value) / 2d; + var sp = start.Value + (center - start.Value) / 2d; + var ep = center + (end.Value - center) / 2d; - //this.Diameter = Yw.Settings.HydroL3dParasHelper.HydroL3d.Flow.Direction.Diameter; + if (this.Positive) + { + this.Point1 = sp; + this.Point2 = ep; + } + else + { + this.Point1 = ep; + this.Point2 = sp; + } + var htmlColor = Yw.Settings.HydroL3dParasHelper.HydroL3d.Flow.Direction.HtmlColor; + var color = htmlColor.ToMediaColor(); + this.Material = DrawMaterialHelper.GetMaterial(color); + + var diameter = _link3d.GetDiameter(); + this.Diameter = diameter; + } + } + + + //闄勫姞 + private void Attach() + { + _link3d.Visual3DChangedEvent += Update; + } + + //鍒嗙 + private void Detach() + { + _link3d.Visual3DChangedEvent -= Update; } /// <summary> @@ -63,7 +81,7 @@ /// </summary> public void Dispose() { - _link3d.Visual3DChangedEvent -= UpdateVisual; + Detach(); } } -- Gitblit v1.9.3