0

我的班级中有一个Drawing名为的函数drawPoly(...),该函数绘制点并将它们连接起来。我想要的是,如何将它们隐藏在画布中?我有 8 个我的班级绘图实例。如果可能的话,我不想删除整个Canvas,只是隐藏绘制的点。

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);来隐藏旧点吗?

4

2 回答 2

1

System.Windows.Shapes.Path有财产Visibility。将其设置为Hidden

path.Visibility = Visibility.Hidden;
于 2013-06-20T11:41:58.407 回答
0

我不明白你的问题。这些点本身不应该是可见的。只是路径具有可见性属性。

您可以设置路径的可见性属性以将其隐藏在画布中。如果您想对画布中的所有路径执行此操作,您可以遍历它的子节点并将可见性设置为 visibility.hidden

于 2013-06-20T11:45:47.753 回答