public void calcArea()
        {
            Rectangel rectangel = new Rectangel();

            rectangel.length = double.Parse(rectView.lengthText);
            rectangel.width  = double.Parse(rectView.widthText);

            rectView.areaText = rectangel.calculateArea().ToString();
        }
Beispiel #2
0
        protected override void OnPaint(PaintEventArgs pe)
        {
            Rectangle rect = this.ClientRectangle;
            Graphics  g    = pe.Graphics;

            ProgressBarRenderer.DrawHorizontalBar(g, rect);
            if (this.Value > 0)
            {
                Rectangle clip = new Rectangel(rect.x, rect.Y, (int)Math.Round(((float)this.Value / this.Maximum) * rect.Width), rect.Height);
                PregressBarRenderer.DrawHorizontalBar(g, clip);
            }
            using (Font f = new Font(FontFamily.GenericMonospace, 10))
            {
                SizeF size     = g.MeasureString(string.Format("{0} %", this.Value), f);
                Point location = new Point((int)((rect.Width / 2) - (size.Width / 2)), (int)((rect.Height / 2) - (size.Height / 2) + 2));
                g.DrawString(string.Format("{0} %", thisValue), f, Brushes, Black, location);
            }
            base.OnPaint(pe);
        }
    static void Main()
    {
        string typeOfShape = Console.ReadLine();
        Shape  shape       = null;

        if (typeOfShape == "Square")
        {
            int    side   = int.Parse(Console.ReadLine());
            Square square = new Square(side);
            shape = square;
        }
        else
        {
            int       width     = int.Parse(Console.ReadLine());
            int       length    = int.Parse(Console.ReadLine());
            Rectangel rectangle = new Rectangel(length, width);
            shape = rectangle;
        }
        CoreDraw.Draw(shape);
    }
Beispiel #4
0
        public static Shape TimHinhVe(OpenGLControl openGLControl, int chooseImg, Point start, Point end, Color userChoose, float thickness)
        {
            Shape imgToDraw = null;

            //Xem lựa chọn của user và chọn hinh vẽ
            if (start.X != -1000)
            {
                if (start == end)
                {
                    chooseImg = -1;
                }
                switch (chooseImg)
                {
                case 0:
                    imgToDraw = new Line(start, end, thickness, userChoose);
                    break;

                case 1:
                    imgToDraw = new Circle(start, end, thickness, userChoose);
                    break;

                case 2:
                    imgToDraw = new Eclipse(start, end, thickness, userChoose);
                    break;

                case 3:
                    imgToDraw = new Rectangel(start, end, thickness, userChoose);
                    break;

                case 4:
                    imgToDraw = new EqualTriangle(start, end, thickness, userChoose);
                    break;

                case 5:
                    imgToDraw = new EqualPentagon(start, end, thickness, userChoose);
                    break;

                case 6:
                    imgToDraw = new EqualHexagon(start, end, thickness, userChoose);
                    break;

                default:
                    imgToDraw = null;
                    break;
                }
            }
            if (imgToDraw != null)
            {
                if (listDraw.Count > 0)
                {
                    var tmpPop = listDraw.Pop();
                    if (tmpPop.upLeft == imgToDraw.upLeft && tmpPop.GetType() == imgToDraw.GetType())
                    {
                        imgToDraw.thoiGianVe = tmpPop.thoiGianVe;
                    }
                    else
                    {
                        listDraw.Push(tmpPop);
                    }
                }
                listDraw.Push(imgToDraw);
            }
            return(imgToDraw);
        }