Beispiel #1
0
		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);
        }
Beispiel #3
0
		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);
		}
Beispiel #4
0
		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;
			}
		}
Beispiel #5
0
		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);
        }
Beispiel #7
0
		protected override int GetRoundingSize(Style style)
		{
			return style.ClassRoundingSize;
		}
Beispiel #8
0
		protected override Font GetNameFont(Style style)
		{
			if (_class.Modifier == ClassModifier.Abstract)
				return style.AbstractNameFont;
			else
				return base.GetNameFont(style);
		}
Beispiel #9
0
		private RectangleF GetEndRoleArea(Style style)
		{
			int last = RouteCache.Count - 1;
			return GetRoleArea(style, AssociationRelationship.EndRole,
				RouteCache[last], RouteCache[last - 1], EndCapSize);
		}
Beispiel #10
0
		protected virtual void DrawEndCap(IGraphics g, bool onScreen, Style style)
		{
		}
Beispiel #11
0
		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);
			}
		}
Beispiel #12
0
		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);
		}
Beispiel #13
0
		protected override GradientStyle GetGradientHeaderStyle(Style style)
		{
			return style.ClassGradientHeaderStyle;
		}
Beispiel #14
0
		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);
			}
		}
Beispiel #15
0
		private static bool LoadCurrentStyle()
		{
			return ((currentStyle = Load(userStylePath, false)) != null);
		}
Beispiel #16
0
		static Style()
		{
			Directory.CreateDirectory(StylesDirectory);
			LoadStyles();
			if (!LoadCurrentStyle())
			{
				CurrentStyle = new Style();
				SaveCurrentStyle();
			}
		}
Beispiel #17
0
		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;
		}
Beispiel #18
0
		private RectangleF GetEndMultiplicityArea(Style style)
		{
			int last = RouteCache.Count - 1;
			return MultiplicityArea(style, AssociationRelationship.EndMultiplicity,
				RouteCache[last], RouteCache[last - 1], EndCapSize);
		}
Beispiel #19
0
		private RectangleF GetStartMultiplicityArea(Style style)
		{
			return MultiplicityArea(style, AssociationRelationship.StartMultiplicity,
				RouteCache[0], RouteCache[1], StartCapSize);
		}
Beispiel #20
0
		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;
		}
Beispiel #21
0
		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);
			}
		}
Beispiel #22
0
		protected override Color GetBackgroundColor(Style style)
		{
            return style.ClassBackgroundColor;
		}
Beispiel #23
0
		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;
		}
Beispiel #24
0
		protected override Color GetBorderColor(Style style)
		{
			return style.ClassBorderColor;
		}
Beispiel #25
0
		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);
		}
Beispiel #26
0
		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);
			}
		}
Beispiel #27
0
		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;
		}
Beispiel #28
0
		protected override Color GetHeaderColor(Style style)
		{
            return style.ClassHeaderColor;
		}
Beispiel #29
0
		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);
			}
		}
Beispiel #30
0
		private RectangleF GetStartRoleArea(Style style)
		{
			return GetRoleArea(style, AssociationRelationship.StartRole,
				RouteCache[0], RouteCache[1], StartCapSize);
		}