Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
ChingYen  
#1 Posted : Tuesday, April 26, 2011 3:09:01 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Hi,

Under MultilayerViewer, may I know how "resizing" is being detected?
We can't use the method of "Mouse Up" to check the previous size and current size as we want "resizing" to be detected while it's being "DRAGGING"/"Resizing".

Please advise.
ChingYen  
#2 Posted : Tuesday, April 26, 2011 3:45:39 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
ChingYen wrote:
Hi,

Under MultilayerViewer, may I know how "resizing" is being detected?
We can't use the method of "Mouse Up" to check the previous size and current size as we want "resizing" to be detected while it's being "DRAGGING"/"Resizing".

Please advise.


Hi, we are now trying to implement this in the mousemove to detect if it's moving the object or resizing the object, but seems like it's pretty confusing.
The method we did was checking if all 4 corner object bound are the same or all not the same, then it's consider "moving", if there are at >= 1 and < 4 point remain the same, then it will be consider "resizing". But, somehow, we found that, for a very minor period of during resize, it will be detected moving (While we keep on resizing without mouseup). On the other hand, the method that we using will not be valid anymore when we are resizing in proportional (where user can drag the center of the line, and the object drag to bigger from the center).

Kindly advise..... perhaps there are some other easier and firm way to detect if the object is being resizing or moving. Thanks.
ChingYen  
#3 Posted : Wednesday, April 27, 2011 4:54:47 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
anyone could help please???
Dmitry.Obukhov  
#4 Posted : Thursday, April 28, 2011 3:37:13 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Ching-Yen,

Sorry for the delay.

I assume you should count the center coordinates to use it as additional parameter to check. If four corner coordinates and the center are changed, it will mean moving. In case the center is not changed, such process will be resizing.

If you share your code snippet you use now, I will be able to check it.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
ChingYen  
#5 Posted : Thursday, April 28, 2011 9:52:44 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Hi,

Thanks for the reply.
Code:

        private System.Drawing.PointF[] GetSelectedObjectsBound()
        {
            System.Drawing.PointF[] gsobSelectedPoints = null;
            if (_workingMultilayerViewer.CurrentDesigner.VObjects.Count() == 1)
            {
                gsobSelectedPoints = GetTransformedCornerPoints((Aurigma.GraphicsMill.WinControls.VObject)_workingMultilayerViewer.CurrentDesigner.VObjects[0]);
            }
            else
            {
                var mvmvPointList = new List<PointF>();
                foreach (Aurigma.GraphicsMill.WinControls.VObject swTmpVObject2 in _workingMultilayerViewer.CurrentDesigner.VObjects)
                {
                    // Get Big Size
                    System.Drawing.PointF[] swObjBound = GetTransformedCornerPoints(swTmpVObject2);
                    mvmvPointList.AddRange(swObjBound);
                }
                System.Drawing.PointF[] mvmvPoints = mvmvPointList.ToArray();
                General mvmvGeneral = new General();
                float mvmvLeastX = mvmvGeneral.GetLeastX(mvmvPoints);
                float mvmvLeastY = mvmvGeneral.GetLeastY(mvmvPoints);
                float mvmvMostX = mvmvGeneral.GetMaxX(mvmvPoints);
                float mvmvMostY = mvmvGeneral.GetMaxY(mvmvPoints);
                gsobSelectedPoints = new PointF[] { new PointF(mvmvLeastX, mvmvLeastY), new PointF(mvmvMostX, mvmvLeastY), new PointF(mvmvMostX, mvmvMostY), new PointF(mvmvLeastX, mvmvMostY) };
            }

            return gsobSelectedPoints;
        }


Code:

       private ResizeVObjectInfo GetVObjectResizeMode(System.Drawing.PointF[] selectVObjectPoints)
        {

            ResizeVObjectInfo gvrmObj = new ResizeVObjectInfo();

            Boolean gvrmResized = false;

            gvrmResized = false;
            Boolean gvrmConstantPoint1 = false;
            Boolean gvrmConstantPoint2 = false;
            Boolean gvrmConstantPoint3 = false;
            Boolean gvrmConstantPoint4 = false;

            if ((Math.Round(_selectItemPoints[0].X, 3) == Math.Round(selectVObjectPoints[0].X, 3)) && (Math.Round(_selectItemPoints[0].Y, 3) == Math.Round(selectVObjectPoints[0].Y, 3)))
            {
                gvrmResized = true;
                gvrmConstantPoint1 = true;
            }

            if ((Math.Round(_selectItemPoints[1].X, 3) == Math.Round(selectVObjectPoints[1].X, 3)) && (Math.Round(_selectItemPoints[1].Y, 3) == Math.Round(selectVObjectPoints[1].Y, 3)))
                {
                    gvrmResized = true;
                    gvrmConstantPoint2 = true;
                }

            if ((Math.Round(_selectItemPoints[2].X, 3) == Math.Round(selectVObjectPoints[2].X, 3)) && (Math.Round(_selectItemPoints[2].Y, 3) == Math.Round(selectVObjectPoints[2].Y, 3)))
                {
                    gvrmResized = true;
                    gvrmConstantPoint3 = true;
                }

            if ((Math.Round(_selectItemPoints[3].X, 3) == Math.Round(selectVObjectPoints[3].X, 3)) && (Math.Round(_selectItemPoints[3].Y, 3) == Math.Round(selectVObjectPoints[3].Y, 3)))
                {
                    gvrmResized = true;
                    gvrmConstantPoint4 = true;
                }

                if (gvrmConstantPoint1 && gvrmConstantPoint2 && gvrmConstantPoint3 && gvrmConstantPoint4)
                {
                    gvrmResized = false;
                }
                else
                {
                    if (!gvrmResized)
                    {
                        _selectItemPoints = selectVObjectPoints;
                    }
                }

                if (gvrmResized)
                {
                    if (gvrmConstantPoint1)
                    {
                        if (gvrmConstantPoint2)
                        {
                            // Resize height to bottom or top (stupid drag till flip)
                            gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[2].X, selectVObjectPoints[2].Y) };
                            //mvmvResizeHeight = true;
                            gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Bottom;
                            //_statusBar.Text = "Dragging to bottom";
                        }
                        else
                        {
                            if (gvrmConstantPoint4)
                            {
                                // Resize width to right or left (stupid drag till flip)
                                gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[1].X, selectVObjectPoints[1].Y) };
                                //mvmvResizeWidth = true;
                                gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Right;
                                //_statusBar.Text = "Dragging to right";
                            }
                            else
                            {
                                // Resize height and width to right & bottom
                                gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[2].X, selectVObjectPoints[2].Y) };
                                //mvmvResizeWidth = true;
                                //mvmvResizeHeight = true;
                                gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.BottomRight;
                                //_statusBar.Text = "Dragging to right + bottom";
                            }

                        }

                    }
                    else
                    {
                        if (gvrmConstantPoint2)
                        {
                            if (gvrmConstantPoint3)
                            {
                                // Resize width to left or right (stupid drag till flip)
                                gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
                                //mvmvResizeWidth = true;
                                gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Left;
                                //_statusBar.Text = "Dragging to left";
                            }
                            else
                            {
                                // Resize height and width to left & bottom
                                gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[3].X, selectVObjectPoints[3].Y) };
                                //mvmvResizeWidth = true;
                                //mvmvResizeHeight = true;
                                gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.BottomLeft;
                                //_statusBar.Text = "Dragging to left + bottom";
                            }
                        }
                        else
                        {
                            if (gvrmConstantPoint3)
                            {
                                if (gvrmConstantPoint4)
                                {
                                    // resize height to top
                                    gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
                                    //mvmvResizeHeight = true;
                                    gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.Top;
                                    //_statusBar.Text = "Dragging to top";
                                }
                                else
                                {
                                    // resize height and width to top & left
                                    gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[0].X, selectVObjectPoints[0].Y) };
                                    //mvmvResizeWidth = true;
                                    //mvmvResizeHeight = true;
                                    gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.TopLeft;
                                    //_statusBar.Text = "Dragging to top + left";
                                }
                            }
                            else
                            {
                                //resize height and with to top & right
                                gvrmObj.Points = new PointF[] { new PointF(selectVObjectPoints[1].X, selectVObjectPoints[1].Y) };
                                gvrmObj.ResizeMode = VObjectResize.VObjectResizeMode.TopRight;
                                //mvmvResizeWidth = true;
                                //mvmvResizeHeight = true;
                                //_statusBar.Text = "Dragging to top + right";
                            }
                        }
                    }
                }
                return gvrmObj;
        }



// Snip code inside MouseMove for MultilayerViewer.
Code:

System.Drawing.PointF[] mvmvSelectedPoints = GetSelectedObjectsBound();
ResizeVObjectInfo mvmvResizeObjInfo = new ResizeVObjectInfo();

if (_selectItemPoints == null)
{
  _selectItemPoints = GetSelectedObjectsBound();
}

mvmvResizeObjInfo = GetVObjectResizeMode(mvmvSelectedPoints);

_statusbar.text = mvmvResizeObjInfo.ResizeMode.ToString();



This code works for most cases beside when the resize is in porpotional and user resize from left, right, top or bottom. But, if we keep on dragging to resize, on and off, we will see the action will actually detected "none" (no resize) for a short period..
Alex Kon  
#6 Posted : Monday, May 2, 2011 9:50:00 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello Ching-Yen,

Do you need to distinguish only drag/resize actions? Or you need to determine whether it is resized or rotated, or resized or skewed?

For the first case - I wonder why not to use object size instead of point coordinates?
As for the second case - skew transform will be treated like resize by your code.

To add this functionality I can recommend you to change source code of VectorObjects module. Take a look at VectorObjects\Objects\ControlPoints\GenericControlPointsProvider.cs. It has such methods as DragCornerSizePoint(...) and DragMiddleSizeSizePoint(...) where you can inject event to react object resize.

ChingYen  
#7 Posted : Tuesday, May 3, 2011 12:01:09 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Alex Kon wrote:
Hello Ching-Yen,

Do you need to distinguish only drag/resize actions? Or you need to determine whether it is resized or rotated, or resized or skewed?

For the first case - I wonder why not to use object size instead of point coordinates?
As for the second case - skew transform will be treated like resize by your code.

To add this functionality I can recommend you to change source code of VectorObjects module. Take a look at VectorObjects\Objects\ControlPoints\GenericControlPointsProvider.cs. It has such methods as DragCornerSizePoint(...) and DragMiddleSizeSizePoint(...) where you can inject event to react object resize.



Dear Alex,

Thanks for the reply. We just need to know it's either "move" or "resize" as Skewed are not allowed, and which point is being drag.

The main target of implement this is for "Snap to Grid" usage. Something like in VS, when we grade a label, when the width is same or almost the same as the above object, it will show grid, and when user mouse up, it will be "snap" to the suggested place.
Alex Kon  
#8 Posted : Tuesday, May 3, 2011 12:32:39 AM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
OK, and what about rotation? Why do you mention only resize and drag? If there are only two options - you can easily distinguish one from another. Drag doesn't change size of the image and resize does.
ChingYen  
#9 Posted : Tuesday, May 3, 2011 1:34:42 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Alex Kon wrote:
OK, and what about rotation? Why do you mention only resize and drag? If there are only two options - you can easily distinguish one from another. Drag doesn't change size of the image and resize does.


Yes, in the past, we are using mouse up, to check with the points are different, and the size of the object

But, now we need to know in real time while the VObject is being dragging, and if it's resize which point is being dragging. (Means we need to have the info before the MouseUp for some visual effect.


Alex Kon  
#10 Posted : Wednesday, May 4, 2011 2:26:22 AM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello,

OK, I understand you. Such functionality wasn't expected when we designed VObjects, so I recommend you to inject your code into GenericControlPointsProvider class (see my message above).

ChingYen  
#11 Posted : Wednesday, May 4, 2011 4:33:48 PM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Alex Kon wrote:
Hello,

OK, I understand you. Such functionality wasn't expected when we designed VObjects, so I recommend you to inject your code into GenericControlPointsProvider class (see my message above).



Hi,

That might be a better idea, but, the problem is, the source file available for download is not updated. Although the compiled version is now 5.5.6 but, the source file still stay at 4.5.17

Dmitry.Obukhov  
#12 Posted : Thursday, May 5, 2011 3:55:52 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Ching-Yen,

Could you please let me know where you downloaded this version? The last version of GM should be with complete of source codes set.
Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
ChingYen  
#13 Posted : Friday, May 6, 2011 6:50:40 AM(UTC)
ChingYen

Rank: Advanced Member

Groups: Member
Joined: 3/3/2008(UTC)
Posts: 185

Thanks: 8 times
Dmitry.Obukhov wrote:
Hello Ching-Yen,

Could you please let me know where you downloaded this version? The last version of GM should be with complete of source codes set.


Hi,

Sorry, my fault. I didn't aware it came with the installer. I always presume it's a separate download. Thanks !
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.