zoom and position in CADPictureBox

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
lulu
Posts: 25
Joined: 12 Nov 2009, 19:55

zoom and position in CADPictureBox

Post by lulu » 13 Nov 2009, 12:19

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

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: zoom and position in CADPictureBox

Post by support » 24 Nov 2009, 15:09

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

lulu
Posts: 25
Joined: 12 Nov 2009, 19:55

Re: zoom and position in CADPictureBox

Post by lulu » 09 Feb 2010, 17:24

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!

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: zoom and position in CADPictureBox

Post by support » 12 Feb 2010, 11:49

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.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

lulu
Posts: 25
Joined: 12 Nov 2009, 19:55

Re: zoom and position in CADPictureBox

Post by lulu » 16 Feb 2010, 12:10

It's perfect!
Thank you Alexander!

lulu
Posts: 25
Joined: 12 Nov 2009, 19:55

Re: zoom and position in CADPictureBox

Post by lulu » 17 Nov 2011, 15:47

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.

support
Posts: 3272
Joined: 30 Mar 2005, 11:36
Contact:

Re: zoom and position in CADPictureBox

Post by support » 23 Nov 2011, 13:41

Hello Lulu.
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

Post Reply