public void ScriptManager_MoveCommandAfter_ToOtherScript_MovesFullNode() { var s1 = NewTestScript(out Command c1, out Command c11); var s2 = NewTestScript(out Command c2, out Command c21); ScriptManager.MoveCommandAfter(c1, c2, 1, 2); Assert.AreEqual(0, s1.Commands.Count()); Assert.AreEqual(2, s2.Commands.Count()); Assert.AreEqual(c1, s2.Commands.GetChild(1).value); Assert.AreEqual(c11, s2.Commands.GetChild(1).GetChild(0).value); }
private void treeListView_ModelDropped(object sender, ModelDropEventArgs e) { var targetNode = e.TargetModel as HierarchyNode; var sourceNode = e.SourceModels[0] as HierarchyNode; if (targetNode.Script != null && sourceNode.Script != null) { if (e.DropTargetLocation == DropTargetLocation.AboveItem) { ScriptManager.MoveScriptBefore(sourceNode.Script.GetIndex(ScriptManager), targetNode.Script.GetIndex(ScriptManager)); } if (e.DropTargetLocation == DropTargetLocation.BelowItem) { ScriptManager.MoveScriptAfter(sourceNode.Script.GetIndex(ScriptManager), targetNode.Script.GetIndex(ScriptManager)); } } if (targetNode.Command != null && sourceNode.Command != null) { var targetScript = ScriptManager.GetScriptFromCommand(targetNode.Command); var sourceScript = ScriptManager.GetScriptFromCommand(sourceNode.Command); if (e.DropTargetLocation == DropTargetLocation.AboveItem) { ScriptManager.MoveCommandBefore(sourceNode.Command, targetNode.Command, sourceScript.GetIndex(ScriptManager), targetScript.GetIndex(ScriptManager)); } if (e.DropTargetLocation == DropTargetLocation.BelowItem) { ScriptManager.MoveCommandAfter(sourceNode.Command, targetNode.Command, sourceScript.GetIndex(ScriptManager), targetScript.GetIndex(ScriptManager)); } if (e.DropTargetLocation == DropTargetLocation.Item && targetNode.Command.CanBeNested) { var node = sourceScript.Commands.GetNodeFromValue(sourceNode.Command); sourceScript.RemoveCommand(sourceNode.Command); targetScript.AddCommandNode(node, targetNode.Command); } } if (targetNode.Script != null && sourceNode.Command != null) { var sourceScript = ScriptManager.GetScriptFromCommand(sourceNode.Command); var node = sourceScript.Commands.GetNodeFromValue(sourceNode.Command); sourceScript.RemoveCommand(sourceNode.Command); targetNode.Script.AddCommandNode(node); } }