编辑Nuget包C#Helixtoolkit.WPF
我在我的C#程序中使用Helixtoolkit.
WPF.我已经导入了NuGet包,它运行得很好.但是,我想编辑其中一个文件,特别是GridLinesVisual.cs.我想改变该文件中的一个函数的运行方式,但似乎无法使其正常工作.
我需要更改的功能从第247行开始保护覆盖MeshGeometry3D Tessellate() 这是我需要更新/更改的文件的链接 我的程序中的调用代码是grid = new GridLinesVisual3D(); 我不像C语言那样熟悉C#,但我知道我无法创建子类来编辑这个函数.我认为覆盖是实现这一目标的正确方法,但我无法做到这一点. using HelixToolkit.Wpf; using System.Windows; using System.Windows.Data; using System.Windows.Media; using System.Windows.Media.Media3D; namespace Axcro.Helix_Toolkit_Extentions { class RectGrid : GridLinesVisual3D { protected override MeshGeometry3D Tessellate() { this.lengthDirection = this.LengthDirection; this.lengthDirection.Normalize(); this.widthDirection = Vector3D.CrossProduct(this.Normal,this.lengthDirection); this.widthDirection.Normalize(); var mesh = new MeshBuilder(true,false); double minX = -this.Width / 2; double minY = -this.Length / 2; double maxX = this.Width / 2; double maxY = this.Length / 2; double x = minX; double eps = this.MinorDistance / 10; while (x <= maxX + eps) { double t = this.Thickness; if (IsMultipleOf(x,this.MajorDistance)) { t *= 2; } this.AddLineX(mesh,x,minY,maxY,t); x += this.MinorDistance; } var m = mesh.ToMesh(); m.Freeze(); return m; } } } 这段代码编译得很好,但我对Tessellate的更改没有显示出来. 对于它的价值,Tessellate功能是在X和Y方向创建网格线.我只想要Y方向的网格线,而不是X.所以基本上我不想要网格,我只想要线条…… 解决方法
您的更改仅适用于RectGrid类.您没有修改原始类的行为,这不是覆盖的工作方式.
您需要确保使用Axcro.Helix_Toolkit_Extentions添加;到实例化类的文件顶部.如果RectGrid类位于使用它的不同DLL中.确保添加引用. 然后,您将使用实例化GridLinesVisual3D的类实例 grid = new RectGrid(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |