public static void RenderOutputConnection(Graphics graphics, NodeConnector output, float x, float y, RenderState state) { if (graphics == null || output == null) { return; } RectangleF outputBounds; if (output.Node.Collapsed) { outputBounds = output.Node.outputBounds; } else { outputBounds = output.bounds; } var x1 = (outputBounds.Left + outputBounds.Right) / 2.0f; var y1 = (outputBounds.Top + outputBounds.Bottom) / 2.0f; float centerX; float centerY; using (var path = GetArrowLinePath(x1, y1, x, y, out centerX, out centerY, true, 0.0f)) { using (var brush = new SolidBrush(GetArrowLineColor(state))) { graphics.FillPath(brush, path); } } }
public static void RenderInputConnection(Graphics graphics, NodeConnector input, float x, float y, RenderState state) { if (graphics == null || input == null) { return; } RectangleF inputBounds; if (input.Node.Collapsed) { inputBounds = input.Node.inputBounds; } else { inputBounds = input.bounds; } var x2 = (inputBounds.Left + inputBounds.Right) / 2.0f; var y2 = (inputBounds.Top + inputBounds.Bottom) / 2.0f; float centerX; float centerY; using (var path = GetArrowLinePath(x, y, x2, y2, out centerX, out centerY, true, 0.0f)) { using (var brush = new SolidBrush(GetArrowLineColor(state))) { graphics.FillPath(brush, path); } } }
public bool CanConnect(NodeConnector from, NodeConnector to) { if (from.Node is MyNodeView && to.Node is MyNodeView) { return to.Node != from.Node && !to.HasConnection; } else return false; }
public bool CanConnect(NodeConnector from, NodeConnector to) { if (from.Item.OutputTypes == null || to.Item.InputTypes == null) return false; foreach (var outputType in from.Item.OutputTypes) { foreach (var inputType in to.Item.InputTypes) { if (outputType == inputType) return true; } } return false; }
public bool CanConnect(NodeConnector from, NodeConnector to) { if (from is NodeInputConnector) { NodeConnector temp = to; to = from; from = temp; } var fromNode = from.Node as MyNodeView; var toNode = to.Node as MyNodeView; if (fromNode != null && toNode != null) { return fromNode != toNode && !to.HasConnection && toNode.Node.AcceptsConnection(fromNode.Node, (int) from.Item.Tag, (int) to.Item.Tag); } else return false; }
public void HandleConnectionRemoved(NodeConnector fromNodeConnector, NodeConnector toNodeConnector, bool input) { var node = input ? toNodeConnector.Node : fromNodeConnector.Node; var nodeItem1 = (NodeColorItem)node.Items.FirstOrDefault(item => item.Tag.Equals(1)); var nodeItem2 = (NodeColorItem)node.Items.FirstOrDefault(item => item.Tag.Equals(2)); if (input) { EventHandler<NodeItemEventArgs> handler; if (toNodeConnector.Item == nodeItem1) { handler = color1Handler; color1Handler = null; nodeItem1.Color = Color.Black; } else { handler = color2Handler; color2Handler = null; nodeItem2.Color = Color.Black; } fromNodeConnector.Node.OutputChanged -= handler; } }
public bool CanConnect(NodeConnector from, NodeConnector to) { if (from.Item.ItemType == to.Item.ItemType) return false; if (from.Item.GetType() == to.Item.GetType()) return true; return false; }
public void HandleConnectionRemoved(NodeConnector fromNodeConnector, NodeConnector toNodeConnector, bool input) { var node = input ? toNodeConnector.Node : fromNodeConnector.Node; var nodeItem1 = (NodeLabelItem)node.Items.FirstOrDefault(item => item.Tag.Equals(1)); var nodeItem2 = (NodeLabelItem)node.Items.FirstOrDefault(item => item.Tag.Equals(2)); if (input) { EventHandler<NodeItemEventArgs> handler; if (toNodeConnector.Item == nodeItem1) { handler = colorHandlerDict[node]; colorHandlerDict.Remove(node); } else { handler = imageHandlerDict[node]; imageHandlerDict.Remove(node); } fromNodeConnector.Node.OutputChanged -= handler; } }
public void HandleConnectionRemoved(NodeConnector fromNodeConnector, NodeConnector toNodeConnector, bool input) { }
public NodeConnection Connect(NodeConnector from, NodeConnector to) { if (from == null || to == null || from.Node == null || to.Node == null || !from.Enabled || !to.Enabled) return null; foreach (var other in from.Node.connections) { if (other.From == from && other.To == to) return null; } foreach (var other in to.Node.connections) { if (other.From == from && other.To == to) return null; } var connection = new NodeConnection(); connection.From = from; connection.To = to; from.Node.connections.Add(connection); to.Node.connections.Add(connection); if (ConnectionAdded != null) { var eventArgs = new AcceptNodeConnectionEventArgs(connection); ConnectionAdded(this, eventArgs); if (eventArgs.Cancel) { Disconnect(connection); return null; } } return connection; }
public void HandleConnectionRemoved(Graph.NodeConnector fromNodeConnector, Graph.NodeConnector toNodeConnector, bool input) { }
/// <summary> /// Checks whether the connection between two connectors is allowed. /// This is achieved through event propagation. /// </summary> /// <returns></returns> private bool ConnectionIsAllowed(NodeConnector from, NodeConnector to) { if (HighlightCompatible && null != CompatibilityStrategy) { if (!CompatibilityStrategy.CanConnect(from, to)) return false; } // If someone has subscribed to the ConnectionAdding event, // give them a chance to interrupt this connection attempt. if (null != ConnectionAdding) { // Populate a temporary NodeConnection instance. var connection = new NodeConnection(); connection.From = from; connection.To = to; // Fire the event and see if someone cancels it. var eventArgs = new AcceptNodeConnectionEventArgs(connection); ConnectionAdding(this, eventArgs); if (eventArgs.Cancel) return false; } return true; }
public NodeConnectionEventArgs(NodeConnector from, NodeConnector to, NodeConnection connection) { Connection = connection; From = from; To = to; FromItem = from.Item.Name; ToItem = to.Item.Name; }
public static void RenderOutputConnection(Graphics graphics, NodeConnector output, float x, float y, RenderState state) { if (graphics == null || output == null) return; RectangleF outputBounds; if (output.Node.Collapsed) outputBounds = output.Node.outputBounds; else outputBounds = output.bounds; var x1 = (outputBounds.Left + outputBounds.Right) / 2.0f; var y1 = (outputBounds.Top + outputBounds.Bottom) / 2.0f; float centerX; float centerY; using (var path = GetArrowLinePath(x1, y1, x, y, out centerX, out centerY, true, 0.0f)) { using (var brush = new SolidBrush(GetArrowLineColor(state))) { graphics.FillPath(brush, path); } } }
public NodeConnectionEventArgs(NodeConnector from, NodeConnector to, NodeConnection connection) { Connection = connection; From = from; To = to; }
public void RenderConnector(Graphics graphics, NodeConnector nodeConnector, RenderState renderState) { if (nodeConnector.ConnectorType == NodeConnectorType.Exec) RenderExecConnector(graphics, nodeConnector, renderState); //else if (nodeConnector.ConnectorType == NodeConnectorType.Array) // RenderArrayConnector(graphics, nodeConnector, renderState); else if (nodeConnector.ConnectorType == NodeConnectorType.Value) RenderValueConnector(graphics, nodeConnector, renderState); }
private void RenderValueConnector(Graphics graphics, NodeConnector nodeConnector, RenderState renderState) { RectangleF bounds = nodeConnector.bounds; var state = renderState; using (var brush = new SolidBrush(GetArrowLineColor(state))) { graphics.FillEllipse(brush, bounds); } if (state == RenderState.None) { graphics.DrawEllipse(Pens.Black, bounds); } else // When we're compatible, but not dragging from this node we render a highlight if ((state & (RenderState.Compatible | RenderState.Dragging)) == RenderState.Compatible) { // First draw the normal black border graphics.DrawEllipse(Pens.Black, bounds); // Draw an additional highlight around the connector RectangleF highlightBounds = new RectangleF(bounds.X, bounds.Y, bounds.Width, bounds.Height); highlightBounds.Width += 10; highlightBounds.Height += 10; highlightBounds.X -= 5; highlightBounds.Y -= 5; graphics.DrawEllipse(Pens.OrangeRed, highlightBounds); } else { graphics.DrawArc(Pens.Black, bounds, 90, 180); using (var pen = new Pen(GetArrowLineColor(state))) { graphics.DrawArc(pen, bounds, 270, 180); } } }
public void RenderOutputConnection(Graphics graphics, NodeConnector output, float x, float y, RenderState state) { if (graphics == null || output == null) return; RectangleF outputBounds = output.bounds; var x1 = (outputBounds.Left + outputBounds.Right) / 2.0f; var y1 = (outputBounds.Top + outputBounds.Bottom) / 2.0f; using (var path = GraphUtils.GetArrowLinePath(x1, y1, x, y, true, 0.0f)) { using (var pen = new Pen(GetArrowLineColor(state), 4)) { graphics.DrawPath(pen, path); } } }
public void RenderInputConnection(Graphics graphics, NodeConnector input, float x, float y, RenderState state) { if (graphics == null || input == null) return; RectangleF inputBounds = input.bounds; var x2 = (inputBounds.Left + inputBounds.Right) / 2.0f; var y2 = (inputBounds.Top + inputBounds.Bottom) / 2.0f; using (var path = GraphUtils.GetArrowLinePath(x, y, x2, y2, true)) using (var pen = new Pen(GetArrowLineColor(state), 4)) { graphics.DrawPath(pen, path); } }
public static void RenderInputConnection(Graphics graphics, NodeConnector input, float x, float y, RenderState state) { if (graphics == null || input == null) return; RectangleF inputBounds; if (input.Node.Collapsed) inputBounds = input.Node.inputBounds; else inputBounds = input.bounds; var x2 = (inputBounds.Left + inputBounds.Right) / 2.0f; var y2 = (inputBounds.Top + inputBounds.Bottom) / 2.0f; float centerX; float centerY; using (var path = GetArrowLinePath(x, y, x2, y2, out centerX, out centerY, true, 0.0f)) { using (var brush = new SolidBrush(GetArrowLineColor(state))) { graphics.FillPath(brush, path); } } }
private void InitIoBranches(int branchCount, NodeConnector connector, ICollection<NodeItem> branchList, IList<PropertyInfo> blocks, bool isInput) { if (branchCount == 1) { connector.Enabled = true; branchList.Add(m_iconItem); } else { for (int i = 0; i < branchCount; i++) { string name = (i + 1) + ""; if (Node is MyWorkingNode) { name = blocks[i].Name; } NodeLabelItem branch = new NodeLabelItem(MyProject.ShortenMemoryBlockName(name), isInput, !isInput) { Tag = i, IsPassive = true }; branchList.Add(branch); AddItem(branch); } } }
public bool CanConnect(NodeConnector @from, NodeConnector to) { if (@from.ConnectorType != to.ConnectorType) return false; return true; }