예제 #1
0
        private bool CanPaste(bool asNew = false)
        {
            if (_clipboardNodes == null)
            {
                return(false);
            }

            ElementNode destinationNode  = null;
            TreeNode    selectedTreeNode = treeview.SelectedNode;

            if (selectedTreeNode != null)
            {
                destinationNode = selectedTreeNode.Tag as ElementNode;
            }

            IEnumerable <ElementNode> invalidNodesForTarget = Enumerable.Empty <ElementNode>();

            if (destinationNode == null && !asNew)
            {
                invalidNodesForTarget = VixenSystem.Nodes.InvalidRootNodes;
            }
            else if (destinationNode != null)
            {
                invalidNodesForTarget = destinationNode.InvalidChildren();
            }
            IEnumerable <ElementNode> invalidSourceNodes = invalidNodesForTarget.Intersect(_clipboardNodes);

            if (invalidSourceNodes.Any())
            {
                return(false);
            }

            return(true);
        }
예제 #2
0
        private void pasteNodesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_clipboardNodes == null)
            {
                return;
            }

            ElementNode destinationNode  = null;
            TreeNode    selectedTreeNode = treeview.SelectedNode;

            if (selectedTreeNode != null)
            {
                destinationNode = selectedTreeNode.Tag as ElementNode;
            }

            IEnumerable <ElementNode> invalidNodesForTarget;

            if (destinationNode == null)
            {
                invalidNodesForTarget = VixenSystem.Nodes.InvalidRootNodes;
            }
            else
            {
                invalidNodesForTarget = destinationNode.InvalidChildren();
            }

            IEnumerable <ElementNode> invalidSourceNodes = invalidNodesForTarget.Intersect(_clipboardNodes);

            if (invalidSourceNodes.Any())
            {
                SystemSounds.Asterisk.Play();
            }
            else
            {
                // Check to see if the new parent node would be 'losing' the Element (ie. becoming a
                // group instead of a leaf node with a element/patches). Prompt the user first.
                if (CheckAndPromptIfNodeWillLosePatches(destinationNode))
                {
                    return;
                }

                foreach (ElementNode cn in _clipboardNodes)
                {
                    VixenSystem.Nodes.AddChildToParent(cn, destinationNode);
                }

                if (selectedTreeNode != null)
                {
                    selectedTreeNode.Expand();
                }

                PopulateNodeTree();
                OnElementsChanged();
            }
        }