We added the else block below to the OnMouseDown method
public override void OnMouseDown (MouseEventArgs mouseevent)
{
Point2D mousepos = new Point2D();
mousepos.SetLocation(mouseevent.X, mouseevent.Y);
base.OnMouseDown(mouseevent);
ChartPlot selectedPlot = (ChartPlot) GetSelectedPlotObj();
if (selectedPlot != null)
{
.
. // Original code, leave in place
.
}
else
{
Point2D physcoord = currentInstance.pTransform0.ConvertCoord(PHYS_POS, mousepos, DEV_POS);
stockpanel.SetChartObjScale(currentInstance.pTransform0);
stockpanel.SetLocation( mousepos, ChartObj.DEV_POS);
// Looking to the original arrays, because we just have the selectedindex,
ChartCalendar x = new ChartCalendar();
x.SetCalendarMsecs((long) physcoord.X);
marker = new Marker(currentInstance.pTransform0,ChartObj.MARKER_VLINE,x.GetCalendarMsecs(),0,1,ChartObj.PHYS_POS);
TimeLabel timelabel = new TimeLabel(currentInstance.pTransform0, x, ChartObj.TIMEDATEFORMAT_24HMS);
stockpanel.SetTextString(timelabel.GetTextString());
stockpanel.SetChartObjEnable(ChartObj.OBJECT_ENABLE);
// Graphics g2 = GetToolTipGraphics();
Graphics g2 = (Graphics) currentInstance.CreateGraphics();
// Precalculates the text bounding box so that the size is
// known before it is drawn
stockpanel.PreCalcTextBoundingBox(g2);
Rectangle2D boundingbox = stockpanel.GetTextBox();
// Reposition tooltip text box if top of box near top of graph window
// You can do the same thing for all four sides of the graph window
if ( (mousepos.GetY() - boundingbox.GetHeight()) < 1)
{
mousepos.SetLocation(mousepos.GetX(), mousepos.GetY() + boundingbox.GetHeight());
stockpanel.SetLocation( mousepos, ChartObj.DEV_POS);
}
// Draws the tooltip text panel to the chart graphics context
stockpanel.SetTextNudge(10, -10);
stockpanel.Draw(g2);
marker.Draw(g2);
if (g2 != null)
g2.Dispose();
}