void EndAndStartCtrlConnection(Guid nodeId, int portIndex, PortType portType) { if (portType == PortType.Output) { return; // Only handle ctrl connections if selected port is an input port } if (firstStartPort == null || activeStartPorts == null || activeStartPorts.Count() <= 0) { return; } var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel; if (node == null) { return; } PortModel portModel = node.InPorts[portIndex]; var models = GetConnectorsToAddAndDelete(portModel, activeStartPorts[0]); WorkspaceModel.RecordModelsForUndo(models, CurrentWorkspace.UndoRecorder); activeStartPorts = new PortModel[] { firstStartPort }; }
void EndShiftReconnections(Guid nodeId, int portIndex, PortType portType) { if (portType == PortType.Input) { return; //only handle multiple connections when the port selected is an output port } if (activeStartPorts == null || activeStartPorts.Count() <= 0) { return; } var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel; if (node == null) { return; } PortModel selectedPort = node.OutPorts[portIndex]; var firstModel = GetConnectorsToAddAndDelete(selectedPort, activeStartPorts[0]); for (int i = 1; i < activeStartPorts.Count(); i++) { var models = GetConnectorsToAddAndDelete(selectedPort, activeStartPorts[i]); foreach (var m in models) { firstModel.Add(m.Key, m.Value); } } WorkspaceModel.RecordModelsForUndo(firstModel, CurrentWorkspace.UndoRecorder); activeStartPorts = null; return; }
void EndConnection(Guid nodeId, int portIndex, PortType portType) { // Check if the node from which the connector starts is valid and has not been deleted if (activeStartPorts == null || activeStartPorts.Count() <= 0 || activeStartPorts[0].Owner == null) { return; } var startNode = CurrentWorkspace.GetModelInternal(activeStartPorts[0].Owner.GUID); if (startNode == null) { return; } var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel; if (node == null) { return; } bool isInPort = portType == PortType.Input; PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex]; var models = GetConnectorsToAddAndDelete(portModel, activeStartPorts[0]); WorkspaceModel.RecordModelsForUndo(models, CurrentWorkspace.UndoRecorder); activeStartPorts = null; firstStartPort = null; }
void EndConnection(Guid nodeId, int portIndex, PortType portType) { bool isInPort = portType == PortType.Input; var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel; if (node == null) { return; } PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex]; ConnectorModel connectorToRemove = null; // Remove connector if one already exists if (portModel.Connectors.Count > 0 && portModel.PortType == PortType.Input) { connectorToRemove = portModel.Connectors[0]; connectorToRemove.Delete(); } // We could either connect from an input port to an output port, or // another way around (in which case we swap first and second ports). PortModel firstPort, second; if (portModel.PortType != PortType.Input) { firstPort = portModel; second = activeStartPort; } else { // Create the new connector model firstPort = activeStartPort; second = portModel; } ConnectorModel newConnectorModel = ConnectorModel.Make( firstPort.Owner, second.Owner, firstPort.Index, second.Index); // Record the creation of connector in the undo recorder. var models = new Dictionary <ModelBase, UndoRedoRecorder.UserAction>(); if (connectorToRemove != null) { models.Add(connectorToRemove, UndoRedoRecorder.UserAction.Deletion); } models.Add(newConnectorModel, UndoRedoRecorder.UserAction.Creation); WorkspaceModel.RecordModelsForUndo(models, CurrentWorkspace.UndoRecorder); activeStartPort = null; }
void EndConnection(Guid nodeId, int portIndex, PortType portType) { bool isInPort = portType == PortType.Input; var node = CurrentWorkspace.GetModelInternal(nodeId) as NodeModel; if (node == null) { return; } PortModel portModel = isInPort ? node.InPorts[portIndex] : node.OutPorts[portIndex]; var models = GetConnectorsToAddAndDelete(portModel, activeStartPort); WorkspaceModel.RecordModelsForUndo(models, CurrentWorkspace.UndoRecorder); activeStartPort = null; }