public HistoryMementoDeleteDrawing(Metadata metadata, Guid managerId, Guid drawingId, string drawingName) { this.metadata = metadata; this.managerId = managerId; this.drawingId = drawingId; this.drawingName = drawingName; commandName = string.Format("{0} ({1})", ScreenManagerLang.CommandDeleteDrawing_FriendlyName, drawingName); AbstractDrawingManager manager = metadata.GetDrawingManager(managerId); if (manager != null) { data = DrawingSerializer.SerializeMemento(metadata, manager.GetDrawing(drawingId), SerializationFilter.All, true); } }
public HistoryMementoModifyDrawing(Metadata metadata, Guid managerId, Guid drawingId, string drawingName, SerializationFilter filter) { this.metadata = metadata; this.managerId = managerId; this.drawingId = drawingId; this.drawingName = drawingName; this.filter = filter; UpdateCommandName(drawingName); AbstractDrawingManager manager = metadata.GetDrawingManager(managerId); if (manager != null) { data = DrawingSerializer.SerializeMemento(metadata, manager.GetDrawing(drawingId), filter, false); } }
public static void DeserializeModifyMemento(Guid managerId, Guid drawingId, string data, Metadata metadata) { AbstractDrawingManager manager = metadata.GetDrawingManager(managerId); IKvaSerializable drawing = manager.GetDrawing(drawingId) as IKvaSerializable; if (drawing == null) { return; } PointF identityScale = new PointF(1, 1); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; settings.IgnoreProcessingInstructions = true; settings.IgnoreWhitespace = true; settings.CloseInput = true; using (XmlReader r = XmlReader.Create(new StringReader(data), settings)) { r.MoveToContent(); if (!(r.Name == "DrawingMemento")) { return; } r.ReadStartElement(); drawing.ReadXml(r, identityScale, TimeHelper.IdentityTimestampMapper); if (drawing is ITrackable) { metadata.TrackabilityManager.ReadTracker(r, identityScale, TimeHelper.IdentityTimestampMapper); metadata.TrackabilityManager.Assign(drawing as ITrackable); } } }