private void deserializeDrawObjects() { _drawObjects = new List <DrawObject>(); if (string.IsNullOrEmpty(FileName)) { return; } string path = Path.Combine(Path.GetDirectoryName(FileName), "drawObjects"); if (!Directory.Exists(path)) { return; } string fileName = Path.Combine(path, Path.GetFileName(FileName) + ".xml"); if (!File.Exists(fileName)) { return; } _drawObjects = SerializableDrawObject.GetDrawObjectsFromXML(_currGraphics, File.ReadAllText(fileName), _zoomMultiplier); if (_drawObjects == null) { _drawObjects = new List <DrawObject>(); } if (_drawObjects.Any()) { redraw(true); } }
public void Undo(SerializableDrawObject sdo) { _startPoint = new Point(sdo.StartPoint.X, sdo.StartPoint.Y); _endPoint = new Point(sdo.EndPoint.X, sdo.EndPoint.Y); _pen.Color = Color.FromArgb(sdo.PenColor); _pen.Width = sdo.PenWidth; reset(); }
public static DrawObject FromSerialized(Graphics graphics, SerializableDrawObject sdo, float zoomMultiplier) { //var drawObj = Activator.CreateInstance(typeof(DrawObject).Assembly.GetType(sdo.DrawObjectType), new object[] { sdo.ID, graphics, // new Pen(Color.FromArgb(sdo.PenColor), sdo.PenWidth), new Point(sdo.StartX, sdo.StartY), sdo.Erase, sdo.Highlight }) as DrawObject; var drawObj = (DrawObject)CreateDrawObject(typeof(DrawObject).Assembly.GetType(sdo.DrawObjectType), sdo.ID, graphics, new Pen(Color.FromArgb(sdo.PenColor), sdo.PenWidth), new Point(sdo.StartPoint.X, sdo.StartPoint.Y), zoomMultiplier); drawObj.Erase = sdo.Erase; drawObj.Highlight = sdo.Highlight; drawObj._endPoint = new Point(sdo.EndPoint.X, sdo.EndPoint.Y); drawObj.ID = sdo.ID; drawObj.SetCargo(sdo.Cargo); drawObj.OnDrawObjectCreated(); return(drawObj); }
private void serializeDrawObjects() { if (string.IsNullOrEmpty(FileName)) { return; } string path = Path.Combine(Path.GetDirectoryName(FileName), "drawObjects"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } File.WriteAllText(Path.Combine(path, Path.GetFileName(FileName) + ".xml"), SerializableDrawObject.GetXMLForDrawObjects(_drawObjects)); }