예제 #1
0
        private void fillWPointsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Point  p;
            Random r = new Random();

            for (int i = 0; i < 10000; i++)
            {
                p = new Point((int)Math.Ceiling(r.NextDouble() * Width), (int)Math.Ceiling(r.NextDouble() * Width), Color.Chartreuse);
                p.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
            }
        }
예제 #2
0
        private void MainCAD_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && chosenShape != Shapes.Point)
            {
                xEnd = e.X;
                yEnd = e.Y;
                int deltaX = xEnd - xStart;
                int deltaY = yEnd - yStart;

                switch (chosenShape)
                {
                case Shapes.Line:
                    Point start = new Point(xStart, yStart);
                    Point end   = new Point(xEnd, yEnd);
                    Line  line  = new Line(start, end, chosenColor);
                    line.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    shapeList.Add(line);
                    break;

                case Shapes.Rectangle:
                    start = new Point(xStart, yStart);
                    Rectangle rectangle = new Rectangle(chosenColor, start, deltaX, deltaY);
                    rectangle.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    shapeList.Add(rectangle);
                    break;

                case Shapes.Square:
                    start = new Point(xStart, yStart);
                    Square square = new Square(chosenColor, start, deltaX);
                    square.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    shapeList.Add(square);
                    break;

                case Shapes.Ellipsis:

                    if (ctrlKeyDown)
                    {
                        deltaY = deltaX = Math.Max(deltaX, deltaY);
                    }

                    start = new Point(xStart, yStart);
                    Ellipsis ellipsis = new Ellipsis(chosenColor, start, deltaX, deltaY);
                    ellipsis.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    shapeList.Add(ellipsis);
                    break;
                }
            }
        }
예제 #3
0
 private void MainCAD_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left && chosenShape == Shapes.Point)
     {
         Point p = new Point(e.X, e.Y, chosenColor);
         p.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
         shapeList.Add(p);
     }
     else if (e.Button == MouseButtons.Right)
     {
         if (colorSelection.ShowDialog() == DialogResult.OK)
         {
             chosenColor = colorSelection.Color;
         }
     }
 }
예제 #4
0
        private void btnDrawPoint_Click(object sender, EventArgs e)
        {
            Point p = new Point((e as MouseEventArgs).X, (e as MouseEventArgs).Y, Color.Aqua);

            p.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
        }
예제 #5
0
 private void pointsCountToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Point.PointsCount();
 }
예제 #6
0
        private void MainCAD_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Point start = new Point(xStart, yStart, chosenColor);
                Point end   = new Point(xEnd, yEnd, chosenColor);
                int   deltaX;
                int   deltaY;

                switch (chosenShape)
                {
                case Shapes.Point:
                    end = new Point(e.X, e.Y, chosenColor);
                    end.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    shapeList.Add(end);
                    break;

                case Shapes.Line:
                    //Cancella la vecchia linea disegnandone una nuova dello stesso colore
                    Line line = new Line(start, end, BackColor);
                    line.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    //Disegna la nuova linea
                    xEnd = e.X;
                    yEnd = e.Y;
                    end  = new Point(xEnd, yEnd, chosenColor);
                    line = new Line(start, end, chosenColor);
                    line.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    RenderRefresh();
                    break;

                case Shapes.Rectangle:
                {
                    //Cancella il vecchio rettangolo
                    deltaX = xEnd - xStart;
                    deltaY = yEnd - yStart;

                    Rectangle rectangle =
                        new Rectangle(BackColor, new Point(xStart, yStart, chosenColor), deltaX, deltaY);
                    rectangle.Draw(toolStripContainer1.ContentPanel.CreateGraphics());

                    //Aggiorna la posizione del mouse
                    xEnd      = e.X;
                    yEnd      = e.Y;
                    deltaX    = xEnd - xStart;
                    deltaY    = yEnd - yStart;
                    rectangle = new Rectangle(chosenColor, new Point(xStart, yStart, chosenColor), deltaX, deltaY);
                    rectangle.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    RenderRefresh();
                }
                break;

                case Shapes.Square:
                    deltaX = xEnd - xStart;
                    Square square = new Square(BackColor, new Point(xStart, yStart), deltaX);
                    square.Draw(toolStripContainer1.ContentPanel.CreateGraphics());

                    xEnd   = e.X;
                    yEnd   = e.Y;
                    deltaX = xEnd - xStart;
                    square = new Square(chosenColor, new Point(xStart, yStart, chosenColor), deltaX);
                    square.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    RenderRefresh();
                    break;

                case Shapes.Ellipsis:
                    deltaX = xEnd - xStart;
                    deltaY = yEnd - yStart;

                    if (ctrlKeyDown)
                    {
                        deltaX = deltaY = Math.Max(deltaX, deltaY);
                    }

                    Ellipsis ellipsis = new Ellipsis(BackColor, new Point(xStart, yStart, chosenColor), deltaX, deltaY);
                    ellipsis.Draw(toolStripContainer1.ContentPanel.CreateGraphics());

                    xEnd   = e.X;
                    yEnd   = e.Y;
                    deltaX = xEnd - xStart;
                    deltaY = yEnd - yStart;

                    if (ctrlKeyDown)
                    {
                        deltaY = deltaX = Math.Max(deltaX, deltaY);
                    }

                    ellipsis = new Ellipsis(chosenColor, new Point(xStart, yStart, chosenColor), deltaX, deltaY);
                    ellipsis.Draw(toolStripContainer1.ContentPanel.CreateGraphics());
                    RenderRefresh();
                    break;
                }
            }
        }