|
Benutzer
Status: Offline
Beiträge: 11
Registriert seit: 02.06.2008
|
Code übersichtlich machen -
01.09.2008, 13:47
Hallo zusammen,
ich habe ein kleines Problem: ich habe Code erhalten mit dem Kommentar "hier mach mal ne erweiterung" -> die Erweiterung war nicht das Problem, mir wurde nur halb schlecht als ich den code so ansah...
jetzt die Frage, wie würdet ihr diesen Code übersichtlicher machen?
public class PDF
{
public PDF()
{
//
// TODO: Add constructor logic here
//
}
PdfDocument document;
public static PdfDocument GeneratePDF(OrderInformationContainer oi)
{
float yPos = 120f + 20;
ConsumerInformationContainer contractPartner = oi.ConsumerInformation[0];
ConsumerInformationContainer admin = oi.ConsumerInformation[1];
ConsumerInformationContainer produser = oi.ConsumerInformation[2];
BillingAddressInformationContainer billing = oi.BillingInformation;
// Create a font
XFont Header = new XFont("Verdana", 12, XFontStyle.Bold);
XFont Heading1 = new XFont("Verdana", 10, XFontStyle.Bold);
XFont fontText = new XFont("Verdana", 10, XFontStyle.Regular);
// Get an XGraphics object for drawing
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
// Image Source
string imgsrc = ....
XImage xImage = XImage.FromFile(@imgsrc);
int height = (int)Math.Ceiling((page.Width.Point - 530));
//Header
gfx.DrawImage(xImage, 30, 30, page.Width.Point - 500, height);
gfx.DrawString(Resources.Translation.OrderOverview , Header, XBrushes.Black, new System.Drawing.PointF(200f, 95));
//Contract Partner
gfx.DrawString(Resources.Translation.CompanyDetail s, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 20));
gfx.DrawString(Resources.Translation.Customer_Comp anyName, fontText, XBrushes.Black, new System.Drawing.PointF(200f, yPos + 40));
gfx.DrawString(oi.CustomerInformation.CompanyName, fontText, XBrushes.Black, new System.Drawing.PointF(200f, yPos + 40));
gfx.DrawString(Resources.Translation.Customer_Stre et, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 60));
gfx.DrawString(oi.CustomerInformation.Street, fontText, XBrushes.Black, new System.Drawing.PointF(200f, yPos + 60));
gfx.DrawString(Resources.Translation.Customer_PLZ_ Ort, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 80));
gfx.DrawString(oi.CustomerInformation.Zip + " " + oi.CustomerInformation.City, fontText, XBrushes.Black, new System.Drawing.PointF(200f, yPos + 80));
gfx.DrawString(Resources.Translation.Customer_Coun try, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 100));
gfx.DrawString(oi.CustomerInformation.Country, fontText, XBrushes.Black, new System.Drawing.PointF(200f, yPos + 100));
gfx.DrawString(Resources.Translation.Customer_Head erContactPerson, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 120));
gfx.DrawString(Resources.Translation.Customer_Titl e, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 140));
gfx.DrawString(Resources.Translation.Customer_Firs tName, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 160));
gfx.DrawString(Resources.Translation.Customer_Last Name, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 180));
gfx.DrawString(Resources.Translation.Customer_Tele fonNumber, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 200));
gfx.DrawString(Resources.Translation.Customer_Mobi leNumber, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 220));
gfx.DrawString(Resources.Translation.Customer_Emai l, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 240));
gfx.DrawString(Resources.Translation.Customer_Logi nName, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 260));
gfx.DrawString(Resources.Translation.Customer_Pass word, fontText, XBrushes.Black, new System.Drawing.PointF(50f, yPos + 280));
...
Geändert von marcofilli88 (01.09.2008 um 14:50 Uhr).
|