隐藏绘制的点
本文关键字:绘制 隐藏 | 更新日期: 2023-09-27 18:19:24
我有一个函数在我的类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;
我不明白你的问题。点本身不应该是可见的。只是路径有一个可见性属性。
你可以设置路径的visibility属性来隐藏它。如果你想对画布中的所有路径都这样做,你可以遍历它的子路径,并将可见性设置为visibility.hidden