public LeCanvas(Control canvas) { xmlShapes = new XMLShapes(); Canvas = canvas; myMenu = new LeMenu(); self = this; }
private void OnShapesLoaded(XMLShapes ret) { if (ShapeReloaded != null) { ShapeReloaded(this, ret); } xmlShapes = ret; }
void leShapeList_ShapeReloaded(object sender, XMLShapes shapes) { xmlShapes = shapes; parent.Invalidate(); /* * xmlShapes.ShapeList.Clear(); * System.Console.WriteLine("Shapes count= " + xmlShapes.ShapeList.Count); * foreach (LeSerializableShape shape in xmlShapes.ShapeList) * { * System.Console.WriteLine("Shapes type= " + typeof(shape)); * if (shapes.LeShapeType == LeShapeType.Rect) * { * AreaShape shape0 = new AreaShape(parent, shape.Boundary); * AddShape(shape0); * shape0.leShape =shape; * System.Console.WriteLine("Added " + shape0.leShape.ToString()); * } * } */ }
public void DeSerializeXML(string fileName) { if (File.Exists(fileName)) { StreamReader sr = new StreamReader(fileName); XmlTextReader xr = new XmlTextReader(sr); XmlSerializer xs = new XmlSerializer(typeof(XMLShapes)); object c; if (xs.CanDeserialize(xr)) { try { XMLShapes ret = (XMLShapes)xs.Deserialize(xr); System.Console.WriteLine("XMLShapes Created"); OnShapesLoaded(ret); } catch (Exception e) { System.Console.WriteLine("Open file " + e.InnerException.Message); } finally { /* * c = xs.Deserialize(xr); * Type t = this.GetType(); * PropertyInfo[] properties = t.GetProperties(); * foreach (PropertyInfo p in properties) * { * p.SetValue(this, p.GetValue(c, null), null); * } */ } } xr.Close(); sr.Close(); } }
public static void DeSerializeXML(string fileName) { if (File.Exists(fileName)) { StreamReader sr = new StreamReader(fileName); XmlTextReader xr = new XmlTextReader(sr); XmlSerializer xs = new XmlSerializer(typeof(XMLShapes)); if (xs.CanDeserialize(xr)) { try { XMLShapes ret = (XMLShapes)xs.Deserialize(xr); LeCanvas.self.xmlShapes = ret; OnShapeReloaded(); } catch (Exception e) { System.Console.WriteLine("Open file " + e.InnerException.Message); } } xr.Close(); sr.Close(); } }
public BaseCanvas(Control canvas) { xmlShapes = new XMLShapes(); Canvas = canvas; }