Exemplo n.º 1
0
        private void btnCreateNew_Click(object sender, EventArgs e)
        {
            if (FiguresCount >= 99)
            {
                MessageBox.Show("Достигнут предел количесвта объектов!");
                return;
            }

            Graphics graphics = pnMain.CreateGraphics();

            CurrentFigureIndex = FiguresCount;

            if (cbFigureType.SelectedIndex == 0)
            {
                figures[CurrentFigureIndex] = new CCircle(graphics, pnMain.Width / 2, pnMain.Height / 2, 50);
                cbCircle.Items.Add("Фигура №" + (FiguresCount).ToString() + " [круг]");
            }

            else if (cbFigureType.SelectedIndex == 1)
            {
                figures[CurrentFigureIndex] = new CRectangle(graphics, pnMain.Width / 2, pnMain.Height / 2, 100, 50);
                cbCircle.Items.Add("Фигура №" + (FiguresCount).ToString() + " [прямоугольник]");
            }
            else if (cbFigureType.SelectedIndex == 2)
            {
                figures[CurrentFigureIndex] = new CTriangle(graphics, pnMain.Width / 2, pnMain.Height / 2, 100);
                cbCircle.Items.Add("Фигура №" + (FiguresCount).ToString() + " [треугольник]");
            }
            figures[CurrentFigureIndex].Show();
            FiguresCount++;
            cbFigureType.SelectedIndex = FiguresCount - 1;
        }
Exemplo n.º 2
0
        private void btnCreateNew_Click(object sender, EventArgs e)
        {
            if (FiguresCount >= 99)
            {
                MessageBox.Show("Досягнуто межі кількості об'єктів!");
                return;
            }

            Graphics graphics = pnMain.CreateGraphics();

            CurrentFigureIndex = FiguresCount;

            if (cbFigureType.SelectedIndex == 0)
            {
                figures[CurrentFigureIndex] =
                    new CCircle(graphics, pnMain.Width / 2, pnMain.Height / 2,
                                50);
                cbCircle.Items.Add("Фігура №" + (FiguresCount).ToString() +
                                   " [коло]");
            }

            else if (cbFigureType.SelectedIndex == 1)
            {
                figures[CurrentFigureIndex] = new CRectangle(graphics,
                                                             pnMain.Width / 2, pnMain.Height / 2, 100, 50);
                cbCircle.Items.Add("Фігура №" + (FiguresCount).ToString() +
                                   " [прямокутник]");
            }
            else if (cbFigureType.SelectedIndex == 2)
            {
                figures[CurrentFigureIndex] = new CTriangle(graphics,
                                                            pnMain.Width / 2, pnMain.Height / 2, 100);
                cbCircle.Items.Add("Фігура №" + (FiguresCount).ToString() +
                                   " [трикутник]");
            }
            figures[CurrentFigureIndex].Show();
            FiguresCount++;
            cbFigureType.SelectedIndex = FiguresCount - 1;
        }
Exemplo n.º 3
0
        private void btnCreateNew_Click(object sender, EventArgs e)
        {
            if (FiguresCount >= 99)
            {
                MessageBox.Show("The limit of the number of objects was reached!!");
                return;
            }

            Graphics graphics = pnMain.CreateGraphics();

            CurrentFigureIndex = FiguresCount;

            if (cbFigureType.SelectedIndex == 0)
            {
                figures[CurrentFigureIndex] =
                    new CCircle(graphics, pnMain.Width / 2, pnMain.Height / 2,
                                50);
                cbCircle.Items.Add("Figure №" + (FiguresCount).ToString() +
                                   " [Circle]");
            }

            else if (cbFigureType.SelectedIndex == 1)
            {
                figures[CurrentFigureIndex] = new CRectangle(graphics,
                                                             pnMain.Width / 2, pnMain.Height / 2, 100, 50);
                cbCircle.Items.Add("Figure №" + (FiguresCount).ToString() +
                                   " [Rectengle]");
            }
            else if (cbFigureType.SelectedIndex == 2)
            {
                figures[CurrentFigureIndex] = new CTriangle(graphics,
                                                            pnMain.Width / 2, pnMain.Height / 2, 100);
                cbCircle.Items.Add("Figure №" + (FiguresCount).ToString() +
                                   " [Triangle]");
            }
            figures[CurrentFigureIndex].Show();
            FiguresCount++;
            cbFigureType.SelectedIndex = FiguresCount - 1;
        }