protected override void SetProperties() { GdiProperties.AddProperty(SCALE_TEXT, true, "Set the value to true if you want the text to shrink " + "and grow with resizes. " + "If the value is set to false, the text will align " + "itself within the area of the scaled bounds. (If the " + "bounds it set to scale of course)."); GdiProperties.AddProperty(EDIT_TEXT, false, "Set the value to true if you want to alter the text " + "after code generation. If the value is false, the text " + "will not be allowed to change"); }
public override string EmitGDICode(string graphicsName, GDIGenerationTool helper) { bool blnScaleText = (bool)GdiProperties.GetValue(SCALE_TEXT); bool blnEditText = (bool)GdiProperties.GetValue(EDIT_TEXT); string strText = blnEditText ? "dText[eShapeText." + this.Name + "]" : helper.FormatText(text); string strBounds = blnScaleText ? "shapeBoundsOld" : "shapeBoundsNew"; string str = "//Text: " + this.Name + "\r\n"; if (painter.PaintWithPath) { str += helper.SetShapeBounds(this); } else { str += helper.GeneratePaintToolInit(this); } str += "Font " + this.Name + "Font = new Font(\"" + font.FontFamily.Name + "\", " + font.Size.ToString() + "f * (" + Size.Width + "f / (float)shapeBoundsOld.Width), (FontStyle)" + (int)font.Style + ");\r\n" + "StringFormat " + this.Name + "Format = new StringFormat();\r\n" + this.Name + "Format.Alignment = (StringAlignment)" + (int)format.Alignment + ";\r\n"; if (blnScaleText) { str += "//Will apply the scaling factors to the graphics object\r\n" + graphicsName + ".ScaleTransform(scale.Width, scale.Height);\r\n"; } if (painter.PaintWithPath) { str += "path = new GraphicsPath();\r\n" + "path.AddString(" + strText + ", " + this.Name + "Font.FontFamily ,(int)" + this.Name + "Font.Style," + this.Name + "Font.Size,\r\n" + strBounds + "," + this.Name + "Format);\r\n" + helper.GeneratePaintToolInit(this, "path.GetBounds()", false) + "//Paint the text\r\n"; if (painter.PaintFill) { str += graphicsName + ".FillPath(" + this.Name + "Brush, path);\r\n"; } if (painter.PaintBorder) { str += graphicsName + ".DrawPath(" + this.Name + "Pen, path);\r\n"; } } else { str += graphicsName + ".DrawString(" + strText + ", " + this.Name + "Font, " + this.Name + "Brush, " + strBounds + ", " + this.Name + "Format);\r\n"; } if (blnScaleText) { str += graphicsName + ".ResetTransform();\r\n"; } str += "//Cleanup Text objects\r\n" + this.Name + "Font.Dispose();\r\n" + this.Name + "Format.Dispose();\r\n" + helper.GeneratePaintToolCleanup(this); return(str); }