Exemple #1
0
            /// <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)
            {
                ModelNoteConnectAction action = (sourceShapeElement.Diagram as ORMDiagram).ModelNoteConnectAction;
                ORMModelElement        sourceElement;
                ORMModelElement        targetElement;

                if (null != (sourceElement = action.mySourceElement) &&
                    null != (targetElement = ElementFromShape <ORMModelElement>(targetShapeElement)))
                {
                    ModelNote note = null;
                    if (null == (note = sourceElement as ModelNote))
                    {
                        if (null != (note = targetElement as ModelNote))
                        {
                            // Switch the source and target
                            targetElement = sourceElement;
                        }
                    }
                    if (note != null)
                    {
                        FactType                factType;
                        ObjectType              objectType;
                        SetConstraint           setConstraint;
                        SetComparisonConstraint setComparisonConstraint;
                        if (null != (factType = targetElement as FactType))
                        {
                            return(!note.FactTypeCollection.Contains(factType));
                        }
                        else if (null != (objectType = targetElement as ObjectType))
                        {
                            return(!note.ObjectTypeCollection.Contains(objectType));
                        }
                        else if (null != (setConstraint = targetElement as SetConstraint))
                        {
                            return(!setConstraint.Constraint.ConstraintIsInternal && !note.SetConstraintCollection.Contains(setConstraint));
                        }
                        else if (null != (setComparisonConstraint = targetElement as SetComparisonConstraint))
                        {
                            return(!note.SetComparisonConstraintCollection.Contains(setComparisonConstraint));
                        }
                    }
                }
                return(false);
            }
Exemple #2
0
            /// <summary>
            /// Create a connection between an ModelNoteShape and a FactType or ObjectType.
            /// </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)
            {
                ModelNoteConnectAction action = (sourceShapeElement.Diagram as ORMDiagram).ModelNoteConnectAction;
                ORMModelElement        sourceElement;
                ORMModelElement        targetElement;

                if (null != (sourceElement = action.mySourceElement) &&
                    null != (targetElement = ElementFromShape <ORMModelElement>(targetShapeElement)))
                {
                    ModelNote note = null;
                    if (null == (note = sourceElement as ModelNote))
                    {
                        if (null != (note = targetElement as ModelNote))
                        {
                            // Switch the source and target
                            targetElement = sourceElement;
                        }
                    }
                    if (note != null)
                    {
                        FactType                factType;
                        ObjectType              objectType;
                        SetConstraint           setConstraint;
                        SetComparisonConstraint setComparisonConstraint;
                        if (null != (factType = targetElement as FactType))
                        {
                            new ModelNoteReferencesFactType(note, factType);
                        }
                        else if (null != (objectType = targetElement as ObjectType))
                        {
                            new ModelNoteReferencesObjectType(note, objectType);
                        }
                        else if (null != (setConstraint = targetElement as SetConstraint))
                        {
                            new ModelNoteReferencesSetConstraint(note, setConstraint);
                        }
                        else if (null != (setComparisonConstraint = targetElement as SetComparisonConstraint))
                        {
                            new ModelNoteReferencesSetComparisonConstraint(note, setComparisonConstraint);
                        }
                    }
                }
            }