zoom and position in CADPictureBox
Moderators: SDS, support, admin
zoom and position in CADPictureBox
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
thanks
Re: zoom and position in CADPictureBox
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: 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.
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();
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: zoom and position in CADPictureBox
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!
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
Hello.
The position after first click will be correct if value set to ImagePreviousScale property:
Alexander.
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();
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: zoom and position in CADPictureBox
It's perfect!
Thank you Alexander!
Thank you Alexander!
Re: zoom and position in CADPictureBox
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.
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
Hello Lulu.
Just use cadPictBox.SetVirtualSizeNoInvalidate(cadPictBox.Size) instead the cadPictBox.Invalidate(). This replacement will result in correct scrollbars position.
Alexander.
Just use cadPictBox.SetVirtualSizeNoInvalidate(cadPictBox.Size) instead the cadPictBox.Invalidate(). This replacement will result in correct scrollbars position.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support