Example #1
0
        //-----------------------------------------------------------------------
        public void Insert(int index, CollectionChildItem child)
        {
            var def = Definition as CollectionDefinition;

            if (IsAtMax)
            {
                return;
            }

            var cdef = Definition as CollectionDefinition;

            UndoRedo.ApplyDoUndo(
                delegate
            {
                Children.Insert(index, child);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                delegate
            {
                Children.Remove(child);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                "Inserting item " + child.Name + " to collection " + Name);
        }
Example #2
0
        //-----------------------------------------------------------------------
        public void Remove(CollectionChildItem item)
        {
            var def = Definition as CollectionDefinition;

            if (IsAtMin)
            {
                return;
            }

            var index = Children.IndexOf(item);

            UndoRedo.ApplyDoUndo(
                delegate
            {
                Children.Remove(item);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                delegate
            {
                Children.Insert(index, item);
                RaisePropertyChangedEvent("HasContent");
                RaisePropertyChangedEvent("Description");
            },
                "Removing item " + item.Name + " from collection " + Name);
        }
Example #3
0
        //-----------------------------------------------------------------------
        public void AddNew()
        {
            CollectionChildItem child = null;

            using (UndoRedo.DisableUndoScope())
            {
                var item = WrappedItem.Definition.CreateData(UndoRedo);
                child             = Definition.CreateData(UndoRedo) as CollectionChildItem;
                child.WrappedItem = item;
            }

            var collection = ParentCollection;
            var index      = collection.Children.IndexOf(this) + 1;

            (ParentCollection as ICollectionItem).Insert(index, child);
        }
Example #4
0
        //-----------------------------------------------------------------------
        public void Duplicate()
        {
            var el = new XElement("Root");

            WrappedItem.Definition.SaveData(el, WrappedItem);

            CollectionChildItem child = null;

            using (UndoRedo.DisableUndoScope())
            {
                var item = WrappedItem.Definition.LoadData(el.Elements().First(), UndoRedo);
                child             = Definition.CreateData(UndoRedo) as CollectionChildItem;
                child.WrappedItem = item;
            }

            var collection = ParentCollection;
            var index      = collection.Children.IndexOf(this) + 1;

            (ParentCollection as ICollectionItem).Insert(index, child);
        }
Example #5
0
        //-----------------------------------------------------------------------
        public void PasteNew()
        {
            foreach (var childDef in CDef.ChildDefinitions)
            {
                if (Clipboard.ContainsData(childDef.WrappedDefinition.CopyKey))
                {
                    var flat = Clipboard.GetData(childDef.WrappedDefinition.CopyKey) as string;
                    var root = XElement.Parse(flat);

                    CollectionChildItem child = null;

                    using (UndoRedo.DisableUndoScope())
                    {
                        var item = childDef.WrappedDefinition.LoadData(root, UndoRedo);
                        child             = childDef.CreateData(UndoRedo) as CollectionChildItem;
                        child.WrappedItem = item;
                    }

                    UndoRedo.ApplyDoUndo(
                        delegate
                    {
                        Children.Add(child);
                        RaisePropertyChangedEvent("HasContent");
                        RaisePropertyChangedEvent("Description");
                    },
                        delegate
                    {
                        Children.Remove(child);
                        RaisePropertyChangedEvent("HasContent");
                        RaisePropertyChangedEvent("Description");
                    },
                        Name + " pasted new");

                    IsExpanded = true;
                }
            }
        }