Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// OnBeforePaint is called at the start of the ShapeElement's painting.
        /// It provides an opportunity for developers to update and override resources
        /// before they're used in painting.
        /// </summary>
        /// <remarks>
        /// You can override existing resources by calling StyleSet.OverrideXXX and
        /// changing the specific setting that you would like.
        /// </remarks>
        protected override void OnBeforePaint()
        {
            if (ModelElement is ModelClass element && (element.IsAbstract || element.IsDependentType))
            {
                PenSettings penSettings = StyleSet.GetOverriddenPenSettings(DiagramPens.ConnectionLine) ?? new PenSettings();

                if (element.IsAbstract)
                {
                    penSettings.Color     = Color.OrangeRed;
                    penSettings.Width     = 0.03f;
                    penSettings.DashStyle = DashStyle.Dot;
                }
                else if (element.IsDependentType)
                {
                    penSettings.Color     = Color.ForestGreen;
                    penSettings.Width     = 0.03f;
                    penSettings.DashStyle = DashStyle.Dot;
                }

                StyleSet.OverridePen(DiagramPens.ShapeOutline, penSettings);
            }
        /// <summary>
        /// OnBeforePaint is called at the start of the ShapeElement's painting.
        /// It provides an opportunity for developers to update and override resources
        /// before they're used in painting.
        /// </summary>
        /// <remarks>
        /// You can override existing resources by calling StyleSet.OverrideXXX and
        /// changing the specific setting that you would like.
        /// </remarks>
        protected override void OnBeforePaint()
        {
            if (ModelElement is Association element)
            {
                BidirectionalAssociation bidirectionalElement = ModelElement as BidirectionalAssociation;
                bool hasAutoInclude = element.Source.ModelRoot.IsEFCore5Plus && (element.TargetAutoInclude || bidirectionalElement?.SourceAutoInclude == true);

                if (hasAutoInclude)
                {
                    PenSettings settings = StyleSet.GetOverriddenPenSettings(DiagramPens.ConnectionLine) ?? new PenSettings();
                    settings.Width = 0.05f;
                    StyleSet.OverridePen(DiagramPens.ConnectionLine, settings);
                }
                else
                {
                    StyleSet.ClearPenOverride(DiagramPens.ConnectionLine);
                }
            }
            else
            {
                StyleSet.ClearPenOverride(DiagramPens.ConnectionLine);
            }
        }