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);
            }
        }
Example #3
0
        public void DeleteDrawing(Guid managerId, Guid drawingId)
        {
            // Remove event handlers from the drawing as well as all associated data like tracking data,
            // and finally remove the drawing itself.

            AbstractDrawingManager manager = null;

            if (managerId == chronoManager.Id)
            {
                manager = chronoManager;
            }
            else if (managerId == trackManager.Id)
            {
                manager = trackManager;
            }
            else
            {
                manager = GetKeyframe(managerId);
            }

            if (manager == null)
            {
                return;
            }

            AbstractDrawing drawing = manager.GetDrawing(drawingId);

            if (drawing == null)
            {
                return;
            }

            BeforeDrawingDeletion(drawing);

            manager.RemoveDrawing(drawingId);
            UnselectAll();

            if (DrawingDeleted != null)
            {
                DrawingDeleted(this, EventArgs.Empty);
            }
        }
Example #4
0
        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);
                }
            }
        }
Example #5
0
        public AbstractDrawing GetDrawing(Guid managerId, Guid drawingId)
        {
            AbstractDrawingManager manager = null;

            if (managerId == chronoManager.Id)
            {
                manager = chronoManager;
            }
            else if (managerId == trackManager.Id)
            {
                manager = trackManager;
            }
            else
            {
                manager = GetKeyframe(managerId);
            }

            if (manager == null)
            {
                return(null);
            }

            return(manager.GetDrawing(drawingId));
        }