private void gridDiveProfil_CellEndEdit(object sender, System.Windows.Forms.DataGridViewCellEventArgs e)
        {
            Data.DiveSegment segment = diving.SegmentsList[e.RowIndex];
            string           colName = gridDiveProfil.Columns[e.ColumnIndex].Name;
            double           iD      = Double.Parse(gridDiveProfil["initialD", e.RowIndex].Value.ToString());
            double           fD      = Double.Parse(gridDiveProfil["finialD", e.RowIndex].Value.ToString());
            double           t       = Double.Parse(gridDiveProfil["time", e.RowIndex].Value.ToString());

            switch (colName)
            {
            case "gasName":
                string      newGasName = (string)gridDiveProfil["gasName", e.RowIndex].Value;
                Data.GasMix newGas     = availableGases.Find(g => g.Name == newGasName);
                if (newGas != null)
                {
                    diving.ChangeSegment(segment.Name, iD, fD, t, newGas);
                }
                else
                {
                    throw new Exception("gridDiveProfil_CellEndEdit(object sender, DataGridViewCellEventArgs e): Invalid Gas");
                }
                break;

            case "time":
                diving.ChangeSegment(segment.Name, iD, fD, t);
                updateChartAndGridDiveProfile();
                break;

            case "runTime":
                double rt = Double.Parse(gridDiveProfil["runTime", e.RowIndex].Value.ToString());
                if (e.RowIndex > 0)
                {
                    t = rt - diving.getRunTime(e.RowIndex - 1);
                    if (t < 0)
                    {
                        t = 0;
                    }
                    diving.ChangeSegment(segment.Name, iD, fD, t);
                }
                else
                {
                    diving.ChangeSegment(segment.Name, iD, fD, rt);
                }
                updateChartAndGridDiveProfile();
                break;

            case "finialD":
            case "initialD":
            default:
            {
                string newName  = diving.ChangeSegment(segment.Name, iD, fD, t);
                int    rowIndex = diving.GetSegmentIndex(newName);
                updateChartAndGridDiveProfile(true, 0, 0);    // e.ColumnIndex, rowIndex);
            }
            break;
            }
        }
 private void setSegmentToGrid(int tableRow, Data.DiveSegment segment)
 {
     System.Windows.Forms.DataGridViewCell defautCell = gridDiveProfil["initialD", tableRow];
     defautCell.Value = segment.InitialDepth;
     defautCell       = gridDiveProfil["finialD", tableRow];
     defautCell.Value = segment.FinialDepth;
     defautCell       = gridDiveProfil["time", tableRow];
     defautCell.Value = segment.Time;
     defautCell       = gridDiveProfil["runTime", tableRow];
     defautCell.Value = diving.getRunTime(0);
     defautCell       = gridDiveProfil["gasName", tableRow];
     defautCell.Value = segment.GasName;
 }