0
我正在构建一个应用程序,我必须在画布上绘制自己的图形。现在我这样做:在WPF中绘制数字
PathFigure figure = new PathFigure() { StartPoint = new Point(0, TurboHeight/turboSizeFactor * turboSchaufelFactor), IsClosed = true};
LineSegment seg = new LineSegment() { Point = new Point(turboWidth, TurboHeight/turboSizeFactor * turboSchaufelFactor) };
figure.Segments.Add(seg);
seg = new LineSegment(){Point=new Point(turboWidth*0.85, 0)};
figure.Segments.Add(seg);
seg = new LineSegment() { Point = new Point(turboWidth * 0.15, 0) };
figure.Segments.Add(seg);
PathGeometry geo = new PathGeometry();
geo.Figures.Add(figure);
Path path = new Path() { Data = geo, Stroke = Brushes.Black, StrokeThickness = 1, SnapsToDevicePixels = true, Fill = Brushes.LightGray};
CnvMain.Children.Add(path);
是这样做的方式或有一个更简单的方法。我的意思是我为画布上的几行创建了很多对象。
谢谢。
您可以查看[StreamGeometry](http://msdn.microsoft.com/en-us/library/system.windows.media.streamgeometry.aspx)。它是PathGeometry的轻量级替代品。 – Clemens