/// <summary> /// Called to query the application for feedback while the user is dragging the connection. /// </summary> public void QueryConnnectionFeedback(ConnectorViewModel draggedOutConnector, ConnectorViewModel draggedOverConnector, out object feedbackIndicator, out bool connectionOk) { if (draggedOutConnector == draggedOverConnector) { // // Can't connect to self! // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator(); connectionOk = false; } else { var sourceConnector = draggedOutConnector; var destConnector = draggedOverConnector; // // Only allow connections from output connector to input connector (ie each // connector must have a different type). // Also only allocation from one node to another, never one node back to the same node. // connectionOk = sourceConnector.ParentNode != destConnector.ParentNode && sourceConnector.Type != destConnector.Type && sourceConnector.DataType == destConnector.DataType; if (connectionOk) { // // Yay, this is a valid connection! // Provide feedback to indicate that this connection is ok! // feedbackIndicator = new ConnectionOkIndicator(); } else { // // Connectors with the same connector type (eg input & input, or output & output) // can't be connected. // Only connectors with separate connector type (eg input & output). // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator(); } } }
/// <summary> /// Called to query the application for feedback while the user is dragging the connection. /// </summary> public void QueryConnnectionFeedback(ConnectorViewModel draggedOutConnector, ConnectorViewModel draggedOverConnector, out object feedbackIndicator, out bool connectionOk) { if (draggedOutConnector == draggedOverConnector) { // // Can't connect to self! // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator("Can't connect to self"); connectionOk = false; } else { string message = string.Empty; var sourceConnector = draggedOutConnector; var destConnector = draggedOverConnector; // // Only allow connections from output connector to input connector (ie each // connector must have a different type). // Also only allocation from one node to another, never one node back to the same node. // connectionOk = IsValidConnection(sourceConnector, draggedOverConnector, ref message); if (connectionOk) { feedbackIndicator = new ConnectionOkIndicator(); } else { // // Connectors with the same connector type (eg input & input, or output & output) // can't be connected. // Only connectors with separate connector type (eg input & output). // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator(message); } } }
/// <summary> /// Called to query the application for feedback while the user is dragging the connection. /// </summary> public void QueryConnnectionFeedback(ConnectorViewModel draggedOutConnector, ConnectorViewModel draggedOverConnector, out object feedbackIndicator, out bool connectionOk) { if (draggedOutConnector == draggedOverConnector) { // // Can't connect to self! // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator(); connectionOk = false; } else { var sourceConnector = draggedOutConnector; var destConnector = draggedOverConnector; // // Only allow connections from output connector to input connector (ie each // connector must have a different type). // Also only allocation from one node to another, never one node back to the same node. // connectionOk = sourceConnector.ParentNode != destConnector.ParentNode && sourceConnector.Type != destConnector.Type && destConnector.AttachedConnections.Count == 0; if (connectionOk) { // // Yay, this is a valid connection! // Provide feedback to indicate that this connection is ok! // feedbackIndicator = new ConnectionOkIndicator(); } else { // // Connectors with the same connector type (eg input & input, or output & output) // can't be connected. // Only connectors with separate connector type (eg input & output). // Provide feedback to indicate that this connection is not valid! // feedbackIndicator = new ConnectionBadIndicator(); } } }