System.Windows.Media PathGeometry is a class in the C# programming language that is used to represent a geometric shape that can be drawn on a 2D surface. It is part of the Windows Presentation Foundation (WPF) library.
Some examples of using PathGeometry include creating shapes such as circles, rectangles, lines, and complex shapes using various path segments such as Bezier curves, arcs, and elliptical arcs. Here is some example code that creates a simple triangle using PathGeometry:
PathGeometry pg = new PathGeometry(); PathFigure pf = new PathFigure(); pf.StartPoint = new Point(0, 0); pf.Segments.Add(new LineSegment(new Point(50, 100), true)); pf.Segments.Add(new LineSegment(new Point(100, 0), true)); pf.IsClosed = true; pg.Figures.Add(pf);
Here, we create a new PathGeometry instance and add a single PathFigure to it. The PathFigure represents a connected sequence of lines and curves that define the shape of the final geometry. We set the StartPoint property to (0,0) and add two LineSegments to define the other two points of the triangle. Finally, we set the IsClosed property to true to indicate that the shape is a closed polygon.
Another example could be creating a circle using PathGeometry:
PathGeometry geometry = new PathGeometry(); EllipseGeometry ellipse = new EllipseGeometry(); ellipse.Center = new Point(50, 50); ellipse.RadiusX = 30; ellipse.RadiusY = 30; geometry.AddGeometry(ellipse);
Here, we create a PathGeometry and an EllipseGeometry instance, which is a type of Geometry used to define a simple circle or ellipse. We set the Center property of the ellipse to (50,50) and set the radius to 30. Finally, we add the ellipse to the PathGeometry using the AddGeometry method.
In summary, the System.Windows.Media PathGeometry class is used to define geometric shapes that can be drawn on the screen. It is part of the WPF library and is used extensively in creating UI elements and graphical applications in C#.
C# (CSharp) System.Windows.Media PathGeometry - 60 examples found. These are the top rated real world C# (CSharp) examples of System.Windows.Media.PathGeometry extracted from open source projects. You can rate examples to help us improve the quality of examples.