예제 #1
0
        private void PasteNodeFromClipboardToSelection()
        {
            var result = ReClassClipboard.Paste(CurrentProject, Program.Logger);

            foreach (var pastedClassNode in result.Item1)
            {
                if (!CurrentProject.ContainsClass(pastedClassNode.Uuid))
                {
                    CurrentProject.AddClass(pastedClassNode);
                }
            }

            var selectedNodes = memoryViewControl.GetSelectedNodes();

            if (selectedNodes.Count == 1)
            {
                var selectedNode  = selectedNodes[0].Node;
                var containerNode = selectedNode.GetParentContainer();
                var classNode     = selectedNode.GetParentClass();
                if (containerNode != null && classNode != null)
                {
                    containerNode.BeginUpdate();

                    foreach (var node in result.Item2)
                    {
                        if (node is BaseWrapperNode)
                        {
                            var rootWrapper = node.GetRootWrapperNode();
                            Debug.Assert(rootWrapper == node);

                            if (rootWrapper.ShouldPerformCycleCheckForInnerNode())
                            {
                                if (rootWrapper.ResolveMostInnerNode() is ClassNode innerNode)
                                {
                                    if (!IsCycleFree(classNode, innerNode))
                                    {
                                        continue;
                                    }
                                }
                            }
                        }

                        containerNode.InsertNode(selectedNode, node);
                    }

                    containerNode.EndUpdate();
                }
            }
        }