public void ChartOverlayPainter(object sender, ChartPaintEventArgs e)
{
// Don't want to print instructions to file
if (this.PrintMode) return;
var g = e.Graphics;
var chart = e.Chart;
// Demo: Static billboards begin -----------------------------------
// Demonstrate how to draw static billboards
// "push matrix" -- save our transformation matrix
e.Chart.BeginBillboardMode(e.Graphics);
// draw mouse command instructions
int margin = 300;
int left = 20;
var color = chart.HeaderFormat.Color;
StringBuilder builder = new StringBuilder();
builder.AppendLine("THIS IS DRAWN BY A CUSTOM OVERLAY PAINTER TO SHOW DEFAULT MOUSE COMMANDS.");
builder.AppendLine("*******************************************************************************************************");
builder.AppendLine("Left Click - Select task and display properties in PropertyGrid");
builder.AppendLine("Left Mouse Drag - Change task starting point");
builder.AppendLine("Right Mouse Drag - Change task duration");
builder.AppendLine("Middle Mouse Drag - Change task complete percentage");
builder.AppendLine("Left Doubleclick - Toggle collaspe on task group");
builder.AppendLine("Right Doubleclick - Split task into task parts");
builder.AppendLine("Left Mouse Dragdrop onto another task - Group drag task under drop task");
builder.AppendLine("Right Mouse Dragdrop onto another task part - Join task parts");
builder.AppendLine("SHIFT + Left Mouse Dragdrop onto another task - Make drop task precedent of drag task");
builder.AppendLine("ALT + Left Dragdrop onto another task - Ungroup drag task from drop task / Remove drop task from drag task precedent list");
builder.AppendLine("SHIFT + Left Mouse Dragdrop - Order tasks");
builder.AppendLine("SHIFT + Middle Click - Create new task");
builder.AppendLine("ALT + Middle Click - Delete task");
builder.AppendLine("Left Doubleclick - Toggle collaspe on task group");
var size = g.MeasureString(builder.ToString(), e.Chart.Font);
var background = new Rectangle(left, chart.Height - margin, (int)size.Width, (int)size.Height);
background.Inflate(10, 10);
g.FillRectangle(new System.Drawing.Drawing2D.LinearGradientBrush(background, Color.LightYellow, Color.Transparent, System.Drawing.Drawing2D.LinearGradientMode.Vertical), background);
g.DrawRectangle(Pens.Brown, background);
g.DrawString(builder.ToString(), chart.Font, color, new PointF(left, chart.Height - margin));
// "pop matrix" -- restore the previous matrix
e.Chart.EndBillboardMode(e.Graphics);
// Demo: Static billboards end -----------------------------------
}