Page 1 of 1

detect cursortool and remove it

Posted: Thu Apr 26, 2007 12:23 pm
by 9788246
hi.. In my Application, the user can add 2 vertical cursortools to a teechart per right mouseclick on the chart in order to show the interval between these 2 cursortools.
The cursortools can be moved (right/left) with the mouse. But because of having a chart which has a lot of X points, it is not practical to use this method (Example: At first: show [15,100] then show [500,550] Actually i use datetime as x values).

So the user must be able to detect the cursortool with mouse and remove it, so that he can add it later again.
I tried to do:

Code: Select all

 private void tChartAll_MouseClick(object sender, MouseEventArgs e)
        {
           ...
            if (e.Button == MouseButtons.Right)
            {
               if(delta1.XValue == tChartAll.Chart.Axes.Bottom.CalcPosPoint(e.X))
               {
                 remove delta1...
               }
....
But it dosent work, althogh the mouse pointer is on the cursortool.
Any Idea? Thanks...

Posted: Thu Apr 26, 2007 12:37 pm
by 9788246
Actually I solved this problem with using a contextmenu. But I would like to learn, whether it is possible to solve it with detecting the cursortool.

Posted: Thu Apr 26, 2007 2:20 pm
by narcis
Hi MU,

Yes, this is possible. You can do something like this:

Code: Select all

		private void tChart1_MouseClick(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Right)
				for (int i = 0; i < tChart1.Tools.Count; i++)
					if ((tChart1.Tools[i] is Steema.TeeChart.Tools.CursorTool) &&
						(((Steema.TeeChart.Tools.CursorTool)tChart1.Tools[i]).Clicked(e.X, e.Y) != Steema.TeeChart.Tools.CursorClicked.None))
					{
						tChart1.Tools.Remove(tChart1.Tools[i]);
					}
		}