Resizing a Rectangle Tool

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Resizing a Rectangle Tool

Post by JayG » Thu Dec 27, 2007 10:48 pm

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

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Post by Marc » Fri Dec 28, 2007 9:02 am

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
Steema Support

JayG
Newbie
Newbie
Posts: 71
Joined: Mon Sep 04, 2006 12:00 am

Resizing a Rectangle Tool

Post by JayG » Mon Dec 31, 2007 5:38 pm

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

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

Post by Narcís » Wed Jan 02, 2008 10:08 am

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;
		}
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

Post Reply