Beispiel #1
0
        private void FillTable_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();

            int style;

            for (int i = 0; i < 10; i++)
            {
                style = rnd.Next(0, 3);
                Model.IFigure figureModel = null;
                switch (_figure)
                {
                case 0:
                    var circle = new Circle();
                    circle.Radius = Convert.ToInt32(rnd.Next(0, 10));
                    circle.X      = Convert.ToInt32(rnd.Next(0, 100));
                    circle.Y      = Convert.ToInt32(rnd.Next(0, 100));
                    figureModel   = circle;
                    break;

                case 1:
                    var rectangle = new Model.Rectangle();
                    rectangle.Length = Convert.ToInt32(rnd.Next(0, 10));
                    rectangle.Width  = Convert.ToInt32(rnd.Next(0, 10));
                    rectangle.X      = Convert.ToInt32(rnd.Next(0, 100));
                    rectangle.Y      = Convert.ToInt32(rnd.Next(0, 100));
                    figureModel      = rectangle;
                    break;

                case 2:
                    var triangle = new Triangle();
                    triangle.Side1 = Convert.ToInt32(rnd.Next(0, 10));
                    triangle.Side2 = Convert.ToInt32(rnd.Next(0, 10));
                    triangle.Side3 = Convert.ToInt32(rnd.Next(0, 10));
                    triangle.X     = Convert.ToInt32(rnd.Next(0, 100));
                    triangle.Y     = Convert.ToInt32(rnd.Next(0, 100));
                    figureModel    = triangle;
                    break;
                }
                Figure       = figureModel;
                DialogResult = DialogResult.OK;
                _figure      = (rnd.Next(0, 3));
                IFigure figure = null;
                figure = Figure;
                ListFigures.list.Add(figure);
                var row = _table.NewRow();
                row[0] = figure.Name;
                row[1] = figure.X;
                row[2] = figure.Y;
                row[3] = figure.CalculationArea();
                _table.Rows.Add(row);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Нажатие по кнопке "Добавить фигуру"
        /// </summary>
        private void AddShape(object sender, EventArgs e)
        {
            AddModifyFigureForm f      = new AddModifyFigureForm();
            IFigure             figure = null;

            f.ShowDialog();
            if (f.DialogResult == DialogResult.OK)
            {
                figure = f.Figure;
                ListFigures.list.Add(figure);
                var row = _table.NewRow();
                row[0] = figure.Name;
                row[1] = figure.X;
                row[2] = figure.Y;
                row[3] = figure.CalculationArea();
                _table.Rows.Add(row);
                FigureGridView.Update();
            }
        }