Page 1 of 1
zoom and position in CADPictureBox
Posted: 13 Nov 2009, 12:19
by lulu
I have a CadImage in a CADPictureBox. how can I to center the image in a determined point with a suitable level of zoom, without necessarily owing it to reload?
thanks
Re: zoom and position in CADPictureBox
Posted: 24 Nov 2009, 15:09
by support
Hello.
This depends on where your determined point located and which zoom level is suitable for your task. For example you can use such code sample within our demo:
Code: Select all
...
this.cadImage.IsWithoutMargins = true;
this.cadImage.BorderSize = 0;
FPoint fpt = new FPoint(100, 100, 0);
ImageScale = 2;
LeftImagePosition = fpt.X;
TopImagePosition = fpt.Y;
visibleArea = cadPictBox.Size;
this.cadPictBox.Invalidate();
FPoint determines left-top corner of the image, ImageScale determines scale factor. No need to reload file. However if you want to create your own form, you will need to define on your form all fields, properties and methods that related to zoom and change image position.
Alexander.
Re: zoom and position in CADPictureBox
Posted: 09 Feb 2010, 17:24
by lulu
Hello Alexander,
I have combined this code to the click of a button. To the first click however the position is wrong! The correct position is reached only to the second click! Would you know me to explain the reason?
Thank you!
Re: zoom and position in CADPictureBox
Posted: 12 Feb 2010, 11:49
by support
Hello.
The position after first click will be correct if value set to
ImagePreviousScale property:
Code: Select all
this.cadImage.IsWithoutMargins = true;
this.cadImage.BorderSize = 0;
FPoint fpt = new FPoint(100, 100, 0);
ImageScale = 2;
ImagePreviousScale = 2;
LeftImagePosition = fpt.X;
TopImagePosition = fpt.Y;
visibleArea = cadPictBox.Size;
visibleArea.Width = visibleArea.Height * (float)(cadImage.AbsWidth / cadImage.AbsHeight);
this.cadPictBox.Invalidate();
Alexander.
Re: zoom and position in CADPictureBox
Posted: 16 Feb 2010, 12:10
by lulu
It's perfect!
Thank you Alexander!
Re: zoom and position in CADPictureBox
Posted: 17 Nov 2011, 15:47
by lulu
Hi Alexander,
I have a little problem with the scrollbars of my CADPictureBox. After positioning and centering changes, scrollbars remain in the old position (corresponding at previous conditions of the image).
Then, if I move them, the image in my CADPictureBox doesn't respect actual position.
Thanks,
Lulu.
Re: zoom and position in CADPictureBox
Posted: 23 Nov 2011, 13:41
by support
Hello Lulu.
Just use cadPictBox.SetVirtualSizeNoInvalidate(cadPictBox.Size) instead the cadPictBox.Invalidate(). This replacement will result in correct scrollbars position.
Alexander.