簡體   English   中英

WPF:隱藏繪制的點

[英]WPF: Hide drawn points

我的類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); 隱藏舊點?

System.Windows.Shapes.Path具有Visibility屬性。 將其設置為“ Hidden

path.Visibility = Visibility.Hidden;

我不明白你的問題。 這些點本身不應該可見。 只是路徑具有可見性。

您可以設置路徑的可見性屬性以將其隱藏在畫布中。 如果要對畫布中的所有路徑執行此操作,則可以遍歷畫布的子項並將可見性設置為visible.hidden

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM