Пример #1
0
        /// <summary>
        /// Обработчик кнопки "Изменить данные"
        /// </summary>
        private void изменитьДанныеToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Изменить обьект?", "Изменение обьекта", MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (TableFigure.CurrentRow != null)
                {
                    foreach (DataGridViewCell cell in TableFigure.SelectedCells)
                    {
                        var     figureForm = new FigureForm();
                        var     a          = TableFigure.SelectedCells[0].RowIndex;
                        IFigure figure     = ListFigure.List[a];
                        if (figureForm.ShowDialog() == DialogResult.OK)
                        {
                            TableFigure.Rows.RemoveAt(cell.RowIndex);

                            ListFigure.List.Add(figure);
                            var row = _tablefigure.NewRow();
                            row[0] = figure.ToString();
                            row[1] = figure.CalculateVolume();
                            row[2] = figure.X;
                            row[3] = figure.Y;
                            row[4] = figure.Z;

                            _tablefigure.Rows.Add(row);
                            TableFigure.Update();
                        }
                    }
                }
            }
        }
Пример #2
0
        private void ButtonModify_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Изменить обьект?", "Изменение обьекта", MessageBoxButtons.YesNo,
                                                  MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                if (TableFigure.CurrentRow != null)
                {
                    foreach (DataGridViewCell cell in TableFigure.SelectedCells)
                    {
                        FigureForm f      = new FigureForm();
                        var        a      = TableFigure.SelectedCells[0].RowIndex;
                        IFigure    figure = ListFigure.List[a];
                        f.ShowDialog();
                        if (f.DialogResult == DialogResult.OK)
                        {
                            TableFigure.Rows.RemoveAt(cell.RowIndex);

                            figure = f.Figures;
                            ListFigure.List.Add(figure);
                            var row = _tablefigure.NewRow();
                            row[0] = figure.Name;
                            row[1] = figure.CalculateVolume();

                            _tablefigure.Rows.Add(row);
                            TableFigure.Update();
                        }
                    }
                }
            }
        }
Пример #3
0
        // Создание строк
        private void ButtonCreate_Click(object sender, EventArgs e)
        {
            var figureForm = new FigureForm();

            if (figureForm.ShowDialog() == DialogResult.OK)
            //добавить фигуру в таблицу
            {
                var figure = figureForm.Figure;
                ListFigure.List.Add(figure);
                var row = _tablefigure.NewRow();
                row[0] = figure.ToString();
                row[1] = figure.CalculateVolume();
                row[2] = figure.X;
                row[3] = figure.Y;
                row[4] = figure.Z;
                _tablefigure.Rows.Add(row);
                TableFigure.Update();
            }
        }