Example #1
0
        private void EraseCenterMyCoordinate()
        {
            List <Point> points = MyCoordinate.DrawMyCoordinateAxis();

            graphics.DrawLine(eraser, new Point(MyCoordinate.centerPoint.X, 0), new Point(MyCoordinate.centerPoint.X, MyCoordinate.centerPoint.Y * 2));
            graphics.DrawLine(eraser, new Point(0, MyCoordinate.centerPoint.Y), new Point(MyCoordinate.centerPoint.X * 2, MyCoordinate.centerPoint.Y));
        }
Example #2
0
        private void DrawMyShapeWithLabel(List <Point> points, bool isDefaultStyle)
        {
            if (isDefaultStyle)
            {
                DrawMyShape(points, MyCoordinate.scale);
            }
            else
            {
                DrawMyShape(points, 1);
            }
            Label labelStart = new Label();

            labelStart.Location = new Point(points[0].X + 10, points[0].Y);
            labelStart.Text     = "(" + MyCoordinate.ConvertToMyPoint(points[0]).X + ", " + MyCoordinate.ConvertToMyPoint(points[0]).Y + ")";
            labelStart.SendToBack();
            labelStart.ForeColor = Color.Red;
            labelStart.AutoSize  = true;
            drawPanel.Controls.Add(labelStart);
            labelStart.Show();

            Label labelEnd = new Label();

            labelEnd.Location = new Point(points[points.Count - 1].X + 10, points[points.Count - 1].Y);
            labelEnd.Text     = "(" + MyCoordinate.ConvertToMyPoint(points[points.Count - 1]).X + ", " + MyCoordinate.ConvertToMyPoint(points[points.Count - 1]).Y + ")";
            labelEnd.SendToBack();
            labelEnd.ForeColor = Color.Red;
            labelEnd.AutoSize  = true;
            drawPanel.Controls.Add(labelEnd);
            labelEnd.Show();
        }
Example #3
0
        private void DrawCenterMyCoordinate3D()
        {
            EraseMyCoordinate();
            List <Point> netPixel = MyCoordinate.Draw3DNetPixel();
            Pen          redPen   = new Pen(Color.Red, 5);
            Pen          grayPen  = new Pen(Color.LightGray, 1);

            for (int i = 0; i < netPixel.Count - 1; i++)
            {
                if (netPixel.ElementAt(i).X == netPixel.ElementAt(i + 1).X ||
                    netPixel.ElementAt(i).Y == netPixel.ElementAt(i + 1).Y)
                {
                    graphics.DrawLine(grayPen, netPixel.ElementAt(i), netPixel.ElementAt(i + 1));
                }
            }
            DrawMyShape(MyCoordinate.DrawMyCoordinateAxis3D(), 1);
        }
Example #4
0
        private void DrawCenterMyCoordinate()
        {
            EraseMyCoordinate();
            List <Point> netPixel = MyCoordinate.DrawNetPixel();
            Pen          redPen   = new Pen(Color.Red, 5);
            Pen          grayPen  = new Pen(Color.LightGray, 1);

            for (int i = 0; i < netPixel.Count - 1; i++)
            {
                if (netPixel.ElementAt(i).X == netPixel.ElementAt(i + 1).X ||
                    netPixel.ElementAt(i).Y == netPixel.ElementAt(i + 1).Y)
                {
                    graphics.DrawLine(grayPen, netPixel.ElementAt(i), netPixel.ElementAt(i + 1));
                }
            }
            EraseCenterMyCoordinate();
            graphics.DrawLine(redPen, new Point(MyCoordinate.centerPoint.X, 0), new Point(MyCoordinate.centerPoint.X, MyCoordinate.centerPoint.Y * 2));
            graphics.DrawLine(redPen, new Point(0, MyCoordinate.centerPoint.Y), new Point(MyCoordinate.centerPoint.X * 2, MyCoordinate.centerPoint.Y));
        }
Example #5
0
        private void drawPanel_MouseDown(object sender, MouseEventArgs e)
        {
            // xu ly ve doan thang
            if (drawLine == false)
            {
                moving   = true;
                point1.X = e.X;
                point1.Y = e.Y;
            }
            else
            {
                Label label = new Label();
                Point point = MyCoordinate.ConvertToMyPoint(new Point(e.X, e.Y));
                label.Location = new Point(e.X + 10, e.Y);
                label.Text     = "(" + MyCoordinate.ConvertToMyPoint(point).X + ", " + MyCoordinate.ConvertToMyPoint(point).Y + ")";
                label.Text     = "(" + point.X + ", " + point.Y + ")";
                label.SendToBack();
                label.ForeColor = Color.Red;
                label.AutoSize  = true;
                drawPanel.Controls.Add(label);
                label.Show();
                if (isPoint1 == false)
                {
                    this.transformationComboBox.Enabled = false;
                    point1.X = e.X;
                    point1.Y = e.Y;
                    isPoint1 = true;
                    if (isEllipseCenter == false && lineStyleComboBox.SelectedIndex == 6)
                    {
                        centerPoint     = point1;
                        isPoint1        = false;
                        isEllipseCenter = true;
                    }
                }
                else if (isPoint1 && !isPoint2)
                {
                    this.transformationComboBox.Enabled = true;
                    point2.X = e.X;
                    point2.Y = e.Y;
                    isPoint2 = true;
                    Point        firstPoint   = point1;
                    Point        seccondPoint = point2;
                    List <Point> points       = DrawLine.DDA(firstPoint, seccondPoint);

                    switch (lineStyleComboBox.SelectedIndex)
                    {
                    case 0:
                    {
                        DrawMyShape(points);
                        if (hasArrowCheckBox.Checked)
                        {
                            DrawArrow(point1, point2, 3);
                        }
                        break;
                    }

                    case 1:
                    {
                        points = DrawLine.DashLine(points);
                        DrawMyShape(points, 1);
                        if (hasArrowCheckBox.Checked)
                        {
                            DrawArrow(point1, point2, 3);
                        }
                        break;
                    }

                    case 2:
                    {
                        points = DrawLine.DashedLineWithOneDot(points);
                        DrawMyShape(points, 1);
                        if (hasArrowCheckBox.Checked)
                        {
                            DrawArrow(point1, point2, 3);
                        }

                        break;
                    }

                    case 3:
                    {
                        points = DrawLine.DashLineWithTwoDot(points);
                        DrawMyShape(points, 1);
                        if (hasArrowCheckBox.Checked)
                        {
                            DrawArrow(point1, point2, 3);
                        }
                        break;
                    }

                    case 4:
                    {
                        points = DrawRecangle.DDA(point1, point2);
                        DrawMyShape(points);
                        break;
                    }

                    case 5:
                    {
                        int radius = (int)Math.Sqrt(Math.Pow(point2.X - point1.X, 2) + Math.Pow(point2.Y - point1.Y, 2));
                        points = DrawCircle.circleBrese(point1.X, point1.Y, radius);
                        DrawMyShape(points);
                        break;
                    }

                    case 6:
                    {
                        int radiusX = (int)Math.Sqrt(Math.Pow(point1.X - centerPoint.X, 2) + Math.Pow(point1.Y - centerPoint.Y, 2));
                        int radiusY = (int)Math.Sqrt(Math.Pow(point2.X - centerPoint.X, 2) + Math.Pow(point2.Y - centerPoint.Y, 2));;
                        points = DrawEllipse.MidPoint(centerPoint, radiusX, radiusY);
                        DrawMyShape(points);
                        isEllipseCenter = false;
                        break;
                    }

                    default:
                        break;
                    }

                    shapesPoints.Add(points);
                    defaultPoints = shapesPoints.ElementAt(shapesPoints.Count - 1);
                    isPoint1      = isPoint2 = false;
                }
            }
        }