Page 1 of 1
Drawing next to cursor
Posted: Thu May 04, 2006 7:02 am
by 9640166
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.
Posted: Thu May 04, 2006 9:39 am
by narcis
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;
}
Posted: Thu May 04, 2006 11:12 pm
by 9640166
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.
Posted: Fri May 05, 2006 10:26 am
by narcis
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);
Posted: Sat May 06, 2006 2:16 am
by 9640166
Thanks very much Narcis. Your help is much appreciated.