private void RefreshCalculatedValues() { DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow(); if (drProp == null) { return; } //Num Cells int NumCells = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]); this.TextBoxNumCells.Text = NumCells.ToString(CultureInfo.InvariantCulture); //Get the units and refresh the units labels - the default Raster Cell Units is Metres^2 string srcSizeUnits = DataTableUtilities.GetDataStr(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]); string srcAreaUnits = srcSizeUnits + "^2"; string amountlabel = null; TerminologyUnit destUnitsVal = 0; TerminologyUtilities.GetAmountLabelTerminology( this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal); string destAreaLbl = TerminologyUtilities.TerminologyUnitToString(destUnitsVal); srcAreaUnits = srcAreaUnits.ToLower(CultureInfo.InvariantCulture); amountlabel = amountlabel.ToLower(CultureInfo.InvariantCulture); destAreaLbl = destAreaLbl.ToLower(CultureInfo.InvariantCulture); this.LabelRasterCellArea.Text = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", srcAreaUnits); this.LabelCalcCellArea.Text = string.Format(CultureInfo.InvariantCulture, "Cell size ({0}):", destAreaLbl); this.LabelCalcTtlAmount.Text = string.Format(CultureInfo.InvariantCulture, "Total {0} ({1}):", amountlabel, destAreaLbl); // Calculate Cell Area in raster's native units float cellSize = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]); double cellArea = Math.Pow(cellSize, 2); this.TextBoxCellArea.Text = cellArea.ToString("N4", CultureInfo.InvariantCulture); // Calc Cell Area in terminology units double cellAreaTU = 0; if (!CheckBoxCellSizeOverride.Checked) { cellAreaTU = InitialConditionsSpatialDataSheet.CalcCellArea(cellArea, srcSizeUnits, destUnitsVal); this.TextBoxCellAreaCalc.Text = cellAreaTU.ToString("N4", CultureInfo.InvariantCulture); drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = cellAreaTU; TextBoxCellAreaCalc.ReadOnly = true; } else { cellAreaTU = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]); TextBoxCellAreaCalc.ReadOnly = false; } // Now calculate total area in the specified terminology units var ttlArea = cellAreaTU * NumCells; this.TextBoxTotalArea.Text = ttlArea.ToString("N4", CultureInfo.InvariantCulture); }
private void RefreshNonCalculatedValues() { DataRow drProp = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME).GetDataRow(); if (drProp == null) { return; } this.CheckBoxCellSizeOverride.Checked = DataTableUtilities.GetDataBool(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_OVERRIDE_COLUMN_NAME]); this.CheckBoxCellSizeOverride.Enabled = true; this.CheckBoxCellSizeOverride.AutoCheck = true; int NumRows = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_ROWS_COLUMN_NAME]); int NumCols = DataTableUtilities.GetDataInt(drProp[Strings.DATASHEET_SPPIC_NUM_COLUMNS_COLUMN_NAME]); float CellArea = DataTableUtilities.GetDataSingle(drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]); double cellAreaCalc = DataTableUtilities.GetDataDbl(drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME]); this.TextBoxNumRows.Text = NumRows.ToString(CultureInfo.InvariantCulture); this.TextBoxNumColumns.Text = NumCols.ToString(CultureInfo.InvariantCulture); this.TextBoxCellArea.Text = CellArea.ToString("N4", CultureInfo.InvariantCulture); this.TextBoxCellAreaCalc.Text = cellAreaCalc.ToString("N4", CultureInfo.InvariantCulture); }