/// <summary> /// Override the connection line pen with a dashed pen /// </summary> /// <param name="classStyleSet"></param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); IORMFontAndColorService colorService = (this.Store as IORMToolServices).FontAndColorService; Color constraintColor = colorService.GetForeColor(ORMDesignerColor.Constraint); Color activeColor = colorService.GetBackColor(ORMDesignerColor.ActiveConstraint); PenSettings settings = new PenSettings(); settings.Color = constraintColor; settings.DashStyle = DashStyle.Dash; settings.Width = 1.0F / 72.0F; // 1 Point. 0 Means 1 pixel, but should only be used for non-printed items #if VISUALSTUDIO_10_0 classStyleSet.AddPen(CustomConnectionLinePen, DiagramPens.ConnectionLine, settings); #else classStyleSet.OverridePen(DiagramPens.ConnectionLine, settings); #endif settings.Color = activeColor; classStyleSet.AddPen(ORMDiagram.StickyBackgroundResource, DiagramPens.ConnectionLine, settings); settings = new PenSettings(); settings.Width = 1.0F / 72.0F; // Soften the arrow a bit settings.Color = constraintColor; classStyleSet.OverridePen(DiagramPens.ConnectionLineDecorator, settings); settings.Color = activeColor; classStyleSet.AddPen(ORMDiagram.StickyForegroundResource, DiagramPens.ConnectionLineDecorator, settings); BrushSettings brushSettings = new BrushSettings(); brushSettings.Color = constraintColor; classStyleSet.OverrideBrush(DiagramBrushes.ConnectionLineDecorator, brushSettings); brushSettings.Color = activeColor; classStyleSet.AddBrush(ORMDiagram.StickyForegroundResource, DiagramBrushes.ConnectionLineDecorator, brushSettings); }
/// <summary> /// Adjust the outline pen width /// </summary> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings penSettings = new PenSettings(); penSettings.Width = 1.0F / 72.0F; // 1 Point. 0 Means 1 pixel, but should only be used for non-printed items penSettings.Color = SystemColors.GrayText; classStyleSet.OverridePen(DiagramPens.ShapeOutline, penSettings); }
/// <summary> /// Override the connection line pen with a dashed pen /// </summary> /// <param name="classStyleSet"></param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings penSettings = new PenSettings(); penSettings.DashStyle = DashStyle.Dot; penSettings.Color = SystemColors.GrayText; penSettings.Width = 1.0F / 72.0F; // 1 Point. 0 Means 1 pixel, but should only be used for non-printed items classStyleSet.OverridePen(DiagramPens.ConnectionLine, penSettings); }
/// <summary> /// Add the operator pen to the style set. /// </summary> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings penSettings = new PenSettings(); penSettings.Width = 1 / 72f; penSettings.StartCap = LineCap.Square; penSettings.EndCap = LineCap.Square; classStyleSet.AddPen(OperatorResource, DiagramPens.ShapeOutline, penSettings); }
private static void SetConnectorWidth(AssociationConnector connector) { PenSettings settings = connector.StyleSet.GetOverriddenPenSettings(DiagramPens.ConnectionLine) ?? new PenSettings(); settings.Width = connector.ManuallyRouted ? 0.02f : 0.01f; connector.StyleSet.OverridePen(DiagramPens.ConnectionLine, settings); }
private protected virtual Pen GetPen(PenSettings key) { if (PenTable.ContainsKey(key)) { return(PenTable[key]); } else { return(DefaultPenTable[key]); } }
/// <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(); }
/// <summary> /// Initialize a <see cref="StyleSet"/> for rendering deontic constraints. /// The style set is created in <see cref="DeonticClassStyleSet"/> and /// initialized here. /// </summary> /// <remarks>If a derived class does not modify additional resources in the /// default style set, then this method is not required and any derived deontic /// style set can be based on the deontic style set for this base class. However, /// if new resources are introduced, then the derived class should base a /// deontic style set on the derived class style set and reinitialize the /// deontic settings in that style set.</remarks> protected virtual void InitializeDeonticClassStyleSet(StyleSet styleSet) { IORMFontAndColorService colorService = (Store as IORMToolServices).FontAndColorService; Color constraintColor = colorService.GetForeColor(ORMDesignerColor.DeonticConstraint); PenSettings penSettings = new PenSettings(); penSettings.Color = constraintColor; styleSet.OverridePen(DiagramPens.ShapeOutline, penSettings); BrushSettings brushSettings = new BrushSettings(); brushSettings.Color = constraintColor; styleSet.OverrideBrush(ExternalConstraintBrush, brushSettings); }
/// <summary> /// Change the outline pen to a thin black line for all instances /// of this shape. /// </summary> /// <param name="classStyleSet">The style set to modify</param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); IORMFontAndColorService colorService = (Store as IORMToolServices).FontAndColorService; PenSettings settings = new PenSettings(); settings.Color = colorService.GetForeColor(ORMDesignerColor.Constraint); settings.DashStyle = DashStyle.Dash; settings.Width = 1.0F / 72.0F; // 1 Point. 0 Means 1 pixel, but should only be used for non-printed items classStyleSet.OverridePen(DiagramPens.ConnectionLine, settings); settings.Color = colorService.GetBackColor(ORMDesignerColor.ActiveConstraint); classStyleSet.AddPen(ORMDiagram.StickyBackgroundResource, DiagramPens.ConnectionLine, settings); }
/// <summary> /// Initialize a pen and a brush for drawing the constraint /// outlines and contents. /// </summary> /// <param name="classStyleSet">StyleSet</param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings penSettings = new PenSettings(); IORMFontAndColorService colorService = (Store as IORMToolServices).FontAndColorService; Color constraintColor = colorService.GetForeColor(ORMDesignerColor.Constraint); penSettings.Color = constraintColor; penSettings.Width = 1.35F / 72.0F; // 1.35 Point. classStyleSet.OverridePen(DiagramPens.ShapeOutline, penSettings); BrushSettings brushSettings = new BrushSettings(); brushSettings.Color = constraintColor; classStyleSet.AddBrush(ExternalConstraintBrush, DiagramBrushes.ShapeBackground, brushSettings); penSettings.Color = colorService.GetBackColor(ORMDesignerColor.ActiveConstraint); classStyleSet.AddPen(ORMDiagram.StickyBackgroundResource, DiagramPens.ShapeOutline, penSettings); }
/// <summary> /// Change the outline pen to a thin black line for all instances /// of this shape. /// </summary> /// <param name="classStyleSet">The style set to modify</param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); IORMFontAndColorService colorService = (this.Store as IORMToolServices).FontAndColorService; Color lineColor = colorService.GetForeColor(ORMDesignerColor.Constraint); Color stickyColor = colorService.GetBackColor(ORMDesignerColor.ActiveConstraint); Color activeColor = colorService.GetBackColor(ORMDesignerColor.RolePicker); PenSettings penSettings = new PenSettings(); penSettings.Width = 1.8F / 72.0F; // 1.8 Point. 0 Means 1 pixel, but should only be used for non-printed items penSettings.Alignment = PenAlignment.Center; penSettings.Color = lineColor; classStyleSet.OverridePen(DiagramPens.ConnectionLine, penSettings); //Supporting Dashed subtypefacts when not primary penSettings.DashStyle = DashStyle.Dash; classStyleSet.AddPen(NonPrimaryNormalResource, DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Solid; penSettings.Color = stickyColor; classStyleSet.AddPen(ORMDiagram.StickyBackgroundResource, DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Dash; classStyleSet.AddPen(NonPrimaryStickyResource, DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Solid; penSettings.Color = activeColor; classStyleSet.AddPen(ORMDiagram.ActiveBackgroundResource, DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Dash; classStyleSet.AddPen(NonPrimaryActiveResource, DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Solid; penSettings = new PenSettings(); penSettings.Width = 1.4F / 72.0F; // Soften the arrow a bit penSettings.Color = lineColor; classStyleSet.OverridePen(DiagramPens.ConnectionLineDecorator, penSettings); penSettings.Color = stickyColor; classStyleSet.AddPen(ORMDiagram.StickyConnectionLineDecoratorResource, DiagramPens.ConnectionLineDecorator, penSettings); penSettings.Color = activeColor; classStyleSet.AddPen(ORMDiagram.ActiveConnectionLineDecoratorResource, DiagramPens.ConnectionLineDecorator, penSettings); BrushSettings brushSettings = new BrushSettings(); brushSettings.Color = lineColor; classStyleSet.OverrideBrush(DiagramBrushes.ConnectionLineDecorator, brushSettings); brushSettings.Color = stickyColor; classStyleSet.AddBrush(ORMDiagram.StickyConnectionLineDecoratorResource, DiagramBrushes.ConnectionLineDecorator, brushSettings); brushSettings.Color = activeColor; classStyleSet.AddBrush(ORMDiagram.ActiveConnectionLineDecoratorResource, DiagramBrushes.ConnectionLineDecorator, brushSettings); }
/// <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); }
// change the display to reflect it's disabled protected internal void SetdisabledValue(bool newval) { if (newval == m_disabledValue) { return; } m_disabledValue = newval; if (m_disabledValue) { // update font and border PenSettings outlinePen = new PenSettings(); outlinePen.Color = Color.FromKnownColor(KnownColor.LightGray); outlinePen.DashStyle = DashStyle.Custom; outlinePen.DashPattern = CustomOutlineDashPattern; outlinePen.Width = 0.01F; this.ClassStyleSet.OverridePen(DiagramPens.ShapeOutline, outlinePen); BrushSettings textBrush = new BrushSettings(); textBrush.Color = Color.FromKnownColor(KnownColor.LightGray); this.ClassStyleSet.OverrideBrush(DiagramBrushes.ShapeText, textBrush); this.Invalidate(); } else { // update font and border PenSettings outlinePen = new PenSettings(); outlinePen.Color = Color.FromKnownColor(KnownColor.Black); outlinePen.DashStyle = DashStyle.Custom; outlinePen.DashPattern = CustomOutlineDashPattern; outlinePen.Width = 0.01F; this.ClassStyleSet.OverridePen(DiagramPens.ShapeOutline, outlinePen); BrushSettings textBrush = new BrushSettings(); textBrush.Color = Color.FromKnownColor(KnownColor.Black); this.ClassStyleSet.OverrideBrush(DiagramBrushes.ShapeText, textBrush); this.Invalidate(); } }
/// <summary> /// Initializes style set resources for this shape type /// </summary> /// <param name="classStyleSet">The style set for this shape class</param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings settings = new PenSettings(); settings.Color = Color.FromArgb(0xff, 0, 0, 0); settings.Width = 0.01f; classStyleSet.OverridePen(DiagramPens.ShapeOutline, settings); BrushSettings settings2 = new BrushSettings(); settings2.Color = Color.FromArgb(0xff, 159, 183, 215); classStyleSet.OverrideBrush(DiagramBrushes.ShapeBackground, settings2); FontSettings settings3 = new FontSettings(); settings3.Style = FontStyle.Regular; settings3.Size = 0.09722222f; classStyleSet.AddFont(new StyleSetResourceId(string.Empty, "ShapeTextRegular7"), DiagramFonts.ShapeText, settings3); }
/// <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); } }
/// <summary> /// Change the outline pen to a thin black line for all instances /// of this shape. /// </summary> /// <param name="classStyleSet">The style set to modify</param> protected override void InitializeResources(StyleSet classStyleSet) { base.InitializeResources(classStyleSet); PenSettings penSettings = new PenSettings(); penSettings.Width = 1.2F / 72.0F; // 1.2 Point. 0 Means 1 pixel, but should only be used for non-printed items penSettings.Alignment = PenAlignment.Center; classStyleSet.OverridePen(DiagramPens.ConnectionLine, penSettings); penSettings.DashStyle = DashStyle.Dash; classStyleSet.AddPen(BarkerEROptionalPen, DiagramPens.ConnectionLine, penSettings); IORMFontAndColorService fontsAndColors = (Store as IORMToolServices).FontAndColorService; Color constraintForeColor = fontsAndColors.GetForeColor(ORMDesignerColor.Constraint); penSettings = new PenSettings(); penSettings.Color = constraintForeColor; classStyleSet.OverridePen(DiagramPens.ConnectionLineDecorator, penSettings); BrushSettings brushSettings = new BrushSettings(); brushSettings.Color = constraintForeColor; classStyleSet.OverrideBrush(DiagramBrushes.ConnectionLineDecorator, brushSettings); }