Piersh,
Code works well with MouseUp and the coordinates are displayed in the Output window successfully using the Print statement.
I have tried to add the code (highlighted in bold) to the use these coordinates to draw a line between the clicked on areas, but this does not work - I get a "Ninja has detected a problem ..." error when I click. I have also tried to replace X and Y with static values and this also generates the same error. Do I have my drawline in the right place, Am I doing something stupid? Any suggestions would be most appreciated.
void ChartControl_MouseMove (object sender, System.Windows.Forms.MouseEventArgs e)
{
eventCount ++;
double right = _chartBounds.Right - this.ChartControl.BarMarginRight - this.ChartControl.BarWidth - this.ChartControl.BarSpace / 2;
double bottom = _chartBounds.Bottom;
double x = right - e.X;
double y = bottom - e.Y;
int iBar = this.LastVisibleBar + (int) Math.Round (x / this.ChartControl.BarSpace);
double price = _min + y * (_max - _min) / _chartBounds.Height;
if(eventCount == 1)
{
x1 = iBar;
y1 = price; // y1-axis;
}
else if(eventCount == 2)
{
x2 = iBar;
y2 = price; // y2-axis;
eventCount = 0;
}
profitLine = Math.Max(y1, y2) - Math.Min(y1, y2);
midPoint = Math.Min(y1, y2) + profitLine /2;
string str = (profitLine * 10000).ToString("f0");
Print(y1 + "::" + x1 + " , " + y2 + "::" + x2);
if(Math.Min(y1,y2) > 0)
{
DrawLine("tag" + y1, 10, y1, 5, y2, Color.LimeGreen,DashStyle.Solid, 2);
// DrawLine("tag" + y1, 10, 1.5090, 5, 1.4456, Color.LimeGreen,DashStyle.Solid, 2);
// DrawText("tag2", str, 10, midPoint, Color.Black);
}
}
Comment