private void readXML() { XmlReader xr = new XmlTextReader(path); i = 0; while (xr.Read()) { if (xr.NodeType == XmlNodeType.Element) { if (xr.AttributeCount > 0) { if (xr.Name == "SystemData") { while (xr.MoveToNextAttribute()) { switch (xr.Name) { case "projectName": sysData.Project = xr.Value; break; case "columnGrid": sysData.ColumGrid = xr.Value; break; case "method": sysData.Method = xr.Value; break; case "areaRatio": sysData.AreaRatio = Convert.ToDouble(xr.Value); break; case "columnRadius": sysData.ColumnRadius = Convert.ToDouble(xr.Value); break; case "widening": sysData.Rgeo = Convert.ToDouble(xr.Value); break; case "elongationStiffness": sysData.J = Convert.ToDouble(xr.Value); break; case "load": sysData.TotalLoad = Convert.ToDouble(xr.Value); break; case "athmosphericPressure": sysData.Pref = Convert.ToDouble(xr.Value); break; case "ohde": sysData.M = Convert.ToDouble(xr.Value); break; case "poisson": sysData.Poisson = Convert.ToDouble(xr.Value); break; case "columnDistance": sysData.S = Convert.ToDouble(xr.Value); break; } } } if (xr.AttributeCount > 0) { if (xr.Name == "ColumnMaterial") { while (xr.MoveToNextAttribute()) { switch (xr.Name) { case "effectivShearStrength": columnMaterial.Phis = Convert.ToDouble(xr.Value); break; case "specificWeight": columnMaterial.Gammas = Convert.ToDouble(xr.Value); break; } } } } if (xr.AttributeCount > 0) { if (xr.Name == "Geotextile") { while (xr.MoveToNextAttribute()) { switch (xr.Name) { case "shortStrength": geo.Rbk0 = Convert.ToDouble(xr.Value); break; case "a1": geo.A1 = Convert.ToDouble(xr.Value); break; case "a2": geo.A2 = Convert.ToDouble(xr.Value); break; case "a3": geo.A3 = Convert.ToDouble(xr.Value); break; case "a4": geo.A4 = Convert.ToDouble(xr.Value); break; case "a5": geo.A5 = Convert.ToDouble(xr.Value); break; case "safetyFactor": geo.GammaM = Convert.ToDouble(xr.Value); break; } } } } if (xr.AttributeCount > 0) { if (xr.Name == "soilLayer_" + i) { SoilMaterial soil = new SoilMaterial(); while (xr.MoveToNextAttribute()) { switch (xr.Name) { case "layerThickness": soil.LayerThickness = Convert.ToDouble(xr.Value); break; case "referenceModul": soil.ReferenceEModul = Convert.ToDouble(xr.Value); break; case "effectiveCohesion": soil.EffectiveCohesion = Convert.ToDouble(xr.Value); break; case "effectiveShearStrength": soil.EffectiveShearStrengthLayer = Convert.ToDouble(xr.Value); break; case "specificWeight": soil.SpecificWeightLayer = Convert.ToDouble(xr.Value); break; } } soilLayer.Add(soil); i++; } } if (xr.AttributeCount > 0) { if (xr.Name == "Time_stamp") { while (xr.MoveToNextAttribute()) { switch (xr.Name) { case "Saved_file_on": break; } } } } } } } xr.Close(); }
//set soil layers to object, put in a list, and if value changed, check wich index and change value #region set soil layers public void set_SoilLayers(object sender, DataGridViewCellEventArgs e) { try { int rowIndex = 0; int cellIndex = 0; double LayerThickness = 0; double ReferenceEModul = 0; double EffectiveCohesion = 0; double EffectiveShearStrengthLayer = 0; double SpecificWeightLayer = 0; if (dgvSoilProperties.CurrentCell != null) { rowIndex = dgvSoilProperties.CurrentCell.RowIndex; cellIndex = dgvSoilProperties.CurrentCell.ColumnIndex; LayerThickness = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["layer"].Value); ReferenceEModul = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["refEModulLayer"].Value); EffectiveCohesion = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveCohesionLayer"].Value); EffectiveShearStrengthLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveShearStrengthLayer"].Value); SpecificWeightLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["specificWeightLayer"].Value); if (LayerThickness == 0 && ReferenceEModul == 0 && EffectiveCohesion == 0 && EffectiveShearStrengthLayer == 0 && SpecificWeightLayer == 0) { soilList.RemoveAt(rowIndex); dgvSoilProperties.Rows.RemoveAt(rowIndex); } if (LayerThickness != 0 && ReferenceEModul != 0 && EffectiveCohesion != 0 && EffectiveShearStrengthLayer != 0 && SpecificWeightLayer != 0) { if (rowIndex > soilList.Count - 1) { LayerThickness = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["layer"].Value); ReferenceEModul = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["refEModulLayer"].Value); EffectiveCohesion = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveCohesionLayer"].Value); EffectiveShearStrengthLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveShearStrengthLayer"].Value); SpecificWeightLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["specificWeightLayer"].Value); soilList.Add(soilLayer = new SoilMaterial(LayerThickness, ReferenceEModul, EffectiveCohesion, EffectiveShearStrengthLayer, SpecificWeightLayer)); } else { soilList[rowIndex].LayerThickness = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["layer"].Value); soilList[rowIndex].ReferenceEModul = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["refEModulLayer"].Value); soilList[rowIndex].EffectiveCohesion = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveCohesionLayer"].Value); soilList[rowIndex].EffectiveShearStrengthLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["effectiveShearStrengthLayer"].Value); soilList[rowIndex].SpecificWeightLayer = Convert.ToDouble(dgvSoilProperties.Rows[rowIndex].Cells["specificWeightLayer"].Value); } } } } catch (FormatException FormEx) { MessageBox.Show(FormEx.Message, "Worng Format", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message); } show_Results(); }