Пример #1
0
        private void tabPage1_MouseDown(object sender, MouseEventArgs e)
        {
            captcured.X = e.X;
            captcured.Y = e.Y;
            Point p = new Point();

            p.X = e.X;
            p.Y = e.Y;
            if (isActive(captcured))
            {
                if (selectedShape.getLeftBorder().Contains(p))
                {
                    isResize     = true;
                    resizeLeft   = true;
                    resizeTop    = false;
                    resizeRight  = false;
                    resizeBottom = false;
                    ismoving     = false;
                }
                else if (selectedShape.getTopBorder().Contains(p))
                {
                    isResize     = true;
                    resizeTop    = true;
                    resizeRight  = false;
                    resizeLeft   = false;
                    resizeBottom = false;
                    ismoving     = false;
                }
                else if (selectedShape.getBottomBorder().Contains(p))
                {
                    isResize     = true;
                    resizeBottom = true;
                    resizeTop    = false;
                    resizeRight  = false;
                    resizeLeft   = false;
                    ismoving     = false;
                }
                else if (selectedShape.getRightBorder().Contains(p))
                {
                    isResize     = true;
                    resizeRight  = true;
                    resizeBottom = false;
                    resizeTop    = false;
                    resizeLeft   = false;
                    ismoving     = false;
                }
                else
                {
                    shapeSelected = true;
                    ismoving      = true;
                }
                selectedShape.dx     = e.X - selectedShape.startPoint.X;
                selectedShape.dy     = e.Y - selectedShape.startPoint.Y;
                selectedShape.lineDx = e.X - selectedShape.endPoint.X;
                selectedShape.lineDy = e.Y - selectedShape.endPoint.Y;
                tabPage1.Invalidate();
            }
            else
            {
                shapeSelected = false;
                selectedShape = null;
                ismoving      = false;
                tabPage1.Invalidate();
            }
            if (!ismoving)
            {
                if (type == "Line")
                {
                    shape      = new Line();
                    shape.type = "Line";
                }
                else if (type == "Rect")
                {
                    shape      = new Rect();
                    shape.type = "Rect";
                }
                else if (type == "Circle")
                {
                    shape      = new Circle();
                    shape.type = "Circle";
                }
                shape.penColor     = colorDialog1.Color;
                shape.thickness    = Convert.ToInt32(LineSize.SelectedItem.ToString());
                shape.startPoint.X = e.X;
                shape.startPoint.Y = e.Y;
            }
            else
            {
                shape = null;
            }
        }