private float DrawHeadBackground(bool isSelected, Graphics graphics, Color color,
float x, float y, float width, float height, float radius, ArrowType arrowType, bool dashedLine, bool fill)
{
float additionalOffset = arrowType != ArrowType.None ? GetArrowSize(height) : 0;
width += additionalOffset;
var oldMode = graphics.SmoothingMode;
graphics.SmoothingMode = SmoothingMode.AntiAlias;
try
{
// shade
if (fill)
using (var shadePath = CreateRoundRectPath(x + 1, y + 1, width, height, radius))
{
var shadeBrush = isSelected ? Brushes.Black : Brushes.Gray;
graphics.FillPath(shadeBrush, shadePath);
}
using (var forePath = CreateRoundRectPath(x, y, width, height, radius))
{
Color fillColor = Lerp(color, Color.White, 0.92F);
if (fill)
using (var fillBrush = new LinearGradientBrush(new RectangleF(x, y, width, height), fillColor, Lerp(fillColor, Color.White, 0.9F), 90))
graphics.FillPath(fillBrush, forePath);
else if (isSelected)
graphics.FillPath(Brushes.White, forePath);
// frame
using (var pen = new Pen(Lerp(color, Color.White, 0.83F)))
{
if (dashedLine)
pen.DashPattern = dashPattern;
graphics.DrawPath(pen, forePath);
}
// arrow if the head is the current branch
if (arrowType != ArrowType.None)
DrawArrow(graphics, x, y, height, color, arrowType == ArrowType.Filled);
}
}
finally
{
graphics.SmoothingMode = oldMode;
}
return additionalOffset;
}