コード例 #1
0
 /// <summary>
 /// ChangeRule: typeof(RingConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority;
 /// </summary>
 private static void RingConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e)
 {
     if (e.DomainProperty.Id == RingConstraint.RingTypeDomainPropertyId)
     {
         RingConstraint ringConstraint = (RingConstraint)e.ModelElement;
         if (!ringConstraint.IsDeleted)
         {
             foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(ringConstraint))
             {
                 RingConstraintShape ringConstraintShape = pel as RingConstraintShape;
                 if (ringConstraintShape != null)
                 {
                     foreach (LinkConnectsToNode connection in DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(ringConstraintShape, LinkConnectsToNode.NodesDomainRoleId))
                     {
                         BinaryLinkShape binaryLink = connection.Link as BinaryLinkShape;
                         if (binaryLink != null)
                         {
                             binaryLink.RecalculateRoute();
                         }
                     }
                     SizeD oldSize = ringConstraintShape.Size;
                     ringConstraintShape.AutoResize();
                     if (oldSize == ringConstraintShape.Size)
                     {
                         ringConstraintShape.InvalidateRequired(true);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// Implements IModelErrorActivation.ActivateModelError
        /// </summary>
        protected new bool ActivateModelError(ModelError error)
        {
            RingConstraintTypeNotSpecifiedError ringTypeError;
            bool retVal = true;

            if (null != (ringTypeError = error as RingConstraintTypeNotSpecifiedError))
            {
                Store          store      = Store;
                RingConstraint constraint = ringTypeError.RingConstraint;
                EditorUtility.ActivatePropertyEditor(
                    (store as IORMToolServices).ServiceProvider,
                    DomainTypeDescriptor.CreatePropertyDescriptor(constraint, RingConstraint.RingTypeDomainPropertyId),
                    true);
            }
            else
            {
                retVal = base.ActivateModelError(error);
            }
            return(retVal);
        }
コード例 #3
0
        /// <summary>
        /// Draw all ring constraint types
        /// </summary>
        protected override void OnPaintShape(DiagramPaintEventArgs e, ref PaintHelper helper)
        {
            base.OnPaintShape(e, ref helper);
            RingConstraint     ringConstraint = this.AssociatedRingConstraint;
            RectangleF         boundsF        = RectangleD.ToRectangleF(this.AbsoluteBounds);
            Graphics           g        = e.Graphics;
            RingConstraintType ringType = ringConstraint.RingType;
            RectangleF         innerBounds;
            Pen   pen   = helper.Pen;
            Brush brush = helper.Brush;

            switch (ringType)
            {
            case RingConstraintType.Undefined:
                break;

            case RingConstraintType.Reflexive:
                DrawLeftDot(g, boundsF, brush);
                break;

            case RingConstraintType.PurelyReflexive:
                DrawLeftDot(g, boundsF, brush);
                {
                    float     height            = boundsF.Height;
                    float     left              = boundsF.Left + boundsF.Width / 2;
                    DashStyle originalDashStyle = pen.DashStyle;
                    pen.DashStyle = DashStyle.Solid;
                    g.DrawLine(pen, left, boundsF.Top + height * (.5f - SMALL_LENGTH_FACTOR / 2), left, boundsF.Top + height * (.5f + SMALL_LENGTH_FACTOR / 2));
                    pen.DashStyle = originalDashStyle;
                }
                break;

            case RingConstraintType.Irreflexive:
                DrawLeftDot(g, boundsF, brush);
                DrawRightLine(g, boundsF, pen, 1f);
                break;

            case RingConstraintType.Asymmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, true);
                DrawBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.Antisymmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, false);
                DrawBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.Transitive:
                DrawTriangleDots(g, boundsF, brush, false);
                break;

            case RingConstraintType.Intransitive:
            case RingConstraintType.StronglyIntransitive:
                DrawTriangleDots(g, boundsF, brush, ringType == RingConstraintType.StronglyIntransitive);
                DrawTriangleBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.Acyclic:
                DrawTriangleDots(g, boundsF, brush, false);
                DrawBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.AcyclicTransitive:
                DrawTriangle(g, boundsF, pen);
                DrawTriangleDots(g, boundsF, brush, false);
                DrawBottomLine(g, boundsF, pen, .6f);
                break;

            case RingConstraintType.AcyclicIntransitive:
            case RingConstraintType.AcyclicStronglyIntransitive:
                DrawTriangle(g, boundsF, pen);
                DrawTriangleBottomLine(g, boundsF, pen);
                DrawTriangleDots(g, boundsF, brush, ringType == RingConstraintType.AcyclicStronglyIntransitive);
                DrawBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.TransitiveAsymmetric:
            case RingConstraintType.TransitiveAntisymmetric:
            case RingConstraintType.AsymmetricIntransitive:
            case RingConstraintType.AsymmetricStronglyIntransitive:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, ringType != RingConstraintType.TransitiveAntisymmetric);
                DrawBottomLine(g, boundsF, pen);
                innerBounds = GetInnerBounds(boundsF);
                DrawTriangle(g, innerBounds, pen);
                DrawTriangleDots(g, innerBounds, brush, ringType == RingConstraintType.AsymmetricStronglyIntransitive);
                switch (ringType)
                {
                case RingConstraintType.AsymmetricIntransitive:
                case RingConstraintType.AsymmetricStronglyIntransitive:
                    DrawTriangleBottomLine(g, innerBounds, pen);
                    break;
                }
                break;

            case RingConstraintType.ReflexiveTransitive:
            case RingConstraintType.TransitiveIrreflexive:
                DrawLeftDot(g, boundsF, brush);
                if (ringType == RingConstraintType.TransitiveIrreflexive)
                {
                    DrawRightLine(g, boundsF, pen, .75f);
                }
                innerBounds = GetInnerBounds(boundsF);
                DrawTriangle(g, innerBounds, pen);
                DrawTriangleDots(g, innerBounds, brush, false);
                break;

            case RingConstraintType.Symmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, true);
                break;

            case RingConstraintType.SymmetricTransitive:
            case RingConstraintType.SymmetricIntransitive:
            case RingConstraintType.SymmetricStronglyIntransitive:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, true);
                innerBounds = GetInnerBounds(boundsF);
                DrawTriangle(g, innerBounds, pen);
                DrawTriangleDots(g, innerBounds, brush, ringType == RingConstraintType.SymmetricStronglyIntransitive);
                if (ringType != RingConstraintType.SymmetricTransitive)
                {
                    DrawTriangleBottomLine(g, innerBounds, pen);
                }
                break;

            case RingConstraintType.SymmetricIrreflexive:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, true);
                innerBounds = GetReflexiveInSymmetricBounds(boundsF);
                DrawEllipse(g, innerBounds, pen);
                DrawRightLine(g, innerBounds, pen, 1f);
                break;

            case RingConstraintType.ReflexiveSymmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, true);
                DrawEllipse(g, GetReflexiveInSymmetricBounds(boundsF), pen);
                break;

            case RingConstraintType.ReflexiveAntisymmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, false);
                DrawEllipse(g, GetReflexiveInSymmetricBounds(boundsF), pen);
                DrawBottomLine(g, boundsF, pen);
                break;

            case RingConstraintType.ReflexiveTransitiveAntisymmetric:
                DrawLeftDot(g, boundsF, brush);
                DrawRightDot(g, boundsF, pen, brush, false);
                DrawBottomLine(g, boundsF, pen);
                innerBounds = GetInnerBounds(boundsF);
                DrawTriangle(g, innerBounds, pen);
                DrawTriangleDots(g, innerBounds, brush, false);
                g.DrawArc(pen, GetReflexiveInSymmetricBounds(boundsF), 27, 300);                         // Angles determined empirically to stop on triangle, not worth calculating
                break;
            }
        }