user2261524
user2261524

Reputation: 415

WPF: Hide drawn points

I have a function in my class Drawing called drawPoly(...), this function draws points and connect them. What I want is, how can I hide them in the canvas? I have 8 instance of my class drawing. I want not delete the whole Canvas if possible, just hide the drawn points.

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);        
}

Can I use this pointGroupDrawing.Children.Add(connectorGeometry); to hide the older points?

Upvotes: 0

Views: 1474

Answers (2)

Tobias
Tobias

Reputation: 11

I don't understand your question. The points itself shouldn't be visible. Just the path has a visiblity property.

You can set the visibility property of your path to hide it in your canvas. if you want to to do this with all paths in your canvas, you can iterate through it's children and set the visibility to visibility.hidden

Upvotes: 0

Clemens
Clemens

Reputation: 128060

System.Windows.Shapes.Path has a Visibility property. Set that to Hidden.

path.Visibility = Visibility.Hidden;

Upvotes: 1

Related Questions