Drawing and moving the image

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Drawing and moving the image

Post by roman » 25 Nov 2016, 16:48

Hello,

I'd need to implement the following task:
A User draws on an large image (red). The Image is zoomed (black) and the user wants to draw a polyline(blue) which is started inside the clip rectangle with the given zoom, but the end is outside the visible area.
The user needs to move the clip rectangle but the line should still exist in "edit mode". At the moment the line is removed when the zoom changes.

thank you for your help.
Roman

Image

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

Re: Drawing and moving the image

Post by support » 29 Nov 2016, 21:14

Hello Roman,

The drawing tools are implemented through the EntitiesCreator class which is defined under CADImport.Professional namespace. You should pay attention to the EntitiesCreator.Disable method, it terminates the usage of a drawing tool and removes the drawn object. It seems that you call this method in your zooming in/out routines.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Drawing and moving the image

Post by roman » 30 Nov 2016, 09:41

Hello Mikhail,

I didn't find the EntitiesCreator.Disable method where you mentioned, but after some research inside the CADEditor I found the code I postet at the bottom of this post (taken form CadEditorDemo)

Inside the method below i found this part.

Code: Select all

if ((!this.clipRectangle.Enabled) && (!this.CreateNewEntity))
                {
                    LeftImagePosition -= (cX - e.X);
                    TopImagePosition -= (cY - e.Y);
                    cadPictBox.Invalidate();
                }
It prevents moving the drawing when CreateNewEntity is true. Simply removing the (!this.CreateNewEntity) didn't work because the traces were drawn not where the traces should be...
Thank you for your help,
Roman

Code: Select all

private void cadPictBox_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (cadImage == null)
                return;
            if (!this.cadPictBox.Focused)
            {
                this.cadPictBox.Focus();
                this.cadPictBox.Invalidate();
            }
            if ((!stopSnap) && (this.cadPictBox.ClientRectangle.Contains(e.X, e.Y)))
            {
                RectangleF tmpRect = ImageRectangleF;
                cadImage.DrawSnapTrace(e.X, e.Y, this.cadPictBox, tmpRect);
            }
            else
            {
                this.cadImage.RefreshSnapTrace(this.cadPictBox);
                this.stopSnap = false;
            }
            
            if (detMouseDown)
            {

                if (e.Button != MouseButtons.Right)
                {
                    if (ChangeEntityOnMouseMove(new Point(e.X, e.Y)))
                        return;

                }

                if ((!this.clipRectangle.Enabled) && (!this.CreateNewEntity))
                {
                    LeftImagePosition -= (cX - e.X);
                    TopImagePosition -= (cY - e.Y);
                    cadPictBox.Invalidate();
                }
                cX = e.X;
                cY = e.Y;
            }
            
            PreviousPosition = new PointF(e.X, e.Y);
            DPoint vPt = GetRealPoint(e.X, e.Y, true);
            stBar.Panels[2].Text = string.Format("{0} : {1} : 0", vPt.X, vPt.Y);
        }

roman
Posts: 43
Joined: 11 Aug 2011, 11:43

Re: Drawing and moving the image

Post by roman » 31 Jan 2017, 09:08

Hello,

still no answer?

Post Reply