Example #1
0
        private void getInfoShape()
        {
            if (choosedShape != null)
            {
                frm.richTextBox1.Clear();
                frm.richTextBox1.AppendText("Tên hình ảnh: " + choosedShape.getName() + "\n");
                frm.richTextBox1.AppendText("Màu sắc: " + choosedShape.getColor().ToString() + "\n");
                switch (choosedShape.getTypeDraw())
                {
                case TypeDraw.Line:
                    Line line = (Line)choosedShape;
                    frm.richTextBox1.AppendText("Điểm đầu: " + line.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm cuối: " + line.getEndPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài: " + line.getLength().ToString());
                    break;

                case TypeDraw.Circle:
                    Circle circle = (Circle)choosedShape;
                    frm.richTextBox1.AppendText("Tâm: " + circle.getCenterPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính: " + circle.getRadius().ToString());
                    break;

                case TypeDraw.Ellipse:
                    Ellipse ellipse = (Ellipse)choosedShape;
                    frm.richTextBox1.AppendText("Tâm: " + ellipse.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính nhỏ: " + ellipse.getWidthRadius().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính lớn: " + ellipse.getHeightRadius().ToString());
                    break;

                case TypeDraw.Parallelogram:
                    Parallelogram parallelogram = (Parallelogram)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + parallelogram.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + parallelogram.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + parallelogram.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + parallelogram.getPoint4().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài:" + parallelogram.getHeight().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều rộng:" + parallelogram.getWidth().ToString() + "\n");
                    break;

                case TypeDraw.Rectangle:
                    Rectangle rectangle = (Rectangle)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + rectangle.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + rectangle.getPoint12().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + rectangle.getEndPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + rectangle.getPoint21().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài:" + rectangle.getHeigth() + "\n");
                    frm.richTextBox1.AppendText("Chiều rộng:" + rectangle.getWidth() + "\n");
                    break;

                case TypeDraw.Triangle:
                    Triangle triangle = (Triangle)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I" + triangle.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II" + triangle.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III" + triangle.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh I: " + triangle.getLength1() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh II: " + triangle.getLength2() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh III: " + triangle.getLength3() + "\n");
                    break;

                case TypeDraw.Square:
                    Square square = (Square)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + square.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + square.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + square.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + square.getPoint4().ToString() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh: " + square.getEdge().ToString() + "\n");
                    break;

                case TypeDraw.Cube:
                    Cube cube = (Cube)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + cube.getList3D().ElementAt(0).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + cube.getList3D().ElementAt(1).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + cube.getList3D().ElementAt(2).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + cube.getList3D().ElementAt(3).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ V: " + cube.getList3D().ElementAt(4).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + cube.getList3D().ElementAt(5).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VII: " + cube.getList3D().ElementAt(6).ToString() + "\n");
                    break;

                case TypeDraw.Cylinder:
                    Cylinder cylinder = (Cylinder)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + cylinder.getList3D().ElementAt(0).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + cylinder.getList3D().ElementAt(1).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + cylinder.getList3D().ElementAt(2).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + cylinder.getList3D().ElementAt(3).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ V: " + cylinder.getList3D().ElementAt(4).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + cylinder.getList3D().ElementAt(5).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VII: " + cylinder.getList3D().ElementAt(6).ToString() + "\n");
                    break;
                }
            }
        }
Example #2
0
        public void MidPoint_Ellipse1(Ellipse ellipse)//,bool dottedEllipseFlag=false)
        {
            bool dottedEllipseFlag = ellipse.getDottedEllipseFlag();
            //int x1, y1, x2, y2, centerX, centerY;
            int x, y, fx, fy, a2, b2, p, a, b;

            //if (!ellipse.getChangeFlag())
            //{
            //a = (int)ellipse.getWidthRadius();
            //b = (int)ellipse.getHeightRadius();
            //}
            //else
            //{


            //if (Math.Abs((int)ellipse.getEndHightPoint().Y) > Math.Abs((int)ellipse.getEndWidthPoint().Y))
            //{
            a = (int)ellipse.getHeightRadius();
            b = (int)ellipse.getWidthRadius();
            //}
            //else
            //{
            //    b = (int)ellipse.getHeightRadius();
            //    a = (int)ellipse.getWidthRadius();
            //}


            //}

            a2 = a * a;
            b2 = b * b;
            x  = 0;
            y  = b;
            fx = 0;
            fy = 2 * a2 * y;
            put4pixel(x, y, ellipse.getStartPoint().X, ellipse.getStartPoint().Y, ellipse.getColor());
            p = round(b2 - (a2 * b) + (0.25 * a2));//p=b2 - a2*b +a2/4
            //int count = 0;
            while (fx < fy)
            {
                x++;
                fx += 2 * b2;
                //delay(50);
                if (p < 0)
                {
                    p += b2 * (2 * x + 3);//p=p + b2*(2x +3)
                }
                else
                {
                    y--;
                    p  += b2 * (2 * x + 3) + a2 * (2 - 2 * y);//p=p +b2(2x +3) +a2(2-2y)
                    fy -= 2 * a2;
                }
                //if (dottedEllipseFlag && count % 20 == 0)
                //    put4pixel(x, y, ellipse.getStartPoint().X, ellipse.getStartPoint().Y, ellipse.getColor(), dottedEllipseFlag);
                //else
                put4pixel(x, y, ellipse.getStartPoint().X, ellipse.getStartPoint().Y, ellipse.getColor());
                //count++;
            }
            p = round(b2 * (x + 0.5) * (x + 0.5) + a2 * (y - 1) * (y - 1) - a2 * b2);
            //
            //count = 0;
            while (y > 0)
            {
                y--;
                fy -= 2 * a2;
                // delay(50);
                if (p >= 0)
                {
                    p += a2 * (3 - 2 * y); //p=p +a2(3-2y)
                }
                else
                {
                    x++;
                    fx += 2 * b2;
                    p  += b2 * (2 * x + 2) + a2 * (3 - 2 * y);//p=p+ b2(2x +2) + a2(3-2y)
                }
                //if (dottedEllipseFlag && count % 20 == 0)
                put4pixel(x, y, ellipse.getStartPoint().X, ellipse.getStartPoint().Y, ellipse.getColor());//, dottedEllipseFlag);
                //else if (dottedEllipseFlag && count % 20 == 0)
                //put4pixel(ellipse.getStartPoint().X, ellipse.getStartPoint().Y, x, y, ellipse.getColor());

                //count++;
            }
        }