예제 #1
0
        public override void LoadDataFeed(DataFeed dataFeed)
        {
            base.LoadDataFeed(dataFeed);

            this.m_FilesView.LoadDataFeed(dataFeed, Strings.DATASHEET_SPIC_NAME);

            if (!this.m_ColumnsInitialized)
            {
                //Add handlers
                this.m_FilesDataGrid.CellFormatting += this.OnGridCellFormatting;
                this.m_FilesDataGrid.CellMouseClick += this.OnGridCellMouseClick;
                this.m_FilesDataGrid.CellPainting   += this.OnGridCellPainting;
                this.m_FilesDataGrid.CellMouseEnter += this.OnGridCellMouseEnter;
                this.m_FilesDataGrid.CellMouseLeave += this.OnGridCellMouseLeave;
                this.m_FilesDataGrid.CellBeginEdit  += this.OnGridBeginEdit;
                this.m_FilesDataGrid.KeyDown        += this.OnGridKeyDown;

                //Add browse button columns
                this.m_FilesDataGrid.Columns.Insert(PRIMARY_STRATUM_BROWSE_COLUMN_INDEX, CreateButtonColumn());
                this.m_FilesDataGrid.Columns.Insert(SECONDARY_STRATUM_BROWSE_COLUMN_INDEX, CreateButtonColumn());
                this.m_FilesDataGrid.Columns.Insert(TERTIARY_STRATUM_BROWSE_COLUMN_INDEX, CreateButtonColumn());
                this.m_FilesDataGrid.Columns.Insert(SCLASS_BROWSE_COLUMN_INDEX, CreateButtonColumn());
                this.m_FilesDataGrid.Columns.Insert(AGE_BROWSE_COLUMN_INDEX, CreateButtonColumn());

                this.m_ColumnsInitialized = true;
            }

            this.MonitorDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME, this.OnTerminologyChanged, true);

            this.m_FilesDataSheet = (InitialConditionsSpatialDataSheet)this.DataFeed.GetDataSheet(Strings.DATASHEET_SPIC_NAME);
            this.m_FilesDataSheet.ValidatingRasters += this.OnValidatingRasters;
            this.m_FilesDataSheet.RastersValidated  += this.OnRastersValidated;
        }
예제 #2
0
        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);
        }