GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / DrawPie Method
The horizontal (X) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The vertical (Y) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
The required radius of the circle, of which the pie shaped portion is a part, expressed in the current units specified by the SetMeasurementUnit method.
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
Set this parameter to true, if you want to fill the pie using the currently defined fill color, otherwise set it to false. You can set the fill color using the SetFillColor(Byte,Byte,Byte) method.
Set this parameter to true, if you want to stroke the pie (draw a boundary line along the pie shape) using the currently defined line color, otherwise set it to false. You can set the line color using the SetLineColor(Byte,Byte,Byte) method.
Example





In This Topic
DrawPie Method (GdPicturePDF)
In This Topic
Draws a pie shape, means a sector of a circle, on the currently selected page of the loaded PDF document according to what you have specified. The center point of the pie's circle and the circle's radius need to be set in the current units defined in the PDF document with respect to the currently located origin, related to the actual page. The pie shape (sector) of the circle's area is clearly defined by the StartAngle and the EndAngle parameters.

You can simply use the GetMeasurementUnit method to determine the currently defined units and you can easily use the SetMeasurementUnit method to reset the units according to your preference.

Syntax
'Declaration
 
Public Function DrawPie( _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Radius As Single, _
   ByVal StartAngle As Single, _
   ByVal EndAngle As Single, _
   ByVal Fill As Boolean, _
   ByVal Stroke As Boolean _
) As GdPictureStatus
public GdPictureStatus DrawPie( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Fill,
   bool Stroke
)
public function DrawPie( 
    Left: Single;
    Top: Single;
    Radius: Single;
    StartAngle: Single;
    EndAngle: Single;
    Fill: Boolean;
    Stroke: Boolean
): GdPictureStatus; 
public function DrawPie( 
   Left : float,
   Top : float,
   Radius : float,
   StartAngle : float,
   EndAngle : float,
   Fill : boolean,
   Stroke : boolean
) : GdPictureStatus;
public: GdPictureStatus DrawPie( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Fill,
   bool Stroke
) 
public:
GdPictureStatus DrawPie( 
   float Left,
   float Top,
   float Radius,
   float StartAngle,
   float EndAngle,
   bool Fill,
   bool Stroke
) 

Parameters

Left
The horizontal (X) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Top
The vertical (Y) coordinate of the center of the pie's circle, expressed in the current units specified by the SetMeasurementUnit method with respect to the defined origin, related to the currently selected page.
Radius
The required radius of the circle, of which the pie shaped portion is a part, expressed in the current units specified by the SetMeasurementUnit method.
StartAngle
The starting angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
EndAngle
The ending angle, in degrees, where 0 means the 12 o'clock position. Positive values represent angles drawn in the clockwise direction, negative ones in the opposite direction.
Fill
Set this parameter to true, if you want to fill the pie using the currently defined fill color, otherwise set it to false. You can set the fill color using the SetFillColor(Byte,Byte,Byte) method.
Stroke
Set this parameter to true, if you want to stroke the pie (draw a boundary line along the pie shape) using the currently defined line color, otherwise set it to false. You can set the line color using the SetLineColor(Byte,Byte,Byte) method.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Just to remind you that angles are measured clockwise using this method.

Example
How to draw stroked and filled pies. The example shows you reasonable combinations of the Fill and the Stroke parameters.
Dim caption As String = "Example: DrawPie"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.NewPDF()
If status = GdPictureStatus.OK Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    'This is the font only used to describe the drawn pies.
    Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        If (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetLineColor(255, 140, 0) = GdPictureStatus.OK) AndAlso 'the color used to stroke the pies
           (gdpicturePDF.SetLineWidth(0.1F) = GdPictureStatus.OK) AndAlso 'the line width used to stroke
           (gdpicturePDF.SetFillColor(153, 50, 204) = GdPictureStatus.OK) AndAlso 'the color used to fill the pies
           (gdpicturePDF.DrawPie(8, 6, 4, -45, 45, False, True) = GdPictureStatus.OK) AndAlso 'the first pie
           (gdpicturePDF.DrawPie(5, 12, 4, -45, 45, True, False) = GdPictureStatus.OK) AndAlso 'the second pie
           (gdpicturePDF.DrawPie(15, 12, 4, -45, 45, True, True) = GdPictureStatus.OK) AndAlso 'the third pie
           (gdpicturePDF.SetFillColor(0, 0, 0) = GdPictureStatus.OK) AndAlso 'the color used to draw text + the code below is used to describe all pies drawn above
           (gdpicturePDF.DrawText(fontName, 8, 6, "1") = GdPictureStatus.OK) AndAlso 'the center of the circle of the first pie
           (gdpicturePDF.DrawText(fontName, 5, 12, "2") = GdPictureStatus.OK) AndAlso 'the center of the circle of the second pie
           (gdpicturePDF.DrawText(fontName, 15, 12, "3") = GdPictureStatus.OK) AndAlso 'the center of the circle of the third pie
           (gdpicturePDF.DrawText(fontName, 7, 4, "only stroke") = GdPictureStatus.OK) AndAlso 'used attributes
           (gdpicturePDF.DrawText(fontName, 4, 10, "only fill") = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontName, 14, 10, "fill & stroke") = GdPictureStatus.OK) Then
            status = gdpicturePDF.SaveToFile("test_DrawPie.pdf")
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The example has been followed successfully and the file has been saved.", caption)
            Else
                MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
            End If
        Else
            MessageBox.Show("The example has not been followed successfully." + vbCrLf + "The last known status is " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: DrawPie";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.NewPDF();
if (status == GdPictureStatus.OK)
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    //This is the font only used to describe the drawn pies.
    string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        if ((gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetLineColor(255, 140, 0) == GdPictureStatus.OK) && //the color used to stroke the pies
            (gdpicturePDF.SetLineWidth(0.1f) == GdPictureStatus.OK) && //the line width used to stroke
            (gdpicturePDF.SetFillColor(153, 50, 204) == GdPictureStatus.OK) && //the color used to fill the pies
            (gdpicturePDF.DrawPie(8, 6, 4, -45, 45, false, true) == GdPictureStatus.OK) && //the first pie
            (gdpicturePDF.DrawPie(5, 12, 4, -45, 45, true, false) == GdPictureStatus.OK) && //the second pie
            (gdpicturePDF.DrawPie(15, 12, 4, -45, 45, true, true) == GdPictureStatus.OK) && //the third pie
            //the code below is used to describe all pies drawn above
            (gdpicturePDF.SetFillColor(0, 0, 0) == GdPictureStatus.OK) && //the color used to draw text
            (gdpicturePDF.DrawText(fontName, 8, 6, "1") == GdPictureStatus.OK) && //the center of the circle of the first pie
            (gdpicturePDF.DrawText(fontName, 5, 12, "2") == GdPictureStatus.OK) && //the center of the circle of the second pie
            (gdpicturePDF.DrawText(fontName, 15, 12, "3") == GdPictureStatus.OK) && //the center of the circle of the third pie
            (gdpicturePDF.DrawText(fontName, 7, 4, "only stroke") == GdPictureStatus.OK) && //used attributes
            (gdpicturePDF.DrawText(fontName, 4, 10, "only fill") == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontName, 14, 10, "fill & stroke") == GdPictureStatus.OK))
        {
            status = gdpicturePDF.SaveToFile("test_DrawPie.pdf");
            if (status == GdPictureStatus.OK)
                MessageBox.Show("The example has been followed successfully and the file has been saved.", caption);
            else
                MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
        }
        else
            MessageBox.Show("The example has not been followed successfully.\nThe last known status is " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The AddStandardFont() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The NewPDF() method has failed with the status: " + status.ToString(), caption);
gdpicturePDF.Dispose();
See Also