public void ExportGeometryCase2() { PathGeometryBuilder g = new PathGeometryBuilder(); g.BeginPath(); g.Rect(10, 10, 100, 200, false); g.Stroke(); var geometry = g.ToGeometry(); var pathGeometry = geometry as PathGeometry; Assert.NotNull(pathGeometry); Assert.Single(pathGeometry.Figures); var figure = pathGeometry.Figures[0]; Assert.NotNull(figure); Assert.Equal(figure.StartPoint, new Point(10, 10)); Assert.False(figure.IsClosed); Assert.False(figure.IsFilled); var segments = figure.Segments; Assert.Single(segments); Assert.IsType <PolyLineSegment>(segments[0]); var segment = segments[0] as PolyLineSegment; Assert.True(segment.IsStroked); Assert.Equal(segment.Points, new[] { new Point(110, 10), new Point(110, 210), new Point(10, 210), new Point(10, 10) }); }
public void ExportGeometryMultipleFigures() { PathGeometryBuilder g = new PathGeometryBuilder(); g.BeginPath(); g.MoveTo(50, 140); g.LineTo(150, 60); g.LineTo(250, 140); g.ClosePath(); g.Stroke(); g.BeginPath(); g.Rect(10, 10, 100, 200, false); g.Stroke(); var geometry = g.ToGeometry(); var pathGeometry = geometry as PathGeometry; Assert.NotNull(pathGeometry); Assert.Equal(2, pathGeometry.Figures.Count); Assert.NotNull(pathGeometry.Figures[0]); Assert.NotNull(pathGeometry.Figures[1]); }