Example #1
0
        private static bool DragDropNosIntoElement(NamedObjectSave movingNos, IElement elementMovingInto)
        {
            bool succeeded = true;

            // moving to another element, so let's copy
            NamedObjectSave clonedNos = movingNos.Clone();

            UpdateNosAfterDragDrop(clonedNos, elementMovingInto);

            elementMovingInto.NamedObjects.Add(clonedNos);

            var referenceCheck = ProjectManager.VerifyReferenceGraph(elementMovingInto);

            if (referenceCheck == ProjectManager.CheckResult.Failed)
            {
                succeeded = false;
                // VerifyReferenceGraph (currently) shows a popup so we don't have to here
                //MessageBox.Show("This movement would result in a circular reference");

                elementMovingInto.NamedObjects.Remove(clonedNos);
            }

            if (succeeded)
            {
                // If an object which was on a Layer
                // is moved into another Element, then
                // the cloned object probably shouldn't
                // be on a layer.  Not sure if we want to
                // see if there is a Layer with the same-name
                // but we maybe shouldn't assume that they mean
                // the same thing.
                clonedNos.LayerOn = null;

                BaseElementTreeNode treeNodeForElementMovedInto = GlueState.Self.Find.ElementTreeNode(elementMovingInto);
                treeNodeForElementMovedInto.UpdateReferencedTreeNodes();
                GlueCommands.Self.GenerateCodeCommands
                .GenerateElementAndReferencedObjectCodeTask(elementMovingInto);

                MessageBox.Show("Copied\n" + movingNos + "\n\nto\n" + clonedNos);
            }
            return(succeeded);
        }