/// <summary> /// Create a connection between an ExternalConstraintShape and a FactType. Roles /// used in the connection are stored with the currently active connect action. /// </summary> /// <param name="sourceShapeElement">The source of the requested connection</param> /// <param name="targetShapeElement">The target of the requested connection</param> /// <param name="paintFeedbackArgs">PaintFeedbackArgs</param> public override void CreateConnection(ShapeElement sourceShapeElement, ShapeElement targetShapeElement, PaintFeedbackArgs paintFeedbackArgs) { SubtypeConnectAction action = (sourceShapeElement.Diagram as ORMDiagram).SubtypeConnectAction; ObjectType sourceObjectType; ObjectType targetObjectType; if ((null != (sourceObjectType = action.mySourceObjectType)) && (null != (targetObjectType = ObjectTypeFromShape(targetShapeElement)))) { SubtypeFact.Create(sourceObjectType, targetObjectType); } }
/// <summary> /// Called as the pointer is moved over potential targets after a source is selected /// So should be pretty quick /// </summary> /// <remarks> /// The cursor can change dependant on CanCreateConnection when this returns true /// </remarks> /// <param name="sourceShapeElement">ShapeElement</param> /// <param name="targetShapeElement">ShapeElement</param> /// <returns></returns> public override bool IsValidSourceAndTarget(ShapeElement sourceShapeElement, ShapeElement targetShapeElement) { SubtypeConnectAction action = (sourceShapeElement.Diagram as ORMDiagram).SubtypeConnectAction; ObjectType sourceObjectType; ObjectType targetObjectType; if ((null != (sourceObjectType = action.mySourceObjectType)) && (null != (targetObjectType = ObjectTypeFromShape(targetShapeElement)))) { // UNDONE: Be smarter here, or display message later on return(sourceObjectType != targetObjectType && ((sourceObjectType.DataType == null) == (targetObjectType.DataType == null))); } return(false); }