Ejemplo n.º 1
0
        public void duplicateToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var selectedNode = treeListView.SelectedObject as HierarchyNode;

            if (selectedNode == null)
            {
                return;
            }

            if (selectedNode.Script != null)
            {
                ScriptManager.NewScript(selectedNode.Script);
                ScriptManager.MoveScriptAfter(ScriptManager.LoadedScripts.Count - 1, selectedNode.Script.GetIndex(ScriptManager));
            }
            else if (selectedNode.Command != null)
            {
                var script = selectedNode.TopLevelNode.Script;
                var node   = script.Commands.GetNodeFromValue(selectedNode.Command);
                var clone  = (TreeNode <Command>)node.Clone();
                clone.CastAndRemoveNullsTree <IHaveGuid>().RegenerateGuids();

                script.AddCommandNode(clone, node.parent.value);
                script.MoveCommandAfter(clone.value, selectedNode.Command);
            }

            RefreshTreeListViewAsync();
            treeListView.Focus();

            ASSERT_TreeViewIsTheSameAsInScriptManager();
        }