private void DrawRelation(RenderInfo info, PointF startPoint, PointF endPoint, Pen pen) { //start if (DataSource.AssociationType == UmlRelationType.Aggregation) { DrawAggregatePort(info, DataSource.StartPortSide, startPoint, pen); } else { DrawPort(info, DataSource.StartPortSide, startPoint, pen); } //middle DrawLine(info, pen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); //end if (DataSource.AssociationType == UmlRelationType.Association) DrawArrowPort(info, DataSource.EndPortSide, endPoint, pen); if (DataSource.AssociationType == UmlRelationType.Aggregation) DrawArrowPort(info, DataSource.EndPortSide, endPoint, pen); if (DataSource.AssociationType == UmlRelationType.None) DrawPort(info, DataSource.EndPortSide, endPoint, pen); if (DataSource.AssociationType == UmlRelationType.Inheritance) DrawInheritancePort(info, DataSource.EndPortSide, endPoint, pen); }
public override void DrawBackground(RenderInfo info) { Shape start = Start; Shape end = End; if (start == null || end == null) return; Rectangle startBounds = start.Bounds; Rectangle endBounds = end.Bounds; PointF startPoint = GetPoint(startBounds, DataSource.StartPortOffset, DataSource.StartPortSide); PointF endPoint = GetPoint(endBounds, DataSource.EndPortOffset, DataSource.EndPortSide); Pen pen; if (DataSource.AssociationType == UmlRelationType.Inheritance) pen = Pens.InheritanceLine; else if (DataSource.AssociationType == UmlRelationType.None) pen = Pens.FakeLine; else pen = Pens.AssociationLine; // DrawAssociation(info, startPoint, endPoint, Settings.Pens.AssociationBorder); DrawRelationBackground(info, startPoint, endPoint); if (Selected) { DrawRelation(info, startPoint, endPoint, Pens.AssociationBorder); } DrawRelation(info, startPoint, endPoint, pen); DrawPortSelectionHandles(info, DataSource.StartPortSide, startPoint); DrawPortSelectionHandles(info, DataSource.EndPortSide, endPoint); }
public override void Draw(RenderInfo info) { int grid = info.GridSize; Rectangle renderBounds = Bounds; var bboxThis = new BoundingBox {Bounds = renderBounds, Target = this, Data = BodyIdentifier}; info.BoundingItems.Add(bboxThis); int x = renderBounds.X; int y = renderBounds.Y; int width = renderBounds.Width; int height = renderBounds.Height; GraphicsPath path = GetOutlinePath(x, y, width, height); Pen borderPen = GetBorderPen(); using (Brush captionBrush = GetCaptionBrush(renderBounds)) { if (Expanded) DrawExpanded(info, path, x, y, width, height, captionBrush, borderPen); else DrawCollapsed(info, path, x, y, width, height, captionBrush, borderPen); } DrawTypeExpander(info, x, y, width); DrawSelection(info); DrawTypeName(info, x, y, width); DrawTypeKind(info, x, y, width); DrawCustomCaptionInfo(info, x, y, width); }
protected void DrawSelectionHandle(RenderInfo info, Point point) { var bounds = new Rectangle(point.X - 4, point.Y - 4, 8, 8); info.Graphics.FillRectangle(Brushes.Gray, bounds); bounds.Inflate(-1, -1); info.Graphics.FillRectangle(Brushes.White, bounds); }
protected override void DrawCustomCaptionInfo(RenderInfo info, int x, int y, int width) { if (InheritsTypeName != null) { info.Graphics.DrawImage(Resources.InheritanceArrow, x + Margins.TypeBoxSideMargin, y + 35); var typeInheritsBounds = new Rectangle(x + 24, y + 33, width - 26, 10); info.Graphics.DrawString(InheritsTypeName, Fonts.InheritsTypeName, Brushes.Black, typeInheritsBounds, StringFormat.GenericTypographic); } IList<string> implementedInterfaces = TypedDataSource.GetImplementedInterfaces(); if (implementedInterfaces.Count > 0) { int offsetX = 20; int offsetY = 20 + (16*(implementedInterfaces.Count - 1)); info.Graphics.DrawEllipse(Pens.Lolipop, x + offsetX, y - offsetY, 12, 12); info.Graphics.DrawLine(Pens.Lolipop, x + offsetX + 6, y - offsetY + 12, x + offsetX + 6, y); int yy = y - offsetY; foreach (string interfaceName in implementedInterfaces) { info.Graphics.DrawString(interfaceName, Fonts.ImplementedInterfaces, Brushes.Black, x + offsetX + 16, yy); yy += 16; } } }
public virtual void Draw(RenderInfo info) { if (!info.Preview && info.ShowGrid) { int xo = info.VisualBounds.X%info.GridSize; int yo = info.VisualBounds.Y%info.GridSize; for (int y = info.VisualBounds.Y - yo; y < (info.VisualBounds.Bottom + info.GridSize)/info.Zoom; y += info.GridSize) { for (int x = info.VisualBounds.X - xo; x < (info.VisualBounds.Right + info.GridSize)/info.Zoom; x += info.GridSize) { info.Graphics.FillRectangle(Brushes.Gray, x, y, 1, 1); } } } int maxWidth = int.MinValue; int maxHeight = int.MinValue; int minWidth = int.MaxValue; int minHeight = int.MaxValue; foreach (Shape shape in Shapes) { if (info.Preview) shape.PreviewDrawBackground(info); else shape.DrawBackground(info); } foreach (Shape shape in Shapes) { if (info.Preview) shape.DrawPreview(info); else shape.Draw(info); if (shape.Bounds.Left*info.Zoom < minWidth) minWidth = (int) (shape.Bounds.Left*info.Zoom); if (shape.Bounds.Top*info.Zoom < minHeight) minHeight = (int) (shape.Bounds.Top*info.Zoom); if (shape.Bounds.Right*info.Zoom > maxWidth) maxWidth = (int) (shape.Bounds.Right*info.Zoom); if (shape.Bounds.Bottom*info.Zoom > maxHeight) maxHeight = (int) (shape.Bounds.Bottom*info.Zoom); } maxWidth += (int) (info.GridSize*info.Zoom); maxHeight += (int) (info.GridSize*info.Zoom); info.ReturnedBounds = new Rectangle(new Point(minWidth, minHeight), new Size(maxWidth - minWidth, maxHeight - minHeight)); }
protected virtual void DrawSelection(RenderInfo info) { if (Selected && SelectedObject == null) { Rectangle outerBounds = Bounds; outerBounds.Inflate(6, 6); outerBounds.Offset(1, 0); Rectangle innerBounds = outerBounds; innerBounds.Inflate(-3, -3); info.Graphics.SetClip(outerBounds, CombineMode.Replace); info.Graphics.SetClip(innerBounds, CombineMode.Xor); info.Graphics.FillRectangle(Brushes.Selection, outerBounds); info.Graphics.ResetClip(); //info.Graphics.DrawRectangle(Settings.Pens.SelectionInner, outerBounds); //outerBounds.Offset(-1, 1); //info.Graphics.DrawRectangle(Settings.Pens.SelectionOuter, outerBounds); DrawSelectionHandle(info, new Point(outerBounds.Left, (outerBounds.Top + outerBounds.Bottom)/2), LeftResizeIdentifier); DrawSelectionHandle(info, new Point(outerBounds.Right, (outerBounds.Top + outerBounds.Bottom)/2), RightResizeIdentifier); DrawCustomSelection(info); } }
public override void Draw(RenderInfo info) { int grid = info.GridSize; Rectangle renderBounds = Bounds; var bboxThis = new BoundingBox(); bboxThis.Bounds = renderBounds; bboxThis.Target = this; bboxThis.Data = BodyIdentifier; info.BoundingBoxes.Add(bboxThis); int x = renderBounds.X; int y = renderBounds.Y; int width = renderBounds.Width; int height = renderBounds.Height; GraphicsPath path = GetOutlinePath(x, y, width, height); Pen borderPen = GetBorderPen(); info.Graphics.FillPath(SystemBrushes.Info, path); info.Graphics.DrawPath(borderPen, path); renderBounds = DrawText(info, renderBounds); DrawSelection(info); }
protected void DrawSelectionHandle(RenderInfo info, Point point, object identifier) { DrawSelectionHandle(info, point); var bounds = new Rectangle(point.X - 4, point.Y - 4, 8, 8); var bBox = new BoundingBox(); bBox.Bounds = bounds; bBox.Data = identifier; bBox.Target = this; info.BoundingBoxes.Add(bBox); }
public override void DrawBackground(RenderInfo info) { int grid = info.GridSize; Rectangle renderBounds = Bounds; int x = renderBounds.X + 4; int y = renderBounds.Y + 3; int width = renderBounds.Width; int height = renderBounds.Height; GraphicsPath shadowPath = GetOutlinePath(x, y, width, height); try { info.Graphics.FillPath(Brushes.Shadow, shadowPath); } catch {} }
protected void DrawTypeExpander(RenderInfo info, int x, int y, int width) { var typeExpanderBounds = new Rectangle(x + width - 20, y + 6, 13, 13); #region add type expander bbox var bboxTypeExpander = new BoundingBox(); bboxTypeExpander.Target = this; bboxTypeExpander.Bounds = typeExpanderBounds; bboxTypeExpander.Data = TypeExpanderIdentifier; info.BoundingItems.Add(bboxTypeExpander); #endregion if (Expanded) info.Graphics.DrawImage(Resources.CollapseType, typeExpanderBounds); else info.Graphics.DrawImage(Resources.ExpandType, typeExpanderBounds); }
protected virtual Rectangle DrawText(RenderInfo info, Rectangle renderBounds) { Rectangle textBounds = renderBounds; textBounds.Inflate(-10, -10); var bboxText = new BoundingBox(); bboxText.Bounds = textBounds; bboxText.Target = this; bboxText.Data = TextIdentifier; info.BoundingItems.Add(bboxText); var textBoundsF = new RectangleF(textBounds.X, textBounds.Y, textBounds.Width, textBounds.Height); //info.Graphics.FillRectangle(Brushes.White, textBounds); info.Graphics.DrawString(Text, Fonts.CommentText, Brushes.Black, textBoundsF, StringFormat.GenericTypographic); return renderBounds; }
protected virtual void DrawCustomCaptionInfo(RenderInfo info, int x, int y, int width) {}
protected virtual void DrawTypeKind(RenderInfo info, int x, int y, int width) { var typeKindBounds = new Rectangle(x + Margins.TypeBoxSideMargin, y + 4 + 15, width - Margins.TypeBoxSideMargin*2, 10); string kind = GetTypeKind(); info.Graphics.DrawString(kind, Fonts.TypeKind, Brushes.Black, typeKindBounds, StringFormat.GenericTypographic); }
protected virtual void DrawTypeName(RenderInfo info, int x, int y, int width) { var typeNameBounds = new Rectangle(x + Margins.TypeBoxSideMargin, y + 4, width - Margins.TypeBoxSideMargin*2, 10); Font typeNameFont = GetTypeNameFont(); info.Graphics.DrawString(TypeName, typeNameFont, Brushes.Black, typeNameBounds, StringFormat.GenericTypographic); }
protected int DrawExpandedCaption(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, Brush captionBrush) { int captionHeight = 48; var captionBounds = new Rectangle(x, y, width, captionHeight); #region add caption bbox var bboxCaption = new BoundingBox(); bboxCaption.Bounds = captionBounds; bboxCaption.Target = this; bboxCaption.Data = CaptionIdentifier; info.BoundingItems.Add(bboxCaption); #endregion info.Graphics.SetClip(path); info.Graphics.FillRectangle(captionBrush, captionBounds); info.Graphics.FillRectangle(Brushes.White, x, y + captionHeight, width, height - captionHeight); info.Graphics.DrawLine(Pens.LightGray, x, y + captionHeight, x + width, y + captionHeight); info.Graphics.ResetClip(); return captionHeight; }
protected void DrawCollapsed(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, Brush captionBrush, Pen borderPen) { var captionBounds = new Rectangle(x, y, width, height); var bboxCaption = new BoundingBox(); bboxCaption.Bounds = captionBounds; bboxCaption.Target = this; bboxCaption.Data = CaptionIdentifier; info.BoundingItems.Add(bboxCaption); info.Graphics.FillPath(captionBrush, path); info.Graphics.DrawPath(borderPen, path); }
protected override int DrawExpandedBody(RenderInfo info, int x, int width, int currentY) { foreach (UmlTypeMemberSection section in TypeMemberSections) { currentY = DrawTypeMembers(info, x, currentY, width, section); } return currentY; }
protected abstract int DrawExpandedBody(RenderInfo info, int x, int width, int currentY);
private void DrawPortSelector(RenderInfo info, float x1, float y1, float x2, float y2, object portIdentifier) { #region Add BBox var bbox = new BoundingBox {Target = this, Data = portIdentifier}; var tmp = new Rectangle((int) Math.Min(x1, x2), (int) Math.Min(y1, y2), (int) Math.Abs(x2 - x1), (int) Math.Abs(y2 - y1)); tmp.Inflate(6, 6); bbox.Bounds = tmp; info.BoundingItems.Add(bbox); #endregion if (Selected) { tmp.Inflate(-2, -2); info.Graphics.FillRectangle(Brushes.Selection, tmp); } }
private void DrawLineBackground(RenderInfo info, float x1, float y1, float x2, float y2) { LineDrawer drawLine = (xx1, yy1, xx2, yy2) => { #region Add BBox var bbox = new BoundingBox {Target = this, Data = this}; var tmp = new Rectangle((int) Math.Min(xx1, xx2), (int) Math.Min(yy1, yy2), (int) Math.Abs(xx2 - xx1), (int) Math.Abs(yy2 - yy1)); tmp.Inflate(6, 6); bbox.Bounds = tmp; info.BoundingItems.Add(bbox); #endregion if (Selected) { info.Graphics.DrawLine(Pens.Selection, xx1, yy1, xx2, yy2); } }; RouteLine(drawLine, x1, y1, x2, y2); }
public virtual void DrawPreview(RenderInfo info) { }
public virtual void PreviewDrawBackground(RenderInfo info) { }
public virtual void Draw(RenderInfo info) { }
protected override void DrawCustomSelection(RenderInfo info) { Rectangle renderBounds = Bounds; Rectangle textBounds = renderBounds; textBounds.Inflate(-10, -10); info.Graphics.DrawRectangle(Pens.SelectionOuter, textBounds); }
private int DrawTypeMembers(RenderInfo info, int x, int y, int width, UmlTypeMemberSection section) { var memberCaptionBounds = new Rectangle(x, y, width, 20); #region add section header bbox var bboxGroup = new BoundingBox(); bboxGroup.Bounds = memberCaptionBounds; bboxGroup.Target = this; bboxGroup.Data = section.CaptionIdentifier; info.BoundingBoxes.Add(bboxGroup); #endregion if (SelectedObject == section.CaptionIdentifier && Selected) { info.Graphics.FillRectangle(SystemBrushes.Highlight, memberCaptionBounds); memberCaptionBounds.X += 20; memberCaptionBounds.Width -= 30; memberCaptionBounds.Y += 3; info.Graphics.DrawString(section.Name, Fonts.SectionCaption, SystemBrushes.HighlightText, memberCaptionBounds); } else { Brush sectionCaptionBrush = GetSectionCaptionBrush(); info.Graphics.FillRectangle(sectionCaptionBrush, memberCaptionBounds); memberCaptionBounds.X += 20; memberCaptionBounds.Width -= 30; memberCaptionBounds.Y += 3; info.Graphics.DrawString(section.Name, Fonts.SectionCaption, Brushes.Black, memberCaptionBounds); } #region add section expander bbox var bboxGroupExpander = new BoundingBox(); bboxGroupExpander.Bounds = new Rectangle(x + 4, y + 4, 13, 13); bboxGroupExpander.Target = this; bboxGroupExpander.Data = section.ExpanderIdentifier; info.BoundingBoxes.Add(bboxGroupExpander); #endregion if (section.Expanded) info.Graphics.DrawImage(Resources.CollapseSection, x + 3, y + 3); else info.Graphics.DrawImage(Resources.ExpandSection, x + 3, y + 3); int currentY = y + 20; if (section.Expanded) { StringFormat sf = StringFormat.GenericTypographic; sf.Trimming = StringTrimming.EllipsisCharacter; foreach (UmlTypeMember member in section.TypeMembers) { var memberBounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16); #region add property bbox var memberBBox = new BoundingBox(); memberBBox.Target = this; memberBBox.Bounds = memberBounds; memberBBox.Data = member; info.BoundingBoxes.Add(memberBBox); #endregion var layoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent, currentY, width - 5 - Margins.TypeMemberNameIndent, 16); Font font = GetTypeMemberFont(); if (member == SelectedObject && Selected) { var selectionBounds = new Rectangle(x, currentY, width, 16); info.Graphics.FillRectangle(SystemBrushes.Highlight, selectionBounds); info.Graphics.DrawString(member.DataSource.Name, font, SystemBrushes.HighlightText, layoutBounds, sf); } else { info.Graphics.DrawString(member.DataSource.Name, font, Brushes.Black, layoutBounds, sf); } info.Graphics.DrawImage(member.DataSource.GetImage(), x + 13, currentY); currentY += 16; } var newLayoutBounds = new Rectangle(x + Margins.typeBoxSideMargin + Margins.TypeMemberNameIndent, currentY, width - 5 - Margins.TypeMemberNameIndent, 16); info.Graphics.DrawString("Add new", Fonts.NewTypeMember, Brushes.Blue, newLayoutBounds, sf); var newMemberBBox = new BoundingBox(); newMemberBBox.Target = this; newMemberBBox.Bounds = new Rectangle(x + Margins.typeBoxSideMargin, currentY, width - 20, 16); newMemberBBox.Data = section.AddNewIdentifier; info.BoundingBoxes.Add(newMemberBBox); currentY += 16; } return currentY; }
private static void DrawLine(RenderInfo info, Pen pen, float x1, float y1, float x2, float y2) { LineDrawer drawLine = (xx1, yy1, xx2, yy2) => info.Graphics.DrawLine(pen, xx1, yy1, xx2, yy2); RouteLine(drawLine, x1, y1, x2, y2); }
protected virtual void DrawExpanded(RenderInfo info, GraphicsPath path, int x, int y, int width, int height, Brush captionBrush, Pen borderPen) { int currentY = y + DrawExpandedCaption(info, path, x, y, width, height, captionBrush); currentY = DrawExpandedBody(info, x, width, currentY); info.Graphics.DrawPath(borderPen, path); }
public override void Draw(RenderInfo info) { base.Draw(info); }
public override void DrawBackground(RenderInfo info) { }