Zoom to entities
Posted: 01 Jul 2008, 16:12
Hello,
I want to zoom on an array of entity.
I have already made an union of each boxes of all entites to get the rectangle to zoom into but i don't know how to put these coordinates to zoom on it.
The best result is with PreviousPosition property :
but the result is not good.
Where to set theses coordinates to do a global zoom of the entities ?
Thank you.
I want to zoom on an array of entity.
I have already made an union of each boxes of all entites to get the rectangle to zoom into but i don't know how to put these coordinates to zoom on it.
The best result is with PreviousPosition property :
Code: Select all
internal static void zoomOnEntity(MyMapDisplay map, CADEntity[] entity)
{
if(entity.Length == 0)
return;
DRect rect = entity[0].Box;
RectangleF rectangleF;
foreach(CADEntity en in entity)
{
rectangleF = RectangleF.Union(new RectangleF((float)rect.left, (float)rect.top, (float)rect.Width, (float)rect.Height), new RectangleF((float)en.Box.left, (float)en.Box.top, (float)en.Box.Width, (float)en.Box.Height));
rect = new DRect(rectangleF.X, rectangleF.Y, 0, rectangleF.Right, rectangleF.Bottom, 0);
}
Point p = map.CADPicture.cadImage.GetPoint(new DPoint(rect.left + rect.Width / 2, rect.top + rect.Height / 2, 0), map.CADPicture.ImageRectangleF);
map.CADPicture.PreviousPosition = new PointF((float)p.X, (float)p.Y);
map.CADPicture.ImageScale = 20.0f;
map.CADPicture.Refresh();
}
Where to set theses coordinates to do a global zoom of the entities ?
Thank you.