Ejemplo n.º 1
0
        private void ParseKeyframes(XmlReader r)
        {
            // TODO: catch empty tag <Keyframes/>.

            // Note: unlike chrono and tracks, keyframes are "merged" into existing keyframes if one already exists at the same position.
            // This has an impact on how we add drawings.
            // We keep the drawings internally to the keyframe during the parse, and only perform the post-drawing init at the end,
            // when the keyframe is merge-inserted into the collection.
            // For chrono and tracks on the other hand, we perform the post-drawing init on the fly during the parse.

            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                if (r.Name == "Keyframe")
                {
                    Keyframe keyframe = KeyframeSerializer.Deserialize(r, GetScaling(), RemapTimestamp, metadata);
                    if (keyframe != null)
                    {
                        metadata.MergeInsertKeyframe(keyframe);
                    }
                }
                else
                {
                    string unparsed = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed);
                }
            }

            r.ReadEndElement();
        }
        public override HistoryMemento PerformUndo()
        {
            HistoryMemento redoMemento = new HistoryMementoAddKeyframe(metadata, keyframeId);

            redoMemento.CommandName = commandName;

            Keyframe keyframe = KeyframeSerializer.DeserializeMemento(data, metadata);

            metadata.AddKeyframe(keyframe);

            return(redoMemento);
        }
        public HistoryMementoDeleteKeyframe(Metadata metadata, Guid keyframeId)
        {
            this.metadata   = metadata;
            this.keyframeId = keyframeId;

            // TODO: save the complete keyframe to XML (including the thumbnail).
            // Including all drawings and trackable drawings associated with these drawings.
            Keyframe keyframe = metadata.GetKeyframe(keyframeId);

            if (keyframe == null)
            {
                throw new NullReferenceException("keyframe");
            }

            data = KeyframeSerializer.SerializeMemento(metadata, keyframe);
        }
Ejemplo n.º 4
0
        private void WriteKeyframes(XmlWriter w)
        {
            int enabled = metadata.Keyframes.Count(kf => !kf.Disabled);

            if (enabled == 0)
            {
                return;
            }

            w.WriteStartElement("Keyframes");

            foreach (Keyframe kf in metadata.Keyframes.Where(kf => !kf.Disabled))
            {
                KeyframeSerializer.Serialize(w, kf);
            }

            w.WriteEndElement();
        }