コード例 #1
0
        private void PictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            switch (Mode)
            {
            case Mode.DrawPoint:
                ShapeLibrary.Point point = new ShapeLibrary.Point(e.X, e.Y, buttonColor.BackColor, size);
                AddShape(point);
                break;

            case Mode.DrawLine:
                X = e.X; Y = e.Y; X1 = e.X; Y1 = e.Y;
                break;

            case Mode.DrawCircle:
                X = e.X; Y = e.Y; Rad = 2;
                break;

            case Mode.DrawRectangle:
                X = e.X; Y = e.Y; X1 = e.X; Y1 = e.Y;
                break;

            case Mode.DrawEllipse:
                X = e.X; Y = e.Y; Rad = 2; Width = 2;
                break;
            }
        }
コード例 #2
0
        private void pictureBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (controller.mode == DrawMode.MODE_DRAW_BY_MOUSE && controller.isDrawing == true)
            {
                int x = e.Location.X;
                int y = e.Location.Y;
                lbMousePos.Text = x.ToString() + ", " + y.ToString();
                if (controller.mShape is Line)
                {
                    Line  l = (Line)controller.mShape;
                    Point p = new Point(x, y);
                    if (x != l.p1.x && y != l.p1.y)
                    {
                        l.p2 = p;
                        drawingTemporary();
                    }
                }

                else if (controller.mShape is Circle)
                {
                    Circle c = (Circle)controller.mShape;
                    Point  p = new Point(x, y);
                    int    r = (int)p.getDistance(c.I);
                    if (r > 0)
                    {
                        c.R = r;
                        drawingTemporary();
                    }
                }

                else if (controller.mShape is Ellipse)
                {
                    Ellipse el = (Ellipse)controller.mShape;
                    int     ra = Math.Abs(el.I.x - x);
                    int     rb = Math.Abs(el.I.y - y);
                    if (ra > 0 && rb > 0)
                    {
                        el.a = ra;
                        el.b = rb;

                        drawingTemporary();
                    }
                }
                else if (controller.mShape is Parabola)
                {
                    Parabola pa = (Parabola)controller.mShape;
                    pa.Bound = new Point(x, y);
                    drawingTemporary();
                }
                else if (controller.mShape is Hyperbole)
                {
                    Hyperbole hy = (Hyperbole)controller.mShape;
                    hy.Bound = new Point(x, y);

                    drawingTemporary();
                }
            }
        }
コード例 #3
0
        private void pictureBoxMain_MouseDown(object sender, MouseEventArgs e)
        {
            switch (Mode)
            {
            case Mode.DrawPoint:
                ShapeLibrary.Point point = new ShapeLibrary.Point(e.X, e.Y, new Pen(buttonColor.BackColor, 2));
                AddShapes(point);
                break;

            case Mode.DrawLine:
            case Mode.DrawCircle:
            case Mode.DrawRectangle:
            case Mode.DrawEllipse:
                MouseX = e.X;
                MouseY = e.Y;
                break;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Krasav4ik66/Paint
 private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
 {
     if (Shapes == null)
     {
         Shapes = new List <Shape_Point>();
     }
     MouseX = e.X;
     MouseY = e.Y;
     switch (mode)
     {
     case Mode.DrawPoint:
         ShapeLibrary.Point point = new ShapeLibrary.Point(
             e.X,
             e.Y,
             buttonColor.BackColor
             );
         AddShape(point);
         break;
     }
 }