public static void DrawElement(Graphics zGraphics, Deck zDeck, ProjectLayoutElement zElement, ElementType eType, int nX, int nY, string sInput, bool bExport) { switch (eType) { case ElementType.Graphic: case ElementType.Shape: sInput = sInput.Trim(); break; } Font zFont = null; Brush zBrush = null; Pen zBorderPen = null; Color colorFont = Color.Black; if (0 != zElement.borderthickness) { zBorderPen = 255 != zElement.opacity ? new Pen(Color.FromArgb(zElement.opacity, zElement.GetElementBorderColor()), zElement.borderthickness) : new Pen(zElement.GetElementBorderColor(), zElement.borderthickness); } // Setup switch (eType) { case ElementType.Text: case ElementType.FormattedText: zFont = zElement.GetElementFont(); colorFont = zElement.GetElementColor(); zBrush = new SolidBrush(colorFont); break; case ElementType.Graphic: case ElementType.Shape: break; default: return; } // NOTE: this is the first transform if (0 != zElement.rotation) { // center the internal element then rotate and restore zGraphics.TranslateTransform(zElement.x + nX + (zElement.width >> 1), zElement.y + nY + (zElement.height >> 1)); zGraphics.RotateTransform(zElement.rotation); zGraphics.TranslateTransform(-(zElement.width >> 1), -(zElement.height >> 1)); if (CardMakerInstance.DrawElementBorder && CardMakerInstance.DrawSelectedElementRotationBounds && !bExport) { zGraphics.DrawRectangle(Pens.LightGreen, 0, 0, zElement.width - 1, zElement.height - 1); } } else { zGraphics.TranslateTransform(zElement.x + nX, zElement.y + nY); } // TODO: an interface for all these would be more appropriate // Draw switch (eType) { case ElementType.Text: s_zDrawText.DrawText(zGraphics, zElement, sInput, zBrush, zFont, colorFont); break; case ElementType.FormattedText: DrawFormattedText(zGraphics, zDeck, zElement, sInput, zBrush, zFont, colorFont); break; case ElementType.Graphic: DrawGraphic(zGraphics, sInput, zElement); break; case ElementType.Shape: ShapeManager.HandleShapeRender(zGraphics, sInput.ToLower(), zElement); break; } if (null != zBorderPen) { // note that the border is inclusive in the width/height consuming 2 pixels (0 to total-1) zGraphics.DrawRectangle(zBorderPen, 0, 0, zElement.width - 1, zElement.height - 1); } zGraphics.ResetTransform(); }