Page 1 of 1
PopupMenu for ColorLine
Posted: Thu May 03, 2007 9:02 am
by 9640311
I am using ColorLine tool and would like to be able to envoke a popup menu when user right clicks it. The popup menu will have line formatting settings and "Remove" items. Can you please advise me how to do that? Color line seem to have no onclick event.
Posted: Thu May 03, 2007 10:01 am
by 9348258
Hi Stratadat
Yes, the colorLine hasn't this event, you should to use the event of the chart and then calculate if the colorLine has been click. You can do something similar, as below code:
Code: Select all
private bool Clicked(int x, int y)
{
int tmp = colorLine1.Axis.Horizontal ? x : y;
int ClickTolerance = 3;
if (Math.Abs(tmp - colorLine1.Axis.CalcPosValue(colorLine1.Value)) < ClickTolerance)
{
Rectangle r = tChart1.Chart.ChartRect;
return colorLine1.Axis.Horizontal ? (y >= r.Y) && (y <= r.Bottom) : (x >= r.X) && (x <= r.Right);
}
else return false;
}
private void tChart1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right && Clicked(e.X, e.Y))
tChart1.Text = "Show Popup";
else tChart1.Text = "Not show Popup";
}