public static SectionDefinition LoadSectionDefinition(XmlNode node) { SectionDefinition ret = new SectionDefinition(); ret.id = node.Attributes["id"].Value; foreach (XmlNode prop in node.ChildNodes) { if (prop.Name.Equals("location")) { ret.location.x = int.Parse(prop.Attributes["x"].Value); ret.location.y = int.Parse(prop.Attributes["y"].Value); } if (prop.Name.Equals("text")) { ret.text.color = ColorTranslator.FromHtml(prop.Attributes["color"].Value); ret.text.size = int.Parse(prop.Attributes["size"].Value); } if (prop.Name.Equals("border")) { ret.border.color = ColorTranslator.FromHtml(prop.Attributes["color"].Value); ret.border.size = int.Parse(prop.Attributes["size"].Value); } if (prop.Name.Equals("block")) { ret.block.height = int.Parse(prop.Attributes["height"].Value); ret.block.width = int.Parse(prop.Attributes["width"].Value); } } return (ret); }
public void WriteString(Graphics graphics, SectionDefinition section, string value) { graphics.SmoothingMode = SmoothingMode.AntiAlias; GraphicsPath path = null; if (section.block.width > 0 && section.block.height > 0) { path = GetTextPath(section.location.ToPoint(), section.text.size, value, section.block.ToSize()); } else { path = GetTextPath(section.location.ToPoint(), section.text.size, value); } SolidBrush b = new SolidBrush(section.text.color); if (section.border.size > 0) { Pen p = new Pen(section.border.color, section.border.size); graphics.DrawPath(p, path); graphics.FillPath(b, path); } else { graphics.FillPath(b, path); } }