protected override void DrawEndCap(IGraphics g, bool onScreen, Style style) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; g.FillPath(Brushes.White, Arrowhead.ClosedArrowPath); g.DrawPath(linePen, Arrowhead.ClosedArrowPath); }
public override void Draw(IGraphics g, bool onScreen, Style style) { base.Draw(g, onScreen, style); if(generalization.Second is ClassType) DrawRole(g, style, ((ClassType)generalization.Second).InheritanceStrategy.ToString(), RouteCache[0], RouteCache[1], StartCapSize); }
protected override void DrawStartCap(IGraphics g, bool onScreen, Style style) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; g.FillEllipse(Brushes.White, -Radius, 0, Diameter, Diameter); g.DrawEllipse(linePen, -Radius, 0, Diameter, Diameter); g.DrawLine(linePen, 0, Radius - CrossSize / 2, 0, Radius + CrossSize / 2); g.DrawLine(linePen, -CrossSize / 2, Radius, CrossSize / 2, Radius); }
protected override int GetBorderWidth(Style style) { switch (_class.Modifier) { case ClassModifier.Abstract: return style.AbstractClassBorderWidth; case ClassModifier.Sealed: return style.SealedClassBorderWidth; case ClassModifier.Static: return style.StaticClassBorderWidth; case ClassModifier.None: default: return style.ClassBorderWidth; } }
protected override bool IsBorderDashed(Style style) { switch (_class.Modifier) { case ClassModifier.Abstract: return style.IsAbstractClassBorderDashed; case ClassModifier.Sealed: return style.IsSealedClassBorderDashed; case ClassModifier.Static: return style.IsStaticClassBorderDashed; case ClassModifier.None: default: return style.IsClassBorderDashed; } }
private void DrawRole(IGraphics g, Style style, string text, Point firstPoint, Point secondPoint, Size capSize) { float angle = GetAngle(firstPoint, secondPoint); Point point = firstPoint; if (angle == 0) // Down { point.X -= capSize.Width / 2 + TextMargin.Width; point.Y += style.ShadowOffset.Height + TextMargin.Height; stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; } else if (angle == 90) // Left { point.X -= TextMargin.Width; point.Y += capSize.Width / 2 + TextMargin.Height; stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Near; } else if (angle == 180) // Up { point.X -= capSize.Width / 2 + TextMargin.Width; point.Y -= TextMargin.Height; stringFormat.Alignment = StringAlignment.Far; stringFormat.LineAlignment = StringAlignment.Far; } else // Right { point.X += style.ShadowOffset.Width + TextMargin.Width; point.Y += capSize.Width / 2 + TextMargin.Height; stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Near; } textBrush.Color = style.RelationshipTextColor; g.DrawString(text, style.RelationshipTextFont, textBrush, point, stringFormat); }
protected override int GetRoundingSize(Style style) { return style.ClassRoundingSize; }
protected override Font GetNameFont(Style style) { if (_class.Modifier == ClassModifier.Abstract) return style.AbstractNameFont; else return base.GetNameFont(style); }
private RectangleF GetEndRoleArea(Style style) { int last = RouteCache.Count - 1; return GetRoleArea(style, AssociationRelationship.EndRole, RouteCache[last], RouteCache[last - 1], EndCapSize); }
protected virtual void DrawEndCap(IGraphics g, bool onScreen, Style style) { }
private void DrawLine(IGraphics g, bool onScreen, Style style) { if (!IsSelected || !onScreen) { linePen.Width = style.RelationshipWidth; linePen.Color = style.RelationshipColor; if (IsDashed) { dashPattern[0] = style.RelationshipDashSize; dashPattern[1] = style.RelationshipDashSize; linePen.DashPattern = dashPattern; } else { linePen.DashStyle = DashStyle.Solid; } g.DrawLines(linePen, routeCacheArray); } }
private RectangleF GetLabelArea(Style style) { bool horizontal; PointF center = GetLineCenter(out horizontal); SizeF size = Graphics.MeasureString(Relationship.Label, style.RelationshipTextFont, PointF.Empty, stringFormat); if (horizontal) { center.X -= size.Width / 2; center.Y -= size.Height + TextMargin.Height; } else { center.Y -= size.Height / 2; center.X += TextMargin.Width; } return new RectangleF(center.X, center.Y, size.Width, size.Height); }
protected override GradientStyle GetGradientHeaderStyle(Style style) { return style.ClassGradientHeaderStyle; }
private static void AddToList(Style style, string stylePath) { if (!styles.ContainsKey(stylePath)) { styles.Add(stylePath, style); } else // Replace the old style { styles.Remove(stylePath); styles.Add(stylePath, style); } }
private static bool LoadCurrentStyle() { return ((currentStyle = Load(userStylePath, false)) != null); }
static Style() { Directory.CreateDirectory(StylesDirectory); LoadStyles(); if (!LoadCurrentStyle()) { CurrentStyle = new Style(); SaveCurrentStyle(); } }
private RectangleF MultiplicityArea(Style style, string text, Point firstPoint, Point secondPoint, Size capSize) { float angle = GetAngle(firstPoint, secondPoint); SizeF textSize = Graphics.MeasureString(text, style.RelationshipTextFont, PointF.Empty, stringFormat); RectangleF area = new RectangleF(firstPoint, textSize); if (angle == 0) // Down { area.X += capSize.Width / 2 + TextMargin.Width; area.Y += style.ShadowOffset.Height + TextMargin.Height; } else if (angle == 90) // Left { area.X -= textSize.Width + TextMargin.Width; area.Y -= textSize.Height + capSize.Width / 2 + TextMargin.Height; } else if (angle == 180) // Up { area.X += capSize.Width / 2 + TextMargin.Width; area.Y -= textSize.Height + TextMargin.Height; } else // Right { area.X += style.ShadowOffset.Width + TextMargin.Width; area.Y -= textSize.Height + capSize.Width / 2 + TextMargin.Height; } return area; }
private RectangleF GetEndMultiplicityArea(Style style) { int last = RouteCache.Count - 1; return MultiplicityArea(style, AssociationRelationship.EndMultiplicity, RouteCache[last], RouteCache[last - 1], EndCapSize); }
private RectangleF GetStartMultiplicityArea(Style style) { return MultiplicityArea(style, AssociationRelationship.StartMultiplicity, RouteCache[0], RouteCache[1], StartCapSize); }
protected override RectangleF CalculateDrawingArea(Style style, bool printing, float zoom) { RectangleF area = base.CalculateDrawingArea(style, printing, zoom); if (AssociationRelationship.StartRole != null) area = RectangleF.Union(area, GetStartRoleArea(style)); if (AssociationRelationship.EndRole != null) area = RectangleF.Union(area, GetEndRoleArea(style)); if (AssociationRelationship.StartMultiplicity != null) area = RectangleF.Union(area, GetStartMultiplicityArea(style)); if (AssociationRelationship.EndMultiplicity != null) area = RectangleF.Union(area, GetEndMultiplicityArea(style)); return area; }
protected override void DrawEndCap(IGraphics g, bool onScreen, Style style) { if (association.Direction == Direction.Unidirectional) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; g.DrawLines(linePen, Arrowhead.OpenArrowPoints); } }
protected override Color GetBackgroundColor(Style style) { return style.ClassBackgroundColor; }
protected override RectangleF CalculateDrawingArea(Style style, bool printing, float zoom) { RectangleF area = GetRouteArea(); float lineSize = (float) style.RelationshipWidth / 2; if (IsSelected && !printing) lineSize = Math.Max(lineSize, (float) BendPoint.SquareSize / 2 / zoom); area.Inflate(lineSize, lineSize); if (StartCapSize != Size.Empty) area = RectangleF.Union(area, GetStartCapArea()); if (EndCapSize != Size.Empty) area = RectangleF.Union(area, GetEndCapArea()); if (Relationship.Label != null) area = RectangleF.Union(area, GetLabelArea(style)); return area; }
protected override Color GetBorderColor(Style style) { return style.ClassBorderColor; }
public override void Draw(IGraphics g, bool onScreen, Style style) { DrawLine(g, onScreen, style); DrawCaps(g, onScreen, style); if (Relationship.SupportsLabel) DrawLabel(g, onScreen, style); }
protected override void DrawStartCap(IGraphics g, bool onScreen, Style style) { linePen.Color = style.RelationshipColor; linePen.Width = style.RelationshipWidth; if (association.IsAggregation) { g.FillPolygon(Brushes.White, diamondPoints); g.DrawPolygon(linePen, diamondPoints); } else if (association.IsComposition) { lineBrush.Color = style.RelationshipColor; g.FillPolygon(lineBrush, diamondPoints); g.DrawPolygon(linePen, diamondPoints); } }
private void DrawCaps(IGraphics g, bool onScreen, Style style) { Matrix transformState = g.Transform; g.TranslateTransform(routeCache[0].X, routeCache[0].Y); g.RotateTransform(GetAngle(routeCache[0], routeCache[1])); DrawStartCap(g, onScreen, style); g.Transform = transformState; int last = routeCache.Count - 1; g.TranslateTransform(routeCache[last].X, routeCache[last].Y); g.RotateTransform(GetAngle(routeCache[last], routeCache[last - 1])); DrawEndCap(g, onScreen, style); g.Transform = transformState; }
protected override Color GetHeaderColor(Style style) { return style.ClassHeaderColor; }
private void DrawLabel(IGraphics g, bool onScreen, Style style) { if (Relationship.Label != null) { bool horizontal; PointF center = GetLineCenter(out horizontal); textBrush.Color = style.RelationshipTextColor; if (horizontal) { stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Far; center.Y -= TextMargin.Height; } else { stringFormat.Alignment = StringAlignment.Near; stringFormat.LineAlignment = StringAlignment.Center; center.X += TextMargin.Width; } g.DrawString(Relationship.Label, style.RelationshipTextFont, textBrush, center, stringFormat); } }
private RectangleF GetStartRoleArea(Style style) { return GetRoleArea(style, AssociationRelationship.StartRole, RouteCache[0], RouteCache[1], StartCapSize); }