The table nod has the following custom draw mechanism:
public override void Draw(IGraphics graphics, RenderOptions options)
{
Rows[1].Height = Bounds.Height - Rows[0].Height - Pen.Width;
base.Draw(graphics, options);
}
public void DrawCell(DrawCellEventArgs e)
{
IGraphics g = e.Graphics;
TableNode.Cell cell = e.Cell;
StringFormat format = cell.TextFormat;
RectangleF r = e.Bounds;
if (e.Cell.Equals(nameCell))
{
float newWidth = CalculateWitdth(e.Cell.Text, Font, r.Width, e.Cell.TextFormat, r.Height);
if (newWidth > r.Width)
{
r.X = r.X - (newWidth - r.Width) / 2;
}
r.Width = newWidth;
g.DrawString(cell.Text,
cell.Font ?? e.Table.Font, Brushes.Black, r, format);
return;
}
g.DrawString(cell.Text, cell.Font ?? e.Table.Font, Brushes.Black, r, format);
}
For a shape node the drawing is the following
public override void Draw(MindFusion.Drawing.IGraphics graphics, RenderOptions options)
{
System.Drawing.Pen pen = Pen.CreateGdiPen(Bounds);
graphics.DrawRectangle(pen, InternalBounds.X, InternalBounds.Y, InternalBounds.Width, InternalBounds.Height);
pen.Dispose();
SizeF textSize = graphics.MeasureString(Text, Font, 0, TextFormat);
textSize.Width += 2;
RectangleF textOutline = new RectangleF(
InternalBounds.X + (InternalBounds.Width - textSize.Width) / 2,
InternalBounds.Y - textSize.Height / 2,
textSize.Width,
textSize.Height);
System.Drawing.Brush brush = new SolidBrush(Color.White);
graphics.FillRectangle(brush, textOutline);
brush.Dispose();
graphics.DrawString(Text, Font, new SolidBrush(TextColor), textOutline, TextFormat);
}
public override void DrawHandles(MindFusion.Drawing.IGraphics graphics, Color color)
{
if (Parent != null)
{
RectangleF rc = Utilities.NormalizeRect(InternalBounds);
InternalUtils.DrawSelHandles(graphics, color, Parent.DisabledHandlesColor, rc, RotationAngle, this.EnabledHandles, Parent.ShowDisabledHandles, this.HandlesStyle, Parent.AdjustmentHandlesSize);
}
}
A shape node in the xml file has the following shape defined:
public static Shape TransactionKind
{
get
{
return new Shape(
Shapes.Ellipse.Outline,
Shapes.Decision.Outline,
null,
FillMode.Winding, "TK");
}
}
and one custom link has the following draw method
Pen pen;
Brush brush;
if (base.ShouldRender())
{
pen = base.Pen.CreateGdiPen();
brush = new SolidBrush(pen.Color);
//determine where the diamond should be drawn at the origin or destination
//depending from where the user start drawing
int diamondPosition = 0;
if (!(this.Origin is ActorRoleView))
{
diamondPosition = ControlPoints.Count - 1;
}
PointF e = ControlPoints[diamondPosition];
RectangleF bounds = new RectangleF(e.X - diamondSize / 2, e.Y - diamondSize / 2, diamondSize, diamondSize);
GraphicsPath path = new GraphicsPath();
path.AddRectangle(bounds);
Matrix r = new Matrix();
r.RotateAt(45, e);
path.Transform(r);
graphics.FillPath(brush, path);
pen.Dispose();
brush.Dispose();
}
else
{
return;
}
base.Draw(graphics, options);