public void L02TestLiteral_Connectivity() { //Create two literal nodes & Connect them string commands = @" ClearSelection CreateCodeBlockNode|d:335.0|d:169.0|s:100 CreateIdentifierNode|d:534.0|d:184.0 MouseDown|e:System.Windows.Input.MouseButton,Left|u:0x10000001|e:DesignScriptStudio.Graph.Core.NodePart,OutputSlot|i:0|e:System.Windows.Input.ModifierKeys,None MouseUp|e:System.Windows.Input.MouseButton,Left|u:0x10000002|e:DesignScriptStudio.Graph.Core.NodePart,InputSlot|i:0|e:System.Windows.Input.ModifierKeys,None"; GraphController controller = new GraphController(null, null); bool result = controller.RunCommands(commands); Assert.AreEqual(true, result); Assert.AreEqual(2, controller.GetVisualNodes().Count);//output slot IVisualNode node = controller.GetVisualNode(0x10000001); IVisualNode node2 = controller.GetVisualNode(0x10000002); Assert.NotNull(new object[] { node, node2 }); // check if node create Assert.AreEqual(NodeType.Literal, node.VisualType); // check if literal node Assert.AreEqual(null, node.GetInputSlots()); //output slot Assert.AreEqual(3, controller.GetSlots().Count); //output slot // get slots uint outputSlotId = node.GetOutputSlot(0); ISlot outputSlot = controller.GetSlot(outputSlotId); uint connectingSlotId = node2.GetInputSlot(0); ISlot connectingSlot = controller.GetSlot(connectingSlotId); uint[] connecting = connectingSlot.ConnectingSlots; Assert.AreEqual(connectingSlotId, outputSlot.ConnectingSlots[0]); }
public void L01TestLiteral() { // Create two literal nodes string commands = @" ClearSelection CreateCodeBlockNode|d:315.0|d:179.0|s:100 ClearSelection CreateCodeBlockNode|d:329.0|d:280.0|s:100"; GraphController controller = new GraphController(null, null); bool result = controller.RunCommands(commands); Assert.AreEqual(true, result); Assert.AreEqual(2, controller.GetVisualNodes().Count);//output slot //check each Node IVisualNode node = controller.GetVisualNode(0x10000001); IVisualNode node2 = controller.GetVisualNode(0x10000002); Assert.NotNull(new object [] { node, node2 }); // check if node create Assert.AreEqual(NodeType.Literal, node.VisualType); // check if literal node Assert.AreEqual(NodeType.Literal, node2.VisualType); // check if literal node Assert.AreEqual(2, controller.GetSlots().Count); //output slot Assert.AreEqual(null, node.GetInputSlots()); //output slot Assert.AreEqual(null, node2.GetInputSlots()); //output slot }
internal void SelectEdges(IVisualNode activatedNode) { uint[] inputs = activatedNode.GetInputSlots(); uint[] outputs = activatedNode.GetOutputSlots(); if (null != inputs) selectedSlots.AddRange(inputs); if (null != outputs) selectedSlots.AddRange(outputs); foreach (uint slotId in selectedSlots) { foreach (VisualEdge visualEdge in edgeCollection.Values) { if (visualEdge.Selected) continue; if ((visualEdge.StartSlotId == slotId) || (visualEdge.EndSlotId == slotId)) { visualEdge.Selected = true; visualEdge.Compose(); } } } }
internal void DeleteEdgesConnectTo(IVisualNode visualNode) { uint[] inputs = visualNode.GetInputSlots(); uint[] outputs = visualNode.GetOutputSlots(); List<VisualEdge> edgesToRemove = new List<VisualEdge>(); if (inputs != null) { foreach (uint slotId in inputs) { foreach (VisualEdge visualEdge in edgeCollection.Values) { if (visualEdge.EndSlotId == slotId || visualEdge.StartSlotId == slotId) edgesToRemove.Add(visualEdge); } } } if (outputs != null) { foreach (uint slotId in outputs) { foreach (VisualEdge visualEdge in edgeCollection.Values) { if (visualEdge.EndSlotId == slotId || visualEdge.StartSlotId == slotId) edgesToRemove.Add(visualEdge); } } } foreach (VisualEdge edgeToDelete in edgesToRemove) DeleteEdge(edgeToDelete); }