Esempio n. 1
18
        private Rectangle GetSizingRect(PosSizableRect p)
        {
            switch (p)
            {
                case PosSizableRect.LeftUp:
                    return CreateRectSizableNode(block.X, block.Y);

                case PosSizableRect.LeftMiddle:
                    return CreateRectSizableNode(block.X, block.Y + (block.Height / 2));

                case PosSizableRect.LeftBottom:
                    return CreateRectSizableNode(block.X, block.Y + block.Height);

                case PosSizableRect.BottomMiddle:
                    return CreateRectSizableNode(block.X + (block.Width / 2), block.Y + block.Height);

                case PosSizableRect.RightUp:
                    return CreateRectSizableNode(block.X + block.Width, block.Y);

                case PosSizableRect.RightBottom:
                    return CreateRectSizableNode(block.X + block.Width, block.Y + block.Height);

                case PosSizableRect.RightMiddle:
                    return CreateRectSizableNode(block.X + block.Width, block.Y + (block.Height / 2));

                case PosSizableRect.UpMiddle:
                    return CreateRectSizableNode(block.X + (block.Width / 2), block.Y);

                default:
                    return new Rectangle();
            }
        }
Esempio n. 2
2
        /// <summary>
        /// Get cursor for the handle
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        private Cursor GetCursor(PosSizableRect p)
        {
            switch (p)
            {
                case PosSizableRect.LeftUp:
                    return Cursors.SizeNWSE;

                case PosSizableRect.LeftMiddle:
                    return Cursors.SizeWE;

                case PosSizableRect.LeftBottom:
                    return Cursors.SizeNESW;

                case PosSizableRect.BottomMiddle:
                    return Cursors.SizeNS;

                case PosSizableRect.RightUp:
                    return Cursors.SizeNESW;

                case PosSizableRect.RightBottom:
                    return Cursors.SizeNWSE;

                case PosSizableRect.RightMiddle:
                    return Cursors.SizeWE;

                case PosSizableRect.UpMiddle:
                    return Cursors.SizeNS;
                default:
                    return Cursors.Default;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Get cursor for the handle
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        private Cursor GetCursor(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(Cursors.SizeNWSE);

            case PosSizableRect.LeftMiddle:
                return(Cursors.SizeWE);

            case PosSizableRect.LeftBottom:
                return(Cursors.SizeNESW);

            case PosSizableRect.BottomMiddle:
                return(Cursors.SizeNS);

            case PosSizableRect.RightUp:
                return(Cursors.SizeNESW);

            case PosSizableRect.RightBottom:
                return(Cursors.SizeNWSE);

            case PosSizableRect.RightMiddle:
                return(Cursors.SizeWE);

            case PosSizableRect.UpMiddle:
                return(Cursors.SizeNS);

            default:
                return(Cursors.Default);
            }
        }
        protected void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (Contains(e.Location)) //нажали внутри фигуры
            {
                isReadyToMove = true; //приготовились двигать всю фигуру
                isMoved       = false;
                OnClick();            //???

                IsActive = true;
            }
            else  //нажали вне фигуры
            {
                IsActive = false;
            }

            if (IsActive) //если фигура активирована - можно применять к ней преобразования, например, растяжение
            {
                //nodeSelected = PosSizableRect.None;
                nodeSelected = GetNodeSelectable(e.Location); //проверяем на захват одного из узлов
                if (nodeSelected != PosSizableRect.None)
                {
                    return;
                }
            }

            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 5
0
        private Rectangle GetRect(PosSizableRect p)
        {
            Rectangle rrect = Rectangle.Round(rect);

            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode(rrect.X, rrect.Y));

            case PosSizableRect.LeftMiddle:
                return(CreateRectSizableNode(rrect.X, rrect.Y + rrect.Height / 2));

            case PosSizableRect.LeftBottom:
                return(CreateRectSizableNode(rrect.X, rrect.Y + rrect.Height));

            case PosSizableRect.BottomMiddle:
                return(CreateRectSizableNode(rrect.X + rrect.Width / 2, rrect.Y + rrect.Height));

            case PosSizableRect.RightUp:
                return(CreateRectSizableNode(rrect.X + rrect.Width, rrect.Y));

            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode(rrect.X + rrect.Width, rrect.Y + rrect.Height));

            case PosSizableRect.RightMiddle:
                return(CreateRectSizableNode(rrect.X + rrect.Width, rrect.Y + rrect.Height / 2));

            case PosSizableRect.UpMiddle:
                return(CreateRectSizableNode(rrect.X + rrect.Width / 2, rrect.Y));

            default:
                return(new Rectangle());
            }
        }
Esempio n. 6
0
        private Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode(rect.X, rect.Y));

            case PosSizableRect.LeftMiddle:
                return(CreateRectSizableNode(rect.X, rect.Y + sizeNodeRect, sizeNodeRect, rect.Height - sizeNodeRect));

            case PosSizableRect.LeftBottom:
                return(CreateRectSizableNode(rect.X, rect.Y + rect.Height));

            case PosSizableRect.BottomMiddle:
                return(CreateRectSizableNode(rect.X + sizeNodeRect, rect.Y + rect.Height, rect.Width - sizeNodeRect, sizeNodeRect));

            case PosSizableRect.RightUp:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y));

            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height));

            case PosSizableRect.RightMiddle:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y + sizeNodeRect, sizeNodeRect, rect.Height - sizeNodeRect));

            case PosSizableRect.UpMiddle:
                return(CreateRectSizableNode(rect.X + sizeNodeRect, rect.Y, rect.Width - sizeNodeRect, sizeNodeRect));

            default:
                return(new Rectangle());
            }
        }
Esempio n. 7
0
        private Rectangle GetSizingRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode(block.X, block.Y));

            case PosSizableRect.LeftMiddle:
                return(CreateRectSizableNode(block.X, block.Y + (block.Height / 2)));

            case PosSizableRect.LeftBottom:
                return(CreateRectSizableNode(block.X, block.Y + block.Height));

            case PosSizableRect.BottomMiddle:
                return(CreateRectSizableNode(block.X + (block.Width / 2), block.Y + block.Height));

            case PosSizableRect.RightUp:
                return(CreateRectSizableNode(block.X + block.Width, block.Y));

            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode(block.X + block.Width, block.Y + block.Height));

            case PosSizableRect.RightMiddle:
                return(CreateRectSizableNode(block.X + block.Width, block.Y + (block.Height / 2)));

            case PosSizableRect.UpMiddle:
                return(CreateRectSizableNode(block.X + (block.Width / 2), block.Y));

            default:
                return(new Rectangle());
            }
        }
Esempio n. 8
0
        private void workspace_MouseDown(object sender, MouseEventArgs e)
        {
            _nodeSelected = PosSizableRect.None;
            sr            = _shapes.FirstOrDefault(s => s.Contains(new Point(e.X, e.Y)));

            if (sr != null)
            {
                sr.IsSelected = true;
                _nodeSelected = sr.GetNodeSelectable(e.Location);
                if (_nodeSelected != PosSizableRect.None)
                {
                    _move = false;
                }
                else
                {
                    _move = true;
                }
            }
            else
            {
                _shapes.ForEach(s => s.IsSelected = false);
            }
            oldX = e.X;
            oldY = e.Y;
        }
        public UltimateRectangle(Rectangle rect)
        {
            guid       = Guid.NewGuid();
            internalID = count;
            count++;

            CreateContextMenu();
            CreateEventHandlers();

            //this.isRectangle = true;
            this.rect = rect;
            //this.points = RectangleToPoints(rect);
            //this.mIsClick = false;

            IsInvertedX = false;
            IsInvertedY = false;

            IsActive     = false;
            mMove        = false;
            nodeSelected = PosSizableRect.None;
            isMouseHover = false;

            //подписка на собственные события
            MouseEnter += new EventHandler(HandleMouseEnter);
            MouseLeave += new EventHandler(HandleMouseLeave);
        }
Esempio n. 10
0
        private Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode(rect.X, rect.Y));

            //case PosSizableRect.LeftMiddle:
            //    return CreateRectSizableNode(rect.X, rect.Y + +rect.Height / 2);

            //case PosSizableRect.LeftBottom:
            //    return CreateRectSizableNode(rect.X, rect.Y +rect.Height);

            //case PosSizableRect.BottomMiddle:
            //    return CreateRectSizableNode(rect.X  + rect.Width / 2,rect.Y + rect.Height);

            //case PosSizableRect.RightUp:
            //    return CreateRectSizableNode(rect.X + rect.Width,rect.Y );

            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height));

            //case PosSizableRect.RightMiddle:
            //    return CreateRectSizableNode(rect.X  + rect.Width, rect.Y  + rect.Height / 2);

            //case PosSizableRect.UpMiddle:
            //    return CreateRectSizableNode(rect.X + rect.Width/2, rect.Y);
            default:
                return(new Rectangle());
            }
        }
Esempio n. 11
0
        private void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            mIsClick = true;

            nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(e.Location);

            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 12
0
        public void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            mIsClick = true;

            //           nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(e.Location);

            if (rect.Contains(new Point(e.X, e.Y)))
            {
                mMove = true;
            }
            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 13
0
        private System.Drawing.Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode((int)_Array_4_Point[0].X, (int)_Array_4_Point[0].Y));

            case PosSizableRect.LeftUp_region:
                return(CreateRectSizableNode((int)_Array_4_Point_region[0].X, (int)_Array_4_Point_region[0].Y));

            //case PosSizableRect.LeftMiddle:
            //    return CreateRectSizableNode(rect.X, rect.Y + +rect.Height / 2);

            case PosSizableRect.LeftBottom:
                return(CreateRectSizableNode((int)_Array_4_Point[3].X, (int)_Array_4_Point[3].Y));

            case PosSizableRect.LeftBottom_region:
                return(CreateRectSizableNode((int)_Array_4_Point_region[3].X, (int)_Array_4_Point_region[3].Y));

            //case PosSizableRect.BottomMiddle:
            //    return CreateRectSizableNode(rect.X + rect.Width / 2, rect.Y + rect.Height);

            case PosSizableRect.RightUp:
                return(CreateRectSizableNode((int)_Array_4_Point[1].X, (int)_Array_4_Point[1].Y));

            case PosSizableRect.RightUp_region:
                return(CreateRectSizableNode((int)_Array_4_Point_region[1].X, (int)_Array_4_Point_region[1].Y));


            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode((int)_Array_4_Point[2].X, (int)_Array_4_Point[2].Y));

            case PosSizableRect.RightBottom_region:
                return(CreateRectSizableNode((int)_Array_4_Point_region[2].X, (int)_Array_4_Point_region[2].Y));

            //case PosSizableRect.RightMiddle:
            //    return CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height / 2);

            //case PosSizableRect.UpMiddle:
            //    return CreateRectSizableNode(rect.X + rect.Width / 2, rect.Y);
            case PosSizableRect.Centeroid:
                return(CreateRectSizableNode((int)Center_x, (int)Center_y));

            case PosSizableRect.Centeroid_region:
                return(CreateRectSizableNode((int)Center_region_x, (int)Center_region_y));

            default:
                return(new System.Drawing.Rectangle());
            }
        }
Esempio n. 14
0
        private void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(new Point(e.X, e.Y));

            if (rect.Contains(new Point(e.X, e.Y)) || nodeSelected != PosSizableRect.None)
            {
                mIsClick = true;
                ChangeCursor(new Point(e.X, e.Y));
            }

            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 15
0
        private void PictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            isClick = true;

            nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(e.Location);

            if (block.Contains(new Point(e.X, e.Y)))
            {
                move = true;
            }

            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 16
0
        private void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            mIsClick = true;

            nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(e.Location);

            if (rect.Contains(new Point(e.X, e.Y)))
            {
                // mMove = true;
            }
            oldX        = e.X;
            oldY        = e.Y;
            panningTemp = iPrint.WizardPageEditor.panning;
        }
Esempio n. 17
0
        private Cursor GetCursor(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.Up:
            case PosSizableRect.Bottom:
                return(Cursors.SizeNS);

            case PosSizableRect.Left:
            case PosSizableRect.Right:
                return(Cursors.SizeWE);

            default:
                return(Cursors.Default);
            }
        }
Esempio n. 18
0
 private void mPictureBox_MouseDown(object sender, MouseEventArgs e)
 {
     mIsClick     = true;
     nodeSelected = PosSizableRect.None;
     nodeSelected = GetNodeSelectable(e.Location);
     if (nodeSelected == PosSizableRect.Centeroid)
     {
         mMove = true;
     }
     if (nodeSelected == PosSizableRect.Centeroid_region)
     {
         mMove_region = true;
     }
     oldX = e.X;
     oldY = e.Y;
 }
Esempio n. 19
0
        /// <summary>
        /// Get cursor for the handle
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        private Cursor GetCursor(PosSizableRect pos, Point p)
        {
            //если такщим какой-нибудь угол
            if (pos == PosSizableRect.LeftUp)
            {
                return(Cursors.SizeNWSE);
            }
            else if (pos == PosSizableRect.LeftMiddle)
            {
                return(Cursors.SizeWE);
            }
            else if (pos == PosSizableRect.LeftBottom)
            {
                return(Cursors.SizeNESW);
            }
            else if (pos == PosSizableRect.BottomMiddle)
            {
                return(Cursors.SizeNS);
            }
            else if (pos == PosSizableRect.RightUp)
            {
                return(Cursors.SizeNESW);
            }
            else if (pos == PosSizableRect.RightBottom)
            {
                return(Cursors.SizeNWSE);
            }
            else if (pos == PosSizableRect.RightMiddle)
            {
                return(Cursors.SizeWE);
            }
            else if (pos == PosSizableRect.UpMiddle)
            {
                return(Cursors.SizeNS);
            }
            else if (pos == PosSizableRect.None)
            {
                //если ничего не тащим, но курсор над нашим прямоугольником
                if (rect.Contains(p))
                {
                    return(Cursors.SizeAll);
                }
            }

            //возвращаем стандартный курсор
            return(Cursors.Default);
        }
Esempio n. 20
0
        private Cursor GetCursor(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            case PosSizableRect.LeftUp_region:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            //case PosSizableRect.LeftMiddle:
            //    return Cursors.SizeWE;

            case PosSizableRect.LeftBottom:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            case PosSizableRect.LeftBottom_region:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            //case PosSizableRect.BottomMiddle:
            //    return Cursors.SizeNS;

            case PosSizableRect.RightUp:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            case PosSizableRect.RightUp_region:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            case PosSizableRect.RightBottom:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            case PosSizableRect.RightBottom_region:
                return(Cursor.Current = new Cursor(Get_cur_resize));

            //case PosSizableRect.RightMiddle:
            //    return Cursors.SizeWE;

            case PosSizableRect.Centeroid:
                return(Cursor.Current = new Cursor(Get_cur_move));

            case PosSizableRect.Centeroid_region:
                return(Cursor.Current = new Cursor(Get_cur_move));

            default:
                return(Cursors.Default);
            }
        }
        private Cursor GetCursor(PosSizableRect pos, Point p)
        {
            //если такщим какой-нибудь угол
            if (IsActive)
            {
                if (pos == PosSizableRect.LeftUp)
                {
                    return(Cursors.SizeNWSE);
                }
                else if (pos == PosSizableRect.LeftMiddle)
                {
                    return(Cursors.SizeWE);
                }
                else if (pos == PosSizableRect.LeftBottom)
                {
                    return(Cursors.SizeNESW);
                }
                else if (pos == PosSizableRect.BottomMiddle)
                {
                    return(Cursors.SizeNS);
                }
                else if (pos == PosSizableRect.RightUp)
                {
                    return(Cursors.SizeNESW);
                }
                else if (pos == PosSizableRect.RightBottom)
                {
                    return(Cursors.SizeNWSE);
                }
                else if (pos == PosSizableRect.RightMiddle)
                {
                    return(Cursors.SizeWE);
                }
                else if (pos == PosSizableRect.UpMiddle)
                {
                    return(Cursors.SizeNS);
                }
            }

            if (pos == PosSizableRect.None && rect.Contains(p))
            {
                return(Cursors.SizeAll);
            }

            //возвращаем стандартный курсор
            return(Cursors.Default);
        }
Esempio n. 22
0
    private Cursor GetCursor(PosSizableRect p)
    {
        switch (p)
        {
        case PosSizableRect.LeftUp:
            return(Cursors.SizeNWSE);

        case PosSizableRect.LeftMiddle:
            return(Cursors.SizeWE);

        case PosSizableRect.LeftBottom:
            return(Cursors.SizeNESW);

        case PosSizableRect.BottomMiddle:
            return(Cursors.SizeNS);

        case PosSizableRect.RightUp:
            return(Cursors.SizeNESW);

        case PosSizableRect.RightBottom:
            return(Cursors.SizeNWSE);

        case PosSizableRect.RightMiddle:
            return(Cursors.SizeWE);

        case PosSizableRect.UpMiddle:
            return(Cursors.SizeNS);

        default:
        {
            if (FreeSnippingTool.FrmMain.currentshape == ShapesTypes.ShapeTypes.CropRect)
            {
                using (var memoryStream = new MemoryStream(FreeSnippingTool.CommonImages.selectcur))
                {
                    return(new Cursor(memoryStream));
                }
            }
            else
            {
                return(Cursors.Default);
            }
        }
        }
    }
        private void mPictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            // mIsClick = false;
            if (isReadyToMove == true) //если только что двигали фигуру
            {
                isReadyToMove = false;
                //OnMoveLeave();
            }
            if (isMoved == true) //если только что двигали фигуру
            {
                isMoved = false;
                OnMoveLeave();
            }

            nodeSelected = PosSizableRect.None;

            //if (e.Button == MouseButtons.Right)
            //   myContextMenu.Show((System.Windows.Forms.Control)sender, new Point(e.X, e.Y));
        }
Esempio n. 24
0
        private Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.LeftUp:
                return(CreateRectSizableNode(rect.X, rect.Y));

            case PosSizableRect.LeftBottom:
                return(CreateRectSizableNode(rect.X, rect.Y + rect.Height));

            case PosSizableRect.RightUp:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y));

            case PosSizableRect.RightBottom:
                return(CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height));

            default:
                return(new Rectangle());
            }
        }
Esempio n. 25
0
        protected Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
            case PosSizableRect.Up:
                return(GetSizableRect(Rect.X + Rect.Width / 2, Rect.Y));

            case PosSizableRect.Left:
                return(GetSizableRect(Rect.X, Rect.Y + Rect.Height / 2));

            case PosSizableRect.Right:
                return(GetSizableRect(Rect.X + Rect.Width, Rect.Y + Rect.Height / 2));

            case PosSizableRect.Bottom:
                return(GetSizableRect(Rect.X + Rect.Width / 2, Rect.Y + Rect.Height));

            default:
                return(new Rectangle());
            }
        }
Esempio n. 26
0
    private void mForm_MouseDown(object sender, MouseEventArgs e)
    {
        if (AllowMovementAndResize)
        {
            mIsClick = true;
        }
        else
        {
            mIsClick = false;
        }

        nodeSelected = PosSizableRect.None;
        nodeSelected = GetNodeSelectable(e.Location);

        if (rect.Contains(new Point(e.X, e.Y)))
        {
            mMove = true;
        }
        oldX = e.X;
        oldY = e.Y;
    }
        private void mPictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (Contains(new Point(e.X, e.Y))) //если мышь попадает в нашу фигуру
            {
                if (isMouseHover == false)
                {
                    isMouseHover = true;
                    OnMouseEnter();
                    //OnMouseEnter();
                    //DragAndDropEnter((object)this, new EventArgs()); //на самом деле MouseEnter
                }
                OnMouseHover();
            }
            else //если двигаем мышь вне фигуры
            {
                if (isMouseHover == true)
                {
                    isMouseHover = false;
                    OnMouseLeave();
                }
            }

            Point   p = new Point(e.X, e.Y);
            WinRECT R = new WinRECT(rect);

            if (nodeSelected == PosSizableRect.None && IsReadyToMove == true)
            {
                //двигаем весь прямоугольник, не меняя форму
                if (isMoved == false)
                {
                    isMoved = true;
                    OnMoveEnter();
                }
                OnMoveHover();

                int dx = e.X - oldX;
                int dy = e.Y - oldY;
                rect.X += dx;
                rect.Y += dy;
                RecalcParams();
                //RecalcNodes();
                mPictureBox.Invalidate();
                oldX = e.X;
                oldY = e.Y;
                return;
            }

            //меняем параметры ректа в зависимости от того, какой угол захвачен
            if (nodeSelected == PosSizableRect.LeftUp)
            {
                R.left = p.X; R.top = p.Y;
            }
            if (nodeSelected == PosSizableRect.UpMiddle)
            {
                R.top = p.Y;
            }
            if (nodeSelected == PosSizableRect.RightUp)
            {
                R.right = p.X; R.top = p.Y;
            }
            if (nodeSelected == PosSizableRect.RightMiddle)
            {
                R.right = p.X;
            }
            if (nodeSelected == PosSizableRect.RightBottom)
            {
                R.right = p.X; R.bottom = p.Y;
            }
            if (nodeSelected == PosSizableRect.BottomMiddle)
            {
                R.bottom = p.Y;
            }
            if (nodeSelected == PosSizableRect.LeftBottom)
            {
                R.left = p.X; R.bottom = p.Y;
            }
            if (nodeSelected == PosSizableRect.LeftMiddle)
            {
                R.left = p.X;
            }

            //при перемещении узлов могут поменяться местами левая сторона и правая
            //или верхняя сторона и нижняя; эти ситуации нужно обрабатывать

            int b = 0;

            if (R.left > R.right) //перепутались левая и правая сторона
            {
                //свопаем границы
                b       = R.left;
                R.right = R.left;
                R.left  = b;

                IsInvertedX = !IsInvertedX;

                //переключаемся на противоположный узел
                if (nodeSelected == PosSizableRect.LeftMiddle)
                {
                    nodeSelected = PosSizableRect.RightMiddle;
                }
                else if (nodeSelected == PosSizableRect.LeftUp)
                {
                    nodeSelected = PosSizableRect.RightUp;
                }
                else if (nodeSelected == PosSizableRect.LeftBottom)
                {
                    nodeSelected = PosSizableRect.RightBottom;
                }
                else if (nodeSelected == PosSizableRect.RightMiddle)
                {
                    nodeSelected = PosSizableRect.LeftMiddle;
                }
                else if (nodeSelected == PosSizableRect.RightUp)
                {
                    nodeSelected = PosSizableRect.LeftUp;
                }
                else if (nodeSelected == PosSizableRect.RightBottom)
                {
                    nodeSelected = PosSizableRect.LeftBottom;
                }
            }
            if (R.top > R.bottom) //перепутались верхняя и нижняя сторона
            {
                //свопаем границы
                b        = R.top;
                R.bottom = R.top;
                R.top    = b;

                IsInvertedY = !IsInvertedY;

                //переключаемся на противоположный узел
                if (nodeSelected == PosSizableRect.UpMiddle)
                {
                    nodeSelected = PosSizableRect.BottomMiddle;
                }
                else if (nodeSelected == PosSizableRect.LeftUp)
                {
                    nodeSelected = PosSizableRect.LeftBottom;
                }
                else if (nodeSelected == PosSizableRect.RightUp)
                {
                    nodeSelected = PosSizableRect.RightBottom;
                }
                else if (nodeSelected == PosSizableRect.BottomMiddle)
                {
                    nodeSelected = PosSizableRect.UpMiddle;
                }
                else if (nodeSelected == PosSizableRect.LeftBottom)
                {
                    nodeSelected = PosSizableRect.LeftUp;
                }
                else if (nodeSelected == PosSizableRect.RightBottom)
                {
                    nodeSelected = PosSizableRect.RightUp;
                }
            }

            //преобразуем обратно
            rect = R.ToRectangle();

            RecalcNodes();

            //Form1 F = (Form1)mPictureBox.Parent;
            //F.LogWrite(nodeSelected.ToString());

            mPictureBox.Invalidate();
        }
Esempio n. 28
-19
        private void mPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            mIsClick = true;

            nodeSelected = PosSizableRect.None;
            nodeSelected = GetNodeSelectable(e.Location);

            if (rect.Contains(new Point(e.X, e.Y)))
            {
                mMove = true;
            }
            oldX = e.X;
            oldY = e.Y;
        }
Esempio n. 29
-37
        private Rectangle GetRect(PosSizableRect p)
        {
            switch (p)
            {
                case PosSizableRect.LeftUp:
                    return CreateRectSizableNode(rect.X, rect.Y);

                case PosSizableRect.LeftMiddle:
                    return CreateRectSizableNode(rect.X, rect.Y + +rect.Height / 2);

                case PosSizableRect.LeftBottom:
                    return CreateRectSizableNode(rect.X, rect.Y + rect.Height);

                case PosSizableRect.BottomMiddle:
                    return CreateRectSizableNode(rect.X + rect.Width / 2, rect.Y + rect.Height);

                case PosSizableRect.RightUp:
                    return CreateRectSizableNode(rect.X + rect.Width, rect.Y);

                case PosSizableRect.RightBottom:
                    return CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height);

                case PosSizableRect.RightMiddle:
                    return CreateRectSizableNode(rect.X + rect.Width, rect.Y + rect.Height / 2);

                case PosSizableRect.UpMiddle:
                    return CreateRectSizableNode(rect.X + rect.Width / 2, rect.Y);
                default:
                    return new Rectangle();
            }
        }