public HistoryMementoAddMultiDrawingItem(Metadata metadata, AbstractMultiDrawing manager, Guid itemId)
        {
            this.metadata = metadata;
            this.manager  = manager;
            this.itemId   = itemId;

            commandName = string.Format("{0} ({1})", ScreenManagerLang.CommandAddDrawing_FriendlyName, manager.ToolDisplayName);
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a new item to a multi drawing.
        /// </summary>
        public void AddMultidrawingItem(AbstractMultiDrawing multidrawing, AbstractMultiDrawingItem item)
        {
            multidrawing.Add(item);
            SelectDrawing(multidrawing);

            if (MultiDrawingItemAdded != null)
            {
                MultiDrawingItemAdded(this, new MultiDrawingItemEventArgs(item, multidrawing));
            }
        }
        public HistoryMementoDeleteMultiDrawingItem(Metadata metadata, AbstractMultiDrawing manager, Guid itemId, SerializationFilter filter)
        {
            this.metadata = metadata;
            this.manager  = manager;
            this.itemId   = itemId;

            commandName = string.Format("{0} ({1})", ScreenManagerLang.CommandDeleteDrawing_FriendlyName, manager.ToolDisplayName);

            if (manager != null)
            {
                data = MultiDrawingItemSerializer.SerializeMemento(metadata, manager, manager.GetItem(itemId), filter);
            }

            // TODO: get the associated trackable drawing and save it too.
        }
Esempio n. 4
0
        public void DeleteMultiDrawingItem(AbstractMultiDrawing manager, Guid itemId)
        {
            ITrackable item = manager.GetItem(itemId) as ITrackable;

            if (item != null)
            {
                DeleteTrackableDrawing(item);
            }

            manager.Remove(itemId);
            UnselectAll();

            if (MultiDrawingItemDeleted != null)
            {
                MultiDrawingItemDeleted(this, EventArgs.Empty);
            }
        }
Esempio n. 5
0
        private ITrackable ConvertToTrackable(object parameter)
        {
            ITrackable trackableDrawing = null;

            if (parameter is AbstractMultiDrawing)
            {
                AbstractMultiDrawing manager = parameter as AbstractMultiDrawing;
                if (manager != null)
                {
                    trackableDrawing = manager.SelectedItem as ITrackable;
                }
            }
            else
            {
                trackableDrawing = parameter as ITrackable;
            }

            return(trackableDrawing);
        }
        public static string SerializeMemento(Metadata metadata, AbstractMultiDrawing manager, AbstractMultiDrawingItem item, SerializationFilter filter)
        {
            IKvaSerializable kvaDrawing = item as IKvaSerializable;

            if (kvaDrawing == null)
            {
                return("");
            }

            string result = "";

            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = false;
            settings.CloseOutput = true;

            StringBuilder builder = new StringBuilder();

            using (XmlWriter w = XmlWriter.Create(builder, settings))
            {
                w.WriteStartElement("DrawingMemento");

                DrawingSerializer.Serialize(w, kvaDrawing, filter);

                if (item is ITrackable)
                {
                    metadata.TrackabilityManager.WriteTracker(w, item.Id);
                }

                w.WriteEndElement();

                w.Flush();
                result = builder.ToString();
            }

            return(result);
        }
 public MultiDrawingItemEventArgs(AbstractMultiDrawingItem item, AbstractMultiDrawing manager)
 {
     this.item    = item;
     this.manager = manager;
 }