Drawing next to cursor

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Agrilink
Newbie
Newbie
Posts: 38
Joined: Thu Feb 02, 2006 12:00 am

Drawing next to cursor

Post by Agrilink » Thu May 04, 2006 7:02 am

Hi,

Whenever the user moves the cursor, I want to display some text in a standard position next to the cursor, say at 3/4 the height of the cursor.

So I want to get the location of the cursor, but using XYalue and YValue doesn't work.

What alternative properties are there so i can set the x and y coordinates of the TextOut method in the AfterDraw event?

Thanks.

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

Post by Narcís » Thu May 04, 2006 9:39 am

Hi Agrilink,

You can use TeeChart's MouseMove event to get the cursor coordinates and do something like:

Code: Select all

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      g.TextOut(X, Y-10, "My Custom Text");
    }

    private int X, Y;

    private void tChart1_MouseMove(object sender, MouseEventArgs e)
    {
      X = e.X;
      Y = e.Y;

      tChart1.Invalidate();
    }
If you want that feature for a cursor tool you can use its Change event to get the coordinates and something like this:

Code: Select all

    private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
      System.Drawing.Rectangle Rect = tChart1.Chart.ChartRect;

      Y=(Rect.Height / 4) * 3;
      g.TextOut(X, Y, "My Custom Text");
    }

    private int X,Y;

    private void cursorTool1_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
    {
      X = e.x;
    }
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

Agrilink
Newbie
Newbie
Posts: 38
Joined: Thu Feb 02, 2006 12:00 am

Post by Agrilink » Thu May 04, 2006 11:12 pm

Hi Narcis,

Thanks great, however one problem. The cursor change event doesn't fire when I move the cursor with the keyboard, only with the mouse?

Why would that be?

Thanks.

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

Post by Narcís » Fri May 05, 2006 10:26 am

Hi Agrilink,

Yes, that's right but you can easily solve it by adding the line below to the KeyDown event:

Code: Select all

      X = tChart1.Axes.Bottom.CalcPosValue(cursorTool1.XValue);
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

Agrilink
Newbie
Newbie
Posts: 38
Joined: Thu Feb 02, 2006 12:00 am

Post by Agrilink » Sat May 06, 2006 2:16 am

Thanks very much Narcis. Your help is much appreciated.

Post Reply