/// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
        {
            Color      retVal = Color.Empty;
            SolidBrush solidBrush;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintLink, IConstraint>[] providers;
            IConstraint constraint;
            Store       store;

            if (brushId == DiagramBrushes.ConnectionLineDecorator &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (constraint = AssociatedConstraint) &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintLink, IConstraint> >()))
            {
                ORMDiagramDynamicColor requestColor = constraint.Modality == ConstraintModality.Deontic ? ORMDiagramDynamicColor.DeonticConstraint : ORMDiagramDynamicColor.Constraint;
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(requestColor, this, constraint);
                    if (alternateColor != Color.Empty)
                    {
                        retVal           = solidBrush.Color;
                        solidBrush.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
示例#2
0
        /// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
        {
            Color retVal = Color.Empty;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintShape, IConstraint>[] providers;
            IConstraint element;
            Store       store;

            if (penId == DiagramPens.ShapeOutline &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintShape, IConstraint> >(true)) &&
                null != (element = (IConstraint)ModelElement))
            {
                ORMDiagramDynamicColor requestColor = element.Modality == ConstraintModality.Deontic ? ORMDiagramDynamicColor.DeonticConstraint : ORMDiagramDynamicColor.Constraint;
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(requestColor, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal    = pen.Color;
                        pen.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
        /// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
        {
            Color retVal = Color.Empty;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintLink, IConstraint>[] providers;
            IConstraint constraint;
            Store       store;

            if ((penId ==
#if VISUALSTUDIO_10_0
                 CustomConnectionLinePen ||
#else
                 DiagramPens.ConnectionLine ||
#endif
                 penId == DiagramPens.ConnectionLineDecorator) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (constraint = AssociatedConstraint) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintLink, IConstraint> >()))
            {
                ORMDiagramDynamicColor requestColor = constraint.Modality == ConstraintModality.Deontic ? ORMDiagramDynamicColor.DeonticConstraint : ORMDiagramDynamicColor.Constraint;
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(requestColor, this, constraint);
                    if (alternateColor != Color.Empty)
                    {
                        retVal    = pen.Color;
                        pen.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
        /// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
        {
            Color      retVal = Color.Empty;
            SolidBrush solidBrush;
            ModelNote  element;
            Store      store;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ModelNoteShape, ModelNote>[] providers;
            bool isBackgroundBrush;

            if (((isBackgroundBrush = brushId == DiagramBrushes.DiagramBackground || brushId == ORMDiagram.TransparentBrushResource) ||
                 brushId == DiagramBrushes.ShapeText) &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ModelNoteShape, ModelNote> >()) &&
                null != (element = (ModelNote)ModelElement))
            {
                ORMDiagramDynamicColor requestColor = ORMDiagramDynamicColor.Background;
                if (isBackgroundBrush)
                {
                    requestColor = ORMDiagramDynamicColor.Background;
                }
                else
                {
                    // Note background defaults to transparent. Use the FloatingText if no background is set,
                    // otherwise use the ForegroundText.
                    requestColor = ORMDiagramDynamicColor.FloatingText;
                    for (int i = 0; i < providers.Length; ++i)
                    {
                        Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Background, this, element);
                        if (alternateColor != Color.Empty && alternateColor != Color.Transparent)
                        {
                            requestColor = ORMDiagramDynamicColor.ForegroundText;
                            break;
                        }
                    }
                }
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(requestColor, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal           = solidBrush.Color;
                        solidBrush.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
示例#5
0
        /// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
        {
            Color      retVal = Color.Empty;
            SolidBrush solidBrush;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintShape, IConstraint>[] providers;
            IConstraint element;
            Store       store;

            // We could check for a background brush request here with
            // DiagramBrushes.DiagramBackground. However, given the small
            // amount of background showing in most constraints and the
            // independent constraint color setting available, changing the
            // constraint background makes it difficult to have constraints
            // combined with FactTypes and ObjectTypes in the same dynamic
            // color provider.
            if ((brushId == ExternalConstraintBrush ||
                 brushId == DiagramBrushes.ShapeText) &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ExternalConstraintShape, IConstraint> >(true)) &&
                null != (element = (IConstraint)ModelElement))
            {
                ORMDiagramDynamicColor requestColor = element.Modality == ConstraintModality.Deontic ? ORMDiagramDynamicColor.DeonticConstraint : ORMDiagramDynamicColor.Constraint;
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(requestColor, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal           = solidBrush.Color;
                        solidBrush.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }