Example #1
0
        /// <summary>
        /// function opens CellForm window with selected Cell to change data of cell.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">event arguments</param>
        private void buttonChangeCell_Click(object sender, EventArgs e)
        {
            int index = this.listBoxCells.SelectedIndex;

            if (index != -1)
            {
                CellForm form = new CellForm(list_cells[index]);
                form.ShowDialog();

                if (form.DialogResult == DialogResult.OK)
                {
                    Cell myCell = form.my_cell;
                    if (myCell == null)
                    {
                        this.errorMessages("Somehow the cell object was empty, try again.");
                    }
                    else
                    {
                        this.listBoxCells.Items.RemoveAt(index);
                        this.list_cells.RemoveAt(index);
                        this.listBoxCells.Items.AddRange(new object[] { (myCell.cell_name + " " + myCell.cell_color) });
                        this.list_cells.Add(myCell);
                    }
                }
            }
            else
            {
                this.errorMessages("You need to select a Cell to change it!");
            }
        }
Example #2
0
        /// <summary>
        /// function reacts on add cell button click, creates a new cell from and on sucess of that form saves the cell
        /// in the hidden list and the list box.
        /// </summary>
        /// <param name="sender">sender object</param>
        /// <param name="e">event arguments</param>
        private void buttonAddCell_Click(object sender, EventArgs e)
        {
            CellForm form = new CellForm();

            form.ShowDialog();
            //check for sucess
            if (form.DialogResult == DialogResult.OK)
            {
                Cell myCell = form.my_cell;
                if (myCell == null)
                {
                    this.errorMessages("Somehow the cell object was empty, try again.");
                }
                else
                {
                    this.listBoxCells.Items.AddRange(new object[] { (myCell.cell_name + " " + myCell.cell_color) });
                    this.list_cells.Add(myCell);
                }
            }
        }