public void setupDialog() { // Get unique species list from trees ArrayList uniqueSpecies = Global.BL.GetJustSpecies("Tree"); // any volume equations?? List <VolumeEquationDO> volList = Global.BL.getVolumeEquations().ToList(); if (volList.Count <= 0) { // Initialize dibs as zero jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); jd.speciesDIB = uniqueSpecies[k].ToString(); jd.productDIB = "01"; jd.primaryDIB = 0.0F; jd.secondaryDIB = 0.0F; jstDIB.Add(jd); } // end for k loop } else if (volList.Count > 0) { // Initialize dibs from volume equations jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); string currentSpecies = uniqueSpecies[k].ToString(); VolumeEquationDO ve = volList.FirstOrDefault(v => v.Species == currentSpecies); if (ve != null) { jd.speciesDIB = currentSpecies; jd.productDIB = ve.PrimaryProduct.ToString(); jd.primaryDIB = ve.TopDIBPrimary; jd.secondaryDIB = ve.TopDIBSecondary; jstDIB.Add(jd); } // endif nthRow } // end for k loop } // endif volumes // Now the list can be loaded into the data grid -- it is not bound int rowNum = 0; completedDIBs.RowCount = jstDIB.Count; completedDIBs.ColumnCount = 3; foreach (JustDIBs jd in jstDIB) { completedDIBs.Rows[rowNum].Cells[0].Value = jd.speciesDIB; completedDIBs.Rows[rowNum].Cells[1].Value = jd.primaryDIB; completedDIBs.Rows[rowNum].Cells[2].Value = jd.secondaryDIB; rowNum++; } // end foreach loop return; } // end setupDialog
} // end setupDialog private void onFinished(object sender, EventArgs e) { // Capture DIB list to use in creating equations jstDIB.Clear(); for (int k = 0; k < completedDIBs.RowCount; k++) { JustDIBs jd = new JustDIBs(); jd.speciesDIB = completedDIBs.Rows[k].Cells[0].Value.ToString(); jd.productDIB = "01"; jd.primaryDIB = Convert.ToSingle(completedDIBs.Rows[k].Cells[1].Value); jd.secondaryDIB = Convert.ToSingle(completedDIBs.Rows[k].Cells[2].Value); jstDIB.Add(jd); } // end foreach Close(); return; } // end onFinished
public void setupDialog() { // Get unique species list from trees ArrayList uniqueSpecies = bslyr.GetJustSpecies("Tree"); // any volume equations?? List <VolumeEquationDO> volList = bslyr.getVolumeEquations(); if (volList.Count <= 0) { // Initialize dibs as zero jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); jd.speciesDIB = uniqueSpecies[k].ToString(); jd.productDIB = "01"; jd.primaryDIB = 0.0F; jd.secondaryDIB = 0.0F; jstDIB.Add(jd); } // end for k loop } else if (volList.Count > 0) { // Initialize dibs from volume equations jstDIB.Clear(); for (int k = 0; k < uniqueSpecies.Count; k++) { JustDIBs jd = new JustDIBs(); string currentSpecies = uniqueSpecies[k].ToString(); int nthRow = volList.FindIndex( delegate(VolumeEquationDO v) { //return v.Species == currentSpecies && v.PrimaryProduct == "01"; return(v.Species == currentSpecies); }); if (nthRow >= 0) { jd.speciesDIB = currentSpecies; jd.productDIB = volList[nthRow].PrimaryProduct.ToString(); jd.primaryDIB = (float)volList[nthRow].TopDIBPrimary; jd.secondaryDIB = (float)volList[nthRow].TopDIBSecondary; jstDIB.Add(jd); } // endif nthRow } // end for k loop } // endif volumes // Now the list can be loaded into the data grid -- it is not bound int rowNum = 0; completedDIBs.RowCount = jstDIB.Count; completedDIBs.ColumnCount = 3; foreach (JustDIBs jd in jstDIB) { completedDIBs.Rows[rowNum].Cells[0].Value = jd.speciesDIB; completedDIBs.Rows[rowNum].Cells[1].Value = jd.primaryDIB; completedDIBs.Rows[rowNum].Cells[2].Value = jd.secondaryDIB; rowNum++; } // end foreach loop return; } // end setupDialog