C# WPF:隐藏绘制的点
在我的类C# WPF:隐藏绘制的点,c#,wpf,drawing,C#,Wpf,Drawing,在我的类Drawing中有一个名为drawPoly(…)的函数,该函数绘制点并连接它们。我想要的是,我怎样才能把它们藏在画布上?我有8个我的班级绘画实例。我不想删除整个画布,如果可能,只需隐藏绘制的点即可 private double t = 0; // x Startpostion für Graph private double xOld = 0; // x Startpostion für Graph private double yOld = 100; System.Wind
Drawing
中有一个名为drawPoly(…)
的函数,该函数绘制点并连接它们。我想要的是,我怎样才能把它们藏在画布上?我有8个我的班级绘画实例。我不想删除整个画布
,如果可能,只需隐藏绘制的点即可
private double t = 0; // x Startpostion für Graph
private double xOld = 0; // x Startpostion für Graph
private double yOld = 100;
System.Windows.Shapes.Path path;
public GeometryGroup pointGroupDrawing = new GeometryGroup();
...
public void drawPoly(double value, Brush colorBrush, int thickness)
{
// is for the x-Axis /time
t++;
// get old value and generate new point
Point pOne = new Point(xOld, yOld);
Point pTwo = new Point(t, value);
// connect old point wit new point
GeometryGroup lineGroup = new GeometryGroup();
LineGeometry connectorGeometry = new LineGeometry();
connectorGeometry.StartPoint = pOne;
connectorGeometry.EndPoint = pTwo;
lineGroup.Children.Add(connectorGeometry);
path = new System.Windows.Shapes.Path();
path.Data = lineGroup;
path.StrokeThickness = thickness;
path.Stroke = path.Fill = colorBrush;
// collect point for redrawing later ?
pointGroupDrawing.Children.Add(connectorGeometry);
// replace old point with new
xOld = t;
yOld = value;
coordinateSystem.Children.Add(path);
}
我可以使用这个
pointGroupDrawing.Children.Add(connectorGeometry)吗
要隐藏旧点吗?System.Windows.Shapes.Path
有一个属性。将其设置为隐藏
path.Visibility = Visibility.Hidden;
我不明白你的问题。这些点本身不应该是可见的。只有路径具有Visibly属性
可以设置路径的可见性属性以将其隐藏在画布中。如果要对画布中的所有路径执行此操作,可以遍历其子路径并将可见性设置为可见性。隐藏为什么要隐藏点?我是否也可以隐藏旧点?公共GeometryGroup pointGroupDrawing=新GeometryGroup();pointGroupDrawing.Children.Add(连接几何);不知道你的意思。您是否在不断地向多段线添加点,并希望删除旧点,只保留最后的
n
?是的,这就是我的意思,我在pointGroupDrawing中收集所有旧点,但是如何在画布上隐藏这些点呢?那么您最好使用多段线
而不是路径
,并在每次更新时设置其点
属性。我在pointGroupDrawing中收集所有旧点,但是我怎么能在画布上隐藏这些点呢?我想你应该使用多段线而不是路径