Page 1 of 1
Resizing a Rectangle Tool
Posted: Thu Dec 27, 2007 10:48 pm
by 9792387
I am using TeeChart v3 and VB 2005 Express.
I have a Rectangle Tool on one of my charts. Is there a way to get the cursor to change to the double arrow (for resizing the rectangle) when the cursor is farther away from the border of the rectangle? I thought I would try changing the tool's CLickTolerance property, but that is a constant.
Jay
Posted: Fri Dec 28, 2007 9:02 am
by Marc
Hello Jay,
You could set it independently of the tool, using the location parameters and tolerance you decide ...
Eg. This modifies the cursor when within 20 pixels of right and bottom of rectangle:
Code: Select all
Cursor origCursor;
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
if ((Math.Abs(e.X - (rectangleTool1.Left + rectangleTool1.Width)) < 20)
&& (Math.Abs(e.Y - (rectangleTool1.Top + rectangleTool1.Height)) < 20))
this.Cursor = Cursors.SizeNS;
else
this.Cursor = origCursor;
}
private void Form1_Load(object sender, EventArgs e)
{
origCursor = tChart1.Cursor;
}
Regards,
Marc Meumann
Resizing a Rectangle Tool
Posted: Mon Dec 31, 2007 5:38 pm
by 9792387
Hello Marc,
I should have been more specific. I don't want to just change the cursor when the mouse pointer is farther away from the rectangle, I want the resizing to work from farther away also.
Jay
Posted: Wed Jan 02, 2008 10:08 am
by narcis
Hi Jay,
In that case you should do something like this:
Code: Select all
Cursor origCursor;
Boolean resize;
private void tChart1_MouseMove(object sender, MouseEventArgs e)
{
int tmpX = e.X - (rectangleTool1.Left + rectangleTool1.Width);
int tmpY = e.Y - (rectangleTool1.Top + rectangleTool1.Height);
if ((Math.Abs(tmpX) < 20) && (Math.Abs(tmpY) < 20))
{
this.Cursor = Cursors.SizeNS;
if (resize)
{
rectangleTool1.Width += tmpX;
rectangleTool1.Height += tmpY;
}
}
else
this.Cursor = origCursor;
}
private void Form1_Load(object sender, EventArgs e)
{
origCursor = tChart1.Cursor;
resize = false;
}
private void tChart1_MouseDown(object sender, MouseEventArgs e)
{
resize = true;
}
private void tChart1_MouseUp(object sender, MouseEventArgs e)
{
resize = false;
}