コード例 #1
0
        public virtual void OnNodeUpdate()
        {
            for (int i = 0; i < 8; i++)
            {
                ResizeNode node = Manager.ResizeNodes[i];

                if (node.IsDragging)
                {
                    Manager.IsResizing = true;

                    if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
                    {
                        tempNodePos  = node.Position;
                        tempStartPos = Rectangle.Location;
                        tempEndPos   = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1);
                    }

                    Point pos      = InputManager.MousePosition0Based;
                    Point startPos = tempStartPos;
                    Point endPos   = tempEndPos;

                    NodePosition nodePosition = (NodePosition)i;

                    int x = pos.X - tempNodePos.X;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Left:
                    case NodePosition.BottomLeft:
                        startPos.X += x;
                        break;

                    case NodePosition.TopRight:
                    case NodePosition.Right:
                    case NodePosition.BottomRight:
                        endPos.X += x;
                        break;
                    }

                    int y = pos.Y - tempNodePos.Y;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Top:
                    case NodePosition.TopRight:
                        startPos.Y += y;
                        break;

                    case NodePosition.BottomLeft:
                    case NodePosition.Bottom:
                    case NodePosition.BottomRight:
                        endPos.Y += y;
                        break;
                    }

                    Rectangle = CaptureHelpers.CreateRectangle(startPos, endPos);
                }
            }
        }
コード例 #2
0
        public void Update()
        {
            BaseShape shape = shapeManager.CurrentShape;

            if (shape != null && Visible && nodes != null)
            {
                if (InputManager.IsMouseDown(MouseButtons.Left))
                {
                    if (shape.NodeType == NodeType.Rectangle)
                    {
                        for (int i = 0; i < 8; i++)
                        {
                            if (nodes[i].IsDragging)
                            {
                                IsResizing = true;

                                if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
                                {
                                    tempRect = shape.Rectangle;
                                }

                                NodePosition nodePosition = (NodePosition)i;

                                int x = InputManager.MouseVelocity.X;

                                switch (nodePosition)
                                {
                                case NodePosition.TopLeft:
                                case NodePosition.Left:
                                case NodePosition.BottomLeft:
                                    tempRect.X     += x;
                                    tempRect.Width -= x;
                                    break;

                                case NodePosition.TopRight:
                                case NodePosition.Right:
                                case NodePosition.BottomRight:
                                    tempRect.Width += x;
                                    break;
                                }

                                int y = InputManager.MouseVelocity.Y;

                                switch (nodePosition)
                                {
                                case NodePosition.TopLeft:
                                case NodePosition.Top:
                                case NodePosition.TopRight:
                                    tempRect.Y      += y;
                                    tempRect.Height -= y;
                                    break;

                                case NodePosition.BottomLeft:
                                case NodePosition.Bottom:
                                case NodePosition.BottomRight:
                                    tempRect.Height += y;
                                    break;
                                }

                                shape.Rectangle = CaptureHelpers.FixRectangle(tempRect);

                                break;
                            }
                        }
                    }
                    else if (shape.NodeType == NodeType.Line)
                    {
                        if (nodes[(int)NodePosition.TopLeft].IsDragging)
                        {
                            IsResizing = true;

                            shape.StartPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y);
                        }
                        else if (nodes[(int)NodePosition.BottomRight].IsDragging)
                        {
                            IsResizing = true;

                            shape.EndPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y);
                        }
                    }
                }
                else
                {
                    IsResizing = false;
                }

                UpdateNodePositions();
            }
        }
コード例 #3
0
        public virtual void OnNodeUpdate()
        {
            for (int i = 0; i < 8; i++)
            {
                ResizeNode node = Manager.ResizeNodes[i];

                if (node.IsDragging)
                {
                    Manager.IsResizing = true;

                    if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
                    {
                        tempNodePos   = node.Position;
                        tempStartPos  = Rectangle.Location;
                        tempEndPos    = new Point(Rectangle.X + Rectangle.Width - 1, Rectangle.Y + Rectangle.Height - 1);
                        tempRectangle = Rectangle;

                        OnResizing();
                    }

                    if (Manager.IsCornerMoving || Manager.IsPanning)
                    {
                        tempStartPos.Offset(InputManager.MouseVelocity);
                        tempEndPos.Offset(InputManager.MouseVelocity);
                        tempNodePos.Offset(InputManager.MouseVelocity);
                        tempRectangle.LocationOffset(InputManager.MouseVelocity);
                    }

                    Point pos      = InputManager.ClientMousePosition;
                    Point startPos = tempStartPos;
                    Point endPos   = tempEndPos;

                    NodePosition nodePosition = (NodePosition)i;

                    int x = pos.X - tempNodePos.X;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Left:
                    case NodePosition.BottomLeft:
                        startPos.X += x;
                        break;

                    case NodePosition.TopRight:
                    case NodePosition.Right:
                    case NodePosition.BottomRight:
                        endPos.X += x;
                        break;
                    }

                    int y = pos.Y - tempNodePos.Y;

                    switch (nodePosition)
                    {
                    case NodePosition.TopLeft:
                    case NodePosition.Top:
                    case NodePosition.TopRight:
                        startPos.Y += y;
                        break;

                    case NodePosition.BottomLeft:
                    case NodePosition.Bottom:
                    case NodePosition.BottomRight:
                        endPos.Y += y;
                        break;
                    }

                    StartPosition = startPos;
                    EndPosition   = endPos;

                    if (Manager.IsProportionalResizing && !InitialSize.IsEmpty)
                    {
                        switch (nodePosition)
                        {
                        case NodePosition.Top:
                        case NodePosition.Right:
                        case NodePosition.Bottom:
                        case NodePosition.Left:
                            return;
                        }

                        double ratio     = Math.Min(Rectangle.Width / (double)InitialSize.Width, Rectangle.Height / (double)InitialSize.Height);
                        int    newWidth  = (int)Math.Round(InitialSize.Width * ratio);
                        int    newHeight = (int)Math.Round(InitialSize.Height * ratio);

                        Point anchor = new Point();

                        switch (nodePosition)
                        {
                        case NodePosition.TopLeft:
                        case NodePosition.Left:
                        case NodePosition.BottomLeft:
                            anchor.X = tempRectangle.Right - 1;
                            break;

                        case NodePosition.TopRight:
                        case NodePosition.Right:
                        case NodePosition.BottomRight:
                            anchor.X = tempRectangle.X;
                            break;
                        }

                        switch (nodePosition)
                        {
                        case NodePosition.TopLeft:
                        case NodePosition.Top:
                        case NodePosition.TopRight:
                            anchor.Y = tempRectangle.Bottom - 1;
                            break;

                        case NodePosition.BottomLeft:
                        case NodePosition.Bottom:
                        case NodePosition.BottomRight:
                            anchor.Y = tempRectangle.Y;
                            break;
                        }

                        Rectangle newRect = Rectangle;

                        if (pos.X < anchor.X)
                        {
                            newRect.X = newRect.Right - newWidth;
                        }

                        newRect.Width = newWidth;

                        if (pos.Y < anchor.Y)
                        {
                            newRect.Y = newRect.Bottom - newHeight;
                        }

                        newRect.Height = newHeight;

                        Rectangle = newRect;
                    }

                    if (LimitRectangleToInsideCanvas)
                    {
                        Rectangle = RectangleInsideCanvas;
                    }
                }
            }
        }
コード例 #4
0
        public void Update()
        {
            if (Visible && nodes != null)
            {
                if (InputManager.IsMouseDown(MouseButtons.Left))
                {
                    for (int i = 0; i < 8; i++)
                    {
                        if (nodes[i].IsDragging)
                        {
                            IsResizing = true;

                            if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
                            {
                                tempRect = areaManager.CurrentArea;
                            }

                            NodePosition nodePosition = (NodePosition)i;

                            int x = InputManager.MouseVelocity.X;

                            switch (nodePosition)
                            {
                            case NodePosition.TopLeft:
                            case NodePosition.Left:
                            case NodePosition.BottomLeft:
                                tempRect.X     += x;
                                tempRect.Width -= x;
                                break;

                            case NodePosition.TopRight:
                            case NodePosition.Right:
                            case NodePosition.BottomRight:
                                tempRect.Width += x;
                                break;
                            }

                            int y = InputManager.MouseVelocity.Y;

                            switch (nodePosition)
                            {
                            case NodePosition.TopLeft:
                            case NodePosition.Top:
                            case NodePosition.TopRight:
                                tempRect.Y      += y;
                                tempRect.Height -= y;
                                break;

                            case NodePosition.BottomLeft:
                            case NodePosition.Bottom:
                            case NodePosition.BottomRight:
                                tempRect.Height += y;
                                break;
                            }

                            areaManager.CurrentArea = CaptureHelpers.FixRectangle(tempRect);

                            break;
                        }
                    }
                }
                else
                {
                    IsResizing = false;
                }

                UpdateNodePositions();
            }
        }