Пример #1
0
        public void PasteInstanceSaves(List <InstanceSave> copiedInstances, StateSave copiedState, ElementSave targetElement)
        {
            List <InstanceSave> newInstances = new List <InstanceSave>();

            foreach (var instanceAsObject in copiedInstances)
            {
                InstanceSave sourceInstance = instanceAsObject as InstanceSave;
                ElementSave  sourceElement  = sourceInstance.ParentContainer;

                InstanceSave targetInstance = sourceInstance.Clone();

                // the original may have been defined in a base component. The new instance will not be
                // derived in the base, so let's get rid of that:
                targetInstance.DefinedByBase = false;

                newInstances.Add(targetInstance);

                if (targetElement != null)
                {
                    PastedCopiedInstance(sourceInstance, sourceElement, targetElement, targetInstance, copiedState);
                }
            }

            if (newInstances.Count > 1)
            {
                SelectedState.Self.SelectedInstances = newInstances;
            }
        }
Пример #2
0
        private void HandleInstanceAdded(ElementSave container, InstanceSave instance)
        {
            var elementsInheritingFromContainer =
                ObjectFinder.Self.GetElementsInheritingFrom(container);

            foreach (var inheritingElement in elementsInheritingFromContainer)
            {
                var clone = instance.Clone();
                clone.DefinedByBase   = true;
                clone.ParentContainer = inheritingElement;
                inheritingElement.Instances.Add(clone);

                // inheritingElement could be a derived of derived, in which case we
                // need to go just one up the inheritance tree:
                var directBase = ObjectFinder.Self.GetElementSave(inheritingElement.BaseType);

                AdjustInstance(directBase, inheritingElement, clone.Name);

                GumCommands.Self.FileCommands.TryAutoSaveElement(inheritingElement);
                GumCommands.Self.GuiCommands.RefreshElementTreeView(inheritingElement);
            }
        }
Пример #3
0
        public void PasteInstanceSaves(List <InstanceSave> copiedInstances, StateSave copiedState, ElementSave targetElement)
        {
            List <InstanceSave> newInstances = new List <InstanceSave>();

            foreach (var instanceAsObject in copiedInstances)
            {
                InstanceSave sourceInstance = instanceAsObject as InstanceSave;
                ElementSave  sourceElement  = sourceInstance.ParentContainer;

                InstanceSave targetInstance = sourceInstance.Clone();
                newInstances.Add(targetInstance);

                if (targetElement != null)
                {
                    PastedCopiedInstance(sourceInstance, sourceElement, targetElement, targetInstance, copiedState);
                }
            }

            if (newInstances.Count > 1)
            {
                SelectedState.Self.SelectedInstances = newInstances;
            }
        }