internal bool HandlePortClicked(PortViewModel portViewModel) { // We only entertain port clicking when the current state is idle, // or when it is already having a connector being established. if (currentState != State.None && (currentState != State.Connection)) { return(false); } var portModel = portViewModel.PortModel; var workspaceViewModel = owningWorkspace.DynamoViewModel.CurrentSpaceViewModel; if (this.currentState != State.Connection) // Not in a connection attempt... { PortType portType = PortType.INPUT; Guid nodeId = portModel.Owner.GUID; int portIndex = portModel.Owner.GetPortIndexAndType(portModel, out portType); var mode = DynamoModel.MakeConnectionCommand.Mode.Begin; var command = new DynamoModel.MakeConnectionCommand(nodeId, portIndex, portType, mode); owningWorkspace.DynamoViewModel.ExecuteCommand(command); if (null != owningWorkspace.activeConnector) { this.currentState = State.Connection; owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.ArcSelect); owningWorkspace.IsCursorForced = false; } } else // Attempt to complete the connection { // Check if connection is valid if (owningWorkspace.CheckActiveConnectorCompatibility(portViewModel)) { PortType portType = PortType.INPUT; Guid nodeId = portModel.Owner.GUID; int portIndex = portModel.Owner.GetPortIndexAndType(portModel, out portType); var mode = DynamoModel.MakeConnectionCommand.Mode.End; var command = new DynamoModel.MakeConnectionCommand(nodeId, portIndex, portType, mode); owningWorkspace.DynamoViewModel.ExecuteCommand(command); owningWorkspace.CurrentCursor = null; owningWorkspace.IsCursorForced = false; this.currentState = State.None; } } return(true); }
internal bool HandlePortClicked(PortViewModel portViewModel) { // We only entertain port clicking when the current state is idle, // or when it is already having a connector being established. if (currentState != State.None && (currentState != State.Connection)) { return(false); } var portModel = portViewModel.PortModel; var workspaceViewModel = owningWorkspace.DynamoViewModel.CurrentSpaceViewModel; if (this.currentState != State.Connection) // Not in a connection attempt... { Guid nodeId = portModel.Owner.GUID; int portIndex = portModel.Index; var mode = DynamoModel.MakeConnectionCommand.Mode.Begin; if (Keyboard.Modifiers == ModifierKeys.Shift) //if shift key is down, handle multiple wire reconnections { multipleConnections = true; mode = DynamoModel.MakeConnectionCommand.Mode.BeginShiftReconnections; } var command = new DynamoModel.MakeConnectionCommand(nodeId, portIndex, portModel.PortType, mode); owningWorkspace.DynamoViewModel.ExecuteCommand(command); if (null != owningWorkspace.FirstActiveConnector) { this.currentState = State.Connection; owningWorkspace.CurrentCursor = CursorLibrary.GetCursor(CursorSet.ArcSelect); owningWorkspace.IsCursorForced = false; } } else // Attempt to complete the connection { // Check if connection is valid if (owningWorkspace.CheckActiveConnectorCompatibility(portViewModel)) { Guid nodeId = portModel.Owner.GUID; int portIndex = portModel.Index; var mode = DynamoModel.MakeConnectionCommand.Mode.End; if (multipleConnections) { mode = DynamoModel.MakeConnectionCommand.Mode.EndShiftReconnections; } var command = new DynamoModel.MakeConnectionCommand(nodeId, portIndex, portModel.PortType, mode); owningWorkspace.DynamoViewModel.ExecuteCommand(command); multipleConnections = false; owningWorkspace.CurrentCursor = null; owningWorkspace.IsCursorForced = false; this.currentState = State.None; } } return(true); }