getting x and y coordinates of mouse

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

getting x and y coordinates of mouse

Post by noaksey » Mon Dec 15, 2008 3:55 pm

I've already done a search but couldn't find what I wanted...

I have a cursor tool which I have as 'invisible' (its colour is transparent), so that it can send the X and Y via an Event so that you are constantly updated with the X and Y of the chart (not control).

However I wanted to replace this with a FastCursor (so setting the property to true), but that doesn't like my transparent colour, and so draws the line as black.

Is there any other way of retrieving the X and Y of the mouse in the chart without using a Cursor Tool - I like having the CursorTool because you can retrieve both chart and control X and Y but it slows the chart down a bit with redrawing.

Thanks for any help.

Regards

Chris

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 15, 2008 3:58 pm

Hi Chris,

Yes, you can use TChart's MouseMove event and its e.X and e.Y arguments for getting mouse coordinates.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Mon Dec 15, 2008 4:08 pm

Thanks for the quick reply there Narcís.

I think I've got you, but I was wondering if there was another way to get the X and Y of the chart axis and not the chart (sorry I didn't put that in the first post), like the lowercase 'x' property of CursorChangeEventArgs, but just without using a CursorTool.

Thanks again,
Chris.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Dec 15, 2008 4:31 pm

Hi Chris,

Sorry, I should have understood that :wink:

In that case you can easily obtain axis values like this:

Code: Select all

		void tChart1_MouseMove(object sender, MouseEventArgs e)
		{
			double xVal = tChart1.Axes.Bottom.CalcPosPoint(e.X);
			double yVal = tChart1.Axes.Left.CalcPosPoint(e.Y);
		}
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Tue Dec 16, 2008 9:15 am

Of course; that's what I wanted, cheers!

And is there definitely no way you know of to make a CursorTool (with FastCursor) have a Transparent colour, at all?!

Regards

Chris

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 16, 2008 9:25 am

Hi Chris,

No, this is because when FastCursor=true it uses DrawReversibleLine method for painting as I explained on this thread.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

noaksey
Newbie
Newbie
Posts: 55
Joined: Wed May 23, 2007 12:00 am

Post by noaksey » Tue Dec 16, 2008 10:13 am

No worries Narcís, I just wondered, that's all!

The reason I asked is that I constantly need to calculate the nearest point when you right click or are moving colourbands - I used a combination of the Interpolating Line series method and a slightly modified version of the code I found in this thread, but as I found the nearestpoint tool in the cursor itself I just use that now.
That same cursor tool sends its X and Y (of the axis) back to the form it's in via event, so i've got it doing a few things at once, which is great!
I just noticed that because of it re-drawing it was taking slightly longer to report back the X and Y of the axis, so I was just searching for some minor alternatives - I can't remove the "invisible" cursor though because it's handy in what I need!

Thanks for the help again.

Chris

Post Reply