コード例 #1
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, SubtypeLink, SubtypeFact>[] providers;
            SubtypeFact element;
            Store       store;

            if (brushId == DiagramBrushes.ConnectionLineDecorator &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, SubtypeLink, SubtypeFact> >()) &&
                null != (element = (SubtypeFact)ModelElement))
            {
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Constraint, this, element);
                    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;
            RoleHasValueConstraint link;
            RoleValueConstraint    constraint;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, ValueRangeLink, RoleValueConstraint>[] providers;
            Store store;

            if (penId == DiagramPens.ConnectionLine &&
                null != (link = ModelElement as RoleHasValueConstraint) &&
                null != (constraint = link.ValueConstraint) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, ValueRangeLink, RoleValueConstraint> >()))
            {
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Constraint, this, constraint);
                    if (alternateColor != Color.Empty)
                    {
                        retVal    = pen.Color;
                        pen.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
コード例 #3
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, 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);
        }
コード例 #4
0
        /// <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);
        }
コード例 #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, CardinalityConstraintShape, CardinalityConstraint>[] providers;
            CardinalityConstraint element;
            bool  isAlethic;
            Store store;

            // See notes in corresponding method on ExternalConstraintShape
            // regarding not using the dynamic background color.
            if (((isAlethic = (brushId == CardinalityTextAlethicBrush)) || brushId == CardinalityTextDeonticBrush) &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, CardinalityConstraintShape, CardinalityConstraint> >(true)) &&
                null != (element = (CardinalityConstraint)ModelElement))
            {
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(isAlethic ? ORMDiagramDynamicColor.Constraint : ORMDiagramDynamicColor.DeonticConstraint, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal           = solidBrush.Color;
                        solidBrush.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
コード例 #6
0
        /// <summary>
        /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
        /// </summary>
        protected Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
        {
            Color retVal = Color.Empty;

            IDynamicShapeColorProvider <ORMDiagramDynamicColor, SubtypeLink, SubtypeFact>[] providers;
            SubtypeFact element;
            Store       store;

            if ((penId == DiagramPens.ConnectionLine ||
                 penId == NonPrimaryNormalResource ||
                 penId == DiagramPens.ConnectionLineDecorator) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, SubtypeLink, SubtypeFact> >()) &&
                null != (element = (SubtypeFact)ModelElement))
            {
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Constraint, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal    = pen.Color;
                        pen.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
コード例 #7
0
            /// <summary>
            /// Initialize paint settings. This is initialized after the base shape
            /// has been painted.
            /// </summary>
            public PaintHelper(DiagramPaintEventArgs e, ExternalConstraintShape constraintShape)
            {
                StyleSet           styleSet = constraintShape.StyleSet;
                StyleSetResourceId penId    = constraintShape.OutlinePenId;
                Pen        pen          = styleSet.GetPen(penId);
                Brush      brush        = styleSet.GetBrush(ExternalConstraintBrush);
                SolidBrush coloredBrush = brush as SolidBrush;

                // Keep the pen color in sync with the color being used for highlighting
                Color startColor = constraintShape.UpdateDynamicColor(constraintShape.OutlinePenId, pen);

                if (startColor.IsEmpty)
                {
                    startColor = constraintShape.UpdateGeometryLuminosity(e.View, pen);
                }
                else
                {
                    constraintShape.UpdateGeometryLuminosity(e.View, pen);
                }
                myPenStartColor = startColor;
                Color newColor = pen.Color;

                if (coloredBrush != null)
                {
                    myBrushStartColor  = coloredBrush.Color;
                    coloredBrush.Color = newColor;
                }
                else
                {
                    myBrushStartColor = Color.Empty;
                }
                myBrush = brush;
                myPen   = pen;
            }
コード例 #8
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> >()) &&
                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);
        }
コード例 #9
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, RoleNameShape, RoleBase>[] providers;
            RoleBase element;
            Store    store;

            if (brushId == RoleNameTextBrush &&
                null != (solidBrush = brush as SolidBrush) &&
                null != (store = Utility.ValidateStore(Store)) &&
                null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders <IDynamicShapeColorProvider <ORMDiagramDynamicColor, RoleNameShape, RoleBase> >()) &&
                null != (element = (RoleBase)ModelElement))
            {
                for (int i = 0; i < providers.Length; ++i)
                {
                    Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.FloatingText, this, element);
                    if (alternateColor != Color.Empty)
                    {
                        retVal           = solidBrush.Color;
                        solidBrush.Color = alternateColor;
                        break;
                    }
                }
            }
            return(retVal);
        }
コード例 #10
0
ファイル: ValueRangeLink.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
		/// </summary>
		protected Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
		{
			Color retVal = Color.Empty;
			RoleHasValueConstraint link;
			RoleValueConstraint constraint;
			IDynamicShapeColorProvider<ORMDiagramDynamicColor, ValueRangeLink, RoleValueConstraint>[] providers;
			Store store;
			if (penId == DiagramPens.ConnectionLine &&
				null != (link = ModelElement as RoleHasValueConstraint) &&
				null != (constraint = link.ValueConstraint) &&
				null != (store = Utility.ValidateStore(Store)) &&
				null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders<IDynamicShapeColorProvider<ORMDiagramDynamicColor, ValueRangeLink, RoleValueConstraint>>()))
			{
				for (int i = 0; i < providers.Length; ++i)
				{
					Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Constraint, this, constraint);
					if (alternateColor != Color.Empty)
					{
						retVal = pen.Color;
						pen.Color = alternateColor;
						break;
					}
				}
			}
			return retVal;
		}
コード例 #11
0
        /// <summary>
        /// Replacement for <see cref="ShapeField.GetBackgroundBrush"/> that recognizes
        /// <see cref="IDynamicColorGeometryHost"/>
        /// </summary>
        public override Pen GetPen(DiagramClientView view, ShapeElement parentShape, ref Color oldColor)
        {
            StyleSet styleSet     = (parentShape != null) ? parentShape.StyleSet : null;
            Color    restoreColor = Color.Empty;
            Pen      pen          = null;

            if (styleSet != null)
            {
                StyleSetResourceId penId = GetPenId(parentShape);
                pen = styleSet.GetPen(penId);
                IDynamicColorGeometryHost dynamicColors = parentShape as IDynamicColorGeometryHost;
                if (dynamicColors == null ||
                    (restoreColor = dynamicColors.UpdateDynamicColor(penId, pen)).IsEmpty)
                {
                    if (view != null)
                    {
                        restoreColor = parentShape.UpdateGeometryLuminosity(view, pen);
                    }
                }
                else if (view != null)
                {
                    parentShape.UpdateGeometryLuminosity(view, pen);
                }
            }
            if (pen != null && !restoreColor.IsEmpty)
            {
                restoreColor = pen.Color;
            }
            return(pen);
        }
コード例 #12
0
        /// <summary>
        /// Sets the given pen with the new given color.
        /// </summary>
        internal static void SetShapePenColor(this ShapeElement shape, StyleSetResourceId resourceId, Color color)
        {
            PenSettings penSettings = shape.StyleSet.GetOverriddenPenSettings(resourceId);
            if (penSettings == null)
            {
                penSettings = new PenSettings();
            }

            penSettings.Color = color;
            shape.StyleSet.OverridePen(resourceId, penSettings);
            shape.Invalidate();
        }
コード例 #13
0
        /// <summary>
        /// Sets the given brush with the new given color.
        /// </summary>
        internal static void SetShapeBrushColor(this ShapeElement shape, StyleSetResourceId resourceId, Color color)
        {
            BrushSettings brushSettings = shape.StyleSet.GetOverriddenBrushSettings(resourceId);
            if (brushSettings == null)
            {
                brushSettings = new BrushSettings();
            }

            brushSettings.Color = color;
            shape.StyleSet.OverrideBrush(resourceId, brushSettings);
            shape.Invalidate();
        }
コード例 #14
0
        /// <summary>
        /// Sets the given brush with the new given color.
        /// </summary>
        internal static void SetShapeBrushColor(this ShapeElement shape, StyleSetResourceId resourceId, Color color)
        {
            BrushSettings brushSettings = shape.StyleSet.GetOverriddenBrushSettings(resourceId);

            if (brushSettings == null)
            {
                brushSettings = new BrushSettings();
            }

            brushSettings.Color = color;
            shape.StyleSet.OverrideBrush(resourceId, brushSettings);
            shape.Invalidate();
        }
コード例 #15
0
        /// <summary>
        /// Sets the given pen with the new given color.
        /// </summary>
        internal static void SetShapePenColor(this ShapeElement shape, StyleSetResourceId resourceId, Color color)
        {
            PenSettings penSettings = shape.StyleSet.GetOverriddenPenSettings(resourceId);

            if (penSettings == null)
            {
                penSettings = new PenSettings();
            }

            penSettings.Color = color;
            shape.StyleSet.OverridePen(resourceId, penSettings);
            shape.Invalidate();
        }
コード例 #16
0
        /// <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);
        }
コード例 #17
0
        /// <summary>
        /// Replacement for <see cref="ShapeField.GetBackgroundBrush"/> that recognizes
        /// <see cref="IDynamicColorGeometryHost"/>
        /// </summary>
        public override Brush GetBackgroundBrush(DiagramClientView view, ShapeElement parentShape, ref Color oldColor)
        {
            StyleSet   styleSet     = (parentShape != null) ? parentShape.StyleSet : null;
            Brush      brush        = null;
            SolidBrush solidBrush   = null;;
            Color      restoreColor = Color.Empty;

            if (styleSet != null)
            {
                StyleSetResourceId brushId = GetBackgroundBrushId(view, parentShape);
                brush = styleSet.GetBrush(brushId);
                IDynamicColorGeometryHost dynamicColors = parentShape as IDynamicColorGeometryHost;
                if (dynamicColors == null ||
                    (restoreColor = dynamicColors.UpdateDynamicColor(brushId, brush)).IsEmpty)
                {
                    if (view != null)
                    {
                        restoreColor = parentShape.UpdateGeometryLuminosity(view, brush);
                    }
                }
                else if (view != null)
                {
                    parentShape.UpdateGeometryLuminosity(view, brush);
                }
            }
            if (restoreColor.IsEmpty)
            {
                if ((solidBrush ?? (solidBrush = brush as SolidBrush)) != null)
                {
                    restoreColor = solidBrush.Color;
                }
            }
            if (!restoreColor.IsEmpty)
            {
                oldColor = restoreColor;
            }
            return(brush);
        }
コード例 #18
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);
        }
コード例 #19
0
 /// <summary>
 ///     Overrides pen colors in one step.
 /// </summary>
 /// <param name="styleSet"></param>
 /// <param name="resourceId"></param>
 /// <param name="color"></param>
 public static void OverridePenColor(this StyleSet styleSet, StyleSetResourceId resourceId, Color color)
 {
     var settings = styleSet.GetOverriddenPenSettings(resourceId) ?? new PenSettings();
     settings.Color = color;
     styleSet.OverridePen(resourceId, settings);
 }
コード例 #20
0
		/// <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;
			IFactConstraint factConstraint;
			IConstraint constraint;
			Store store;
			if ((penId ==
#if VISUALSTUDIO_10_0
				CustomConnectionLinePen ||
#else
				DiagramPens.ConnectionLine ||
#endif
				penId == DiagramPens.ConnectionLineDecorator) &&
				null != (factConstraint = ModelElement as IFactConstraint) &&
				null != (constraint = factConstraint.Constraint) &&
				null != (store = Utility.ValidateStore(Store)) &&
				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;
		}
コード例 #21
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, ExternalConstraintLink, IConstraint>[] providers;
			IFactConstraint factConstraint;
			IConstraint constraint;
			Store store;
			if (brushId == DiagramBrushes.ConnectionLineDecorator &&
				null != (factConstraint = ModelElement as IFactConstraint) &&
				null != (constraint = factConstraint.Constraint) &&
				null != (solidBrush = brush as SolidBrush) &&
				null != (store = Utility.ValidateStore(Store)) &&
				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;
		}
コード例 #22
0
 /// <summary>
 /// Initializes the <see cref="InnerAreaField"/> class.
 /// </summary>
 static InnerAreaField()
 {
     s_background = new StyleSetResourceId("AM", "innerAreaBackground");
 }
コード例 #23
0
 /// <summary>
 /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
 /// </summary>
 protected static Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
 {
     return(Color.Empty);
 }
コード例 #24
0
		Color IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
		{
			return UpdateDynamicColor(penId, pen);
		}
コード例 #25
0
ファイル: RoleNameShape.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
		/// </summary>
		protected Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
		{
			Color retVal = Color.Empty;
			SolidBrush solidBrush;
			IDynamicShapeColorProvider<ORMDiagramDynamicColor, RoleNameShape, RoleBase>[] providers;
			RoleBase element;
			Store store;
			if (brushId == RoleNameTextBrush &&
				null != (solidBrush = brush as SolidBrush) &&
				null != (store = Utility.ValidateStore(Store)) &&
				null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders<IDynamicShapeColorProvider<ORMDiagramDynamicColor, RoleNameShape, RoleBase>>()) &&
				null != (element = (RoleBase)ModelElement))
			{
				for (int i = 0; i < providers.Length; ++i)
				{
					Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.ForegroundText, this, element);
					if (alternateColor != Color.Empty)
					{
						retVal = solidBrush.Color;
						solidBrush.Color = alternateColor;
						break;
					}
				}
			}
			return retVal;
		}
コード例 #26
0
ファイル: RolePlayerLink.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
		/// </summary>
		protected Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
		{
			Color retVal = Color.Empty;
			SolidBrush solidBrush;
			IDynamicShapeColorProvider<ORMDiagramDynamicColor, RolePlayerLink, MandatoryConstraint>[] providers;
			ObjectTypePlaysRole link;
			Role playedRole;
			MandatoryConstraint mandatory;
			Store store;
			if (brushId == DiagramBrushes.ConnectionLineDecorator &&
				null != (store = Utility.ValidateStore(Store)) &&
				null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders<IDynamicShapeColorProvider<ORMDiagramDynamicColor, RolePlayerLink, MandatoryConstraint>>()) &&
				null != (solidBrush = brush as SolidBrush) &&
				null != (link = ModelElement as ObjectTypePlaysRole) &&
				null != (playedRole = link.PlayedRole) &&
				null != (mandatory = playedRole.SimpleMandatoryConstraint) &&
				mandatory.Modality != ConstraintModality.Deontic) // The brush draws the middle, which we don't change
			{
				for (int i = 0; i < providers.Length; ++i)
				{
					Color alternateColor = providers[i].GetDynamicColor(ORMDiagramDynamicColor.Constraint, this, mandatory);
					if (alternateColor != Color.Empty)
					{
						retVal = solidBrush.Color;
						solidBrush.Color = alternateColor;
						break;
					}
				}
			}
			return retVal;
		}
コード例 #27
0
        /// <summary>
        /// Copy of <see cref="TextField.DoPaint"/> modified to support the
        /// <see cref="IDynamicColorGeometryHost"/> on the parent shape.
        /// </summary>
        public override void DoPaint(DiagramPaintEventArgs e, ShapeElement parentShape)
        {
            DiagramClientView clientView = e.View;

            if (!HasPendingEdit(parentShape, clientView))
            {
                if (GetVisible(parentShape))
                {
                    string     text     = GetDisplayText(parentShape);
                    StyleSet   styleSet = parentShape.StyleSet;
                    Graphics   g        = e.Graphics;
                    RectangleF clip     = g.ClipBounds;
                    clip.Inflate(InflateFocus, InflateFocus);
                    clip.Height -= InflateFocus;
                    g.SetClip(clip);
                    RectangleD shapeBounds    = GetBounds(parentShape);
                    RectangleF shapeRect      = RectangleD.ToRectangleF(shapeBounds);
                    Matrix     startTransform = null;
                    if (!DefaultIsHorizontal)
                    {
                        PointF point = PointD.ToPointF(shapeBounds.Center);
                        startTransform = g.Transform;
                        Matrix verticalTransform = g.Transform;
                        verticalTransform.RotateAt(-90f, point);
                        verticalTransform.Translate(0f, (-point.X / 2f) - shapeRect.X);
                        g.Transform = verticalTransform;
                    }
                    if (parentShape.ClipWhenDrawingFields)
                    {
                        RectangleD parentBounds = parentShape.BoundingBox;
                        shapeRect.Intersect(new RectangleF(0f, 0f, (float)parentBounds.Width, (float)parentBounds.Height));
                    }
                    if (FillBackground)
                    {
                        Color startColor = Color.White;
                        Brush brush      = GetBackgroundBrush(clientView, parentShape, ref startColor);
                        g.FillRectangle(brush, shapeRect);
                        SolidBrush solidBrush = brush as SolidBrush;
                        if (solidBrush != null)
                        {
                            solidBrush.Color = startColor;
                        }
                    }
                    if (DrawBorder)
                    {
                        Color oldColor = Color.White;
                        Pen   pen      = GetPen(clientView, parentShape, ref oldColor);
                        GeometryUtility.SafeDrawRectangle(g, pen, shapeRect.X, shapeRect.Y, shapeRect.Width, shapeRect.Height);
                        pen.Color = oldColor;
                    }
                    if (text.Length > 0x0)
                    {
                        using (Font font = GetFont(parentShape))
                        {
                            // Note that this ignores the base GetTextBrush, which is trivial
                            // and has no overrides. Note that we follow the convention used with
                            // the base and do not update luminosity on the text.
                            StyleSetResourceId textBrushId = GetTextBrushId(clientView, parentShape);
                            Brush textBrush        = styleSet.GetBrush(textBrushId);
                            Color restoreTextColor = Color.Empty;
                            IDynamicColorGeometryHost dynamicColors = parentShape as IDynamicColorGeometryHost;
                            if (dynamicColors != null)
                            {
                                restoreTextColor = dynamicColors.UpdateDynamicColor(textBrushId, textBrush);
                            }
                            g.DrawString(text, font, textBrush, shapeRect, GetStringFormat(parentShape));
                            SolidBrush solidTextBrush;
                            if (!restoreTextColor.IsEmpty &&
                                null != (solidTextBrush = textBrush as SolidBrush))
                            {
                                solidTextBrush.Color = restoreTextColor;
                            }
                        }
                    }
                    if (HasFocusedAppearance(parentShape, clientView))
                    {
                        // Note that the base makes a copy of shapeRect and
                        // assymetrically modifies the focus rectangle. I don't
                        // think this adds anything and gives focus floating shapes a
                        // focus rectangle that arbitrarily overlaps nearby shapes.
                        //RectangleF focusRect = shapeRect;
                        //focusRect.Inflate(0f, InflateFocus);
                        //focusRect.Height -= InflateFocus;
                        //GeometryUtility.SafeDrawRectangle(g, styleSet.GetPen(DiagramPens.FocusIndicatorBackground), focusRect.X, focusRect.Y, focusRect.Width, focusRect.Height);
                        //GeometryUtility.SafeDrawRectangle(g, styleSet.GetPen(DiagramPens.FocusIndicator), focusRect.X, focusRect.Y, focusRect.Width, focusRect.Height);
                        // UNDONE: The bottom line is drawing clipped. The original code has the same problem
                        // with both the top and bottom lines. This appears to be an issue with the Center
                        // alignment on the default focus indicator pens.
                        shapeRect.Inflate(0f, TextFocusTopPadding);
                        shapeRect.Height -= TextFocusTopPadding - TextFocusBottomPadding;
                        GeometryUtility.SafeDrawRectangle(g, styleSet.GetPen(DiagramPens.FocusIndicatorBackground), shapeRect.X, shapeRect.Y, shapeRect.Width, shapeRect.Height);
                        GeometryUtility.SafeDrawRectangle(g, styleSet.GetPen(DiagramPens.FocusIndicator), shapeRect.X, shapeRect.Y, shapeRect.Width, shapeRect.Height);
                    }
                    if (startTransform != null)
                    {
                        g.Transform = startTransform;
                    }
                }
            }
        }
コード例 #28
0
        /// <summary>
        /// Replacement for BinaryLinkShapeGeometry.DoPaintGeometry
        /// </summary>
        protected override void DoPaintGeometry(DiagramPaintEventArgs e, IGeometryHost geometryHost)
        {
            LinkShape            linkShape;
            IJumpFreeLinkShape   jumpFreeShape;
            VGObjectLineJumpCode expectedJumpCode;

            if (null != (jumpFreeShape = geometryHost as IJumpFreeLinkShape) &&
                null != (linkShape = geometryHost as LinkShape) &&
                linkShape.RouteJumpType != (expectedJumpCode = (jumpFreeShape.IsJumpFree ? VGObjectLineJumpCode.VGObjectJumpCodeNever : VGObjectLineJumpCode.VGObjectJumpCodePage)))
            {
                // Backup plan, sometimes we can't set this during configuration, and
                // it tends to revert in undo/redo scenarios when the backing graph
                // wrapper is not preserved.
                linkShape.RouteJumpType = expectedJumpCode;
            }
            Graphics           g     = e.Graphics;
            GraphicsPath       path  = this.GetPath(geometryHost);
            StyleSetResourceId penId = GetOutlinePenId(geometryHost);
            Pen pen = geometryHost.GeometryStyleSet.GetPen(penId);

            if ((path != null) && (pen != null))
            {
                IDynamicColorGeometryHost dynamicColors = geometryHost as IDynamicColorGeometryHost;
                if (this.HasOutline(geometryHost))
                {
                    Color restoreColor;
                    if (null == (dynamicColors = geometryHost as IDynamicColorGeometryHost) ||
                        (restoreColor = dynamicColors.UpdateDynamicColor(penId, pen)).IsEmpty)
                    {
                        restoreColor = geometryHost.UpdateGeometryLuminosity(e.View, pen);
                    }
                    else
                    {
                        geometryHost.UpdateGeometryLuminosity(e.View, pen);
                    }
                    GeometryUtility.SafeDrawPath(g, pen, path);
                    pen.Color = restoreColor;
                }
                IBinaryLinkGeometryData hostData;
                EdgePointCollection     edgePoints;
                int edgePointCount;
                if (null != (hostData = geometryHost as IBinaryLinkGeometryData) &&
                    null != (edgePoints = hostData.GeometryEdgePoints) &&
                    1 < (edgePointCount = edgePoints.Count))
                {
                    float         rotationAngle = 0f;
                    LinkDecorator decorator;
                    if (null != (decorator = hostData.GeometryDecoratorFrom))
                    {
                        rotationAngle = CalculateRotationAngle(edgePoints[0].Point, edgePoints[1].Point);
                        DrawDecorator(e, geometryHost, rotationAngle, edgePoints[0].Point, decorator
#if VISUALSTUDIO_10_0
                                      , hostData.GeometryDecoratorFromSize
#endif
                                      );
                    }
                    if (null != (decorator = hostData.GeometryDecoratorTo))
                    {
                        rotationAngle = CalculateRotationAngle(edgePoints[edgePointCount - 1].Point, edgePoints[edgePointCount - 2].Point);
                        DrawDecorator(e, geometryHost, rotationAngle, edgePoints[edgePointCount - 1].Point, decorator
#if VISUALSTUDIO_10_0
                                      , hostData.GeometryDecoratorToSize
#endif
                                      );
                    }
                }
            }
        }
コード例 #29
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>>()) &&
				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;
		}
コード例 #30
0
		Color IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
		{
			return UpdateDynamicColor(brushId, brush);
		}
コード例 #31
0
ファイル: RolePlayerLink.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
		/// </summary>
		protected Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
		{
			Color retVal = Color.Empty;
			IDynamicShapeColorProvider<ORMDiagramDynamicColor, RolePlayerLink, MandatoryConstraint>[] providers;
			ObjectTypePlaysRole link;
			Role playedRole;
			MandatoryConstraint mandatory;
			Store store;
			if (penId == DiagramPens.ConnectionLineDecorator &&
				null != (store = Utility.ValidateStore(Store)) &&
				null != (providers = ((IFrameworkServices)store).GetTypedDomainModelProviders<IDynamicShapeColorProvider<ORMDiagramDynamicColor, RolePlayerLink, MandatoryConstraint>>()) &&
				null != (link = ModelElement as ObjectTypePlaysRole) &&
				null != (playedRole = link.PlayedRole) &&
				null != (mandatory = playedRole.SimpleMandatoryConstraint))
			{
				ORMDiagramDynamicColor requestColor = mandatory.Modality == ConstraintModality.Deontic ? ORMDiagramDynamicColor.DeonticConstraint : ORMDiagramDynamicColor.Constraint;
				for (int i = 0; i < providers.Length; ++i)
				{
					Color alternateColor = providers[i].GetDynamicColor(requestColor, this, mandatory);
					if (alternateColor != Color.Empty)
					{
						retVal = pen.Color;
						pen.Color = alternateColor;
						break;
					}
				}
			}
			return retVal;
		}
コード例 #32
0
 /// <summary>
 /// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
 /// </summary>
 protected static Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
 {
     return(Color.Empty);
 }
コード例 #33
0
ファイル: ValueRangeLink.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Brush)"/>
		/// </summary>
		protected static Color UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
		{
			return Color.Empty;
		}
コード例 #34
0
 Color IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId brushId, Brush brush)
 {
     return(UpdateDynamicColor(brushId, brush));
 }
コード例 #35
0
ファイル: RoleNameShape.cs プロジェクト: cjheath/NORMA
		/// <summary>
		/// Implements <see cref="IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId,Pen)"/>
		/// </summary>
		protected static Color UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
		{
			return Color.Empty;
		}
コード例 #36
0
 Color IDynamicColorGeometryHost.UpdateDynamicColor(StyleSetResourceId penId, Pen pen)
 {
     return(UpdateDynamicColor(penId, pen));
 }
コード例 #37
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>>()) &&
				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;
		}