public void SetModelFromXML(string address) { EJPShape xmlShape = new EJPShape(); string elementName = ""; XmlTextReader reader = new XmlTextReader(address); while (reader.Read()) { switch (reader.NodeType) { case XmlNodeType.Element: // New node. elementName = reader.Name; break; case XmlNodeType.Text: // New text element. xmlShape.SetPropertyFromXML(elementName, reader.Value); break; case XmlNodeType.EndElement: // End of node. if (reader.Name == "shape") // If node was a shape, add it to the list. { Add(xmlShape); xmlShape = new EJPShape(); } break; } } }
protected override void OnPaint(PaintEventArgs e) { // Call the OnPaint method of the base class. base.OnPaint(e); e.Graphics.DrawString("EJP Hello World!!!", Font, new SolidBrush(ForeColor), ClientRectangle); foreach (Object obj in model) { EJPShape shape = (EJPShape)obj; Rectangle rect = shape.ToRectangle(); if (shape.type == "oval") { EJPDrawOval(e, rect); } else { EJPDrawRectangle(e, rect); } } }