Working With ArcSegment Class in WPF

Here we discuss the ArcSegment Class. It creates an arc which is basically based on the starting point of the PathFigure object. Now we take an example of the ArcSegment Class.

        <Path Stroke="Green" Fill="Pink" StrokeThickness="1" Width="Auto">
                            <PathFigure StartPoint="150,200">
                                                    IsLargeArc="False" SweepDirection="Clockwise"

The output will be:


Now we look at the code:

<ArcSegment Point="300,300" Size="700,100" RotationAngle="90" IsLargeArc="False" SweepDirection="Clockwise" />

Here the Point is used to define the terminal point of the Arc. The Size specifies the X and Y radius of the arc. The Rotation Angle specifies the X axis of the arc. IsLargeArc specifies that the arc will be drawn more than 180 degrees.
And SweepDirection specifies whether the arc sweeps clockwise or counterclockwise.

We can also do it with the help of coding:

In this example, we use a Button Control; when we click on the Button the Arc will appear:

<StackPanel Name="StackPanel1">
        <Button Height="23" HorizontalAlignment="Left" Margin="10,10,0,0" Name="button1" VerticalAlignment="Top" Width="75"
Click="button1_Click">Click Me!!!</Button>

Now we write the code in the .cs page:

    private void button1_Click(object sender, RoutedEventArgs e)
        PathGeometry pathGeometry = new PathGeometry();
        PathFigure figure = new PathFigure();
        figure.StartPoint = new Point(150, 200);
        new ArcSegment(
        new Point(300, 200),
        new Size(700, 100),
        Path path = new Path();
        path.Data = pathGeometry;
        path.Fill = Brushes.Pink;
        path.Stroke = Brushes.Green;

Here we create the instance of the PathGeometry() and Path Figure Object.

The output Will Be: