private void addGassesToXMLSpreadsheet2003(ref System.Text.StringBuilder stringBuilder, List <Data.GasMix> gases)
        {
            stringBuilder.Append("<Worksheet ss:Name=\"" + AnalizatorNurkowaniaWFA.Properties.Resources.gasesMixName + "\">\n");
            stringBuilder.Append(" <Table>\n");
            Data.GasMix trimix = gases.Find(item => item.Helium > Double.Epsilon);
            stringBuilder.Append("  <Row>\n");

            stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.gasNameExcel));
            stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.O2NameExcel));
            stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.N2NameExcel));
            if (trimix != null)
            {
                stringBuilder.Append(cellXMLSpreadsheet2003(AnalizatorNurkowaniaWFA.Properties.Resources.HeNameExcel));
            }
            stringBuilder.Append("  </Row>\n");

            foreach (Data.GasMix gas in gases)
            {
                stringBuilder.Append("  <Row>\n");
                stringBuilder.Append(cellXMLSpreadsheet2003(gas.Name));
                stringBuilder.Append(cellXMLSpreadsheet2003(gas.Oxygen));
                stringBuilder.Append(cellXMLSpreadsheet2003(gas.Nitrogen));
                if (trimix != null)
                {
                    stringBuilder.Append(cellXMLSpreadsheet2003(gas.Name));
                }
                stringBuilder.Append("  </Row>\n");
            }
            stringBuilder.Append(" </Table>\n");
            stringBuilder.Append("</Worksheet>\n");
        }
        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;
            }
        }