I am trying to create a 3D pie wedge (If you have a method that will do this, please let me know). I am using the XGraphics.DrawPie() method to draw the top piece of the wedge, and to ensure that I can determine the endpoints, I am trying to manually outline it. Below is a simple routine to show you what I am doing. I'm just not seeing what I'm doing wrong. Any help would be greatly appreciated.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PdfSharp;
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Drawing.Layout;
using PdfSharp.Drawing.BarCodes;
namespace Sample_PDF
{
class Program
{
static void Main(string[] args)
{
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
page.Width = XUnit.FromInch(5);
page.Height = XUnit.FromInch(5);
XGraphics gfx = XGraphics.FromPdfPage(page);
XPen pen = new XPen(XBrushes.Black.Color, 1);
XRect rect = new XRect(10, 10, (page.Width / 2) - 20, (page.Height / 4) - 20);
gfx.DrawPie(XBrushes.Cyan, rect, 0, 25);
XPoint p1 = PointFromEllipse(rect, 0);
XPoint p2 = PointFromEllipse(rect, 25);
XGraphicsPath path = new XGraphicsPath();
path.AddLine(rect.Center, p1);
path.AddArc(rect, 0, 25);
path.AddLine(p2, rect.Center);
gfx.DrawPath(pen, path);
document.Save("c:\\TestPDF.pdf");
}
private static XPoint PointFromEllipse(XRect bounds, double degrees)
{
double a = bounds.Width / 2.0;
double b = bounds.Height / 2.0;
double rad = (Math.PI / 180.0) * degrees;
XPoint ptCenter = bounds.Center;
double x = bounds.Center.X + (a * Math.Cos(rad));
double y = bounds.Center.Y + (b * Math.Sin(rad));
return new XPoint(x, y);
}
}
}