示例#1
0
        protected override void OnRowsAdded(object sender, DataSheetRowEventArgs e)
        {
            base.OnRowsAdded(sender, e);

            var       ThisData = this.GetData();
            DataSheet dsProp   = this.GetDataSheet(Strings.DATASHEET_SPPIC_NAME);
            DataRow   drProp   = dsProp.GetDataRow();

            if (drProp == null && ThisData.DefaultView.Count > 0)
            {
                dsProp.BeginAddRows();
                drProp = dsProp.GetData().NewRow();

                DataRow FirstRow = ThisData.DefaultView[0].Row;
                StochasticTimeRaster FirstRast = this.LoadRaster(FirstRow, Strings.DATASHEET_SPIC_STRATUM_FILE_COLUMN_NAME);

                if (FirstRast.IntCells == null)
                {
                    FirstRast.LoadData();
                }

                drProp[Strings.DATASHEET_SPPIC_NUM_ROWS_COLUMN_NAME]           = FirstRast.Height;
                drProp[Strings.DATASHEET_SPPIC_NUM_COLUMNS_COLUMN_NAME]        = FirstRast.Width;
                drProp[Strings.DATASHEET_SPPIC_NUM_CELLS_COLUMN_NAME]          = FirstRast.GetNumberValidCells();
                drProp[Strings.DATASHEET_SPPIC_XLLCORNER_COLUMN_NAME]          = FirstRast.XllCorner;
                drProp[Strings.DATASHEET_SPPIC_YLLCORNER_COLUMN_NAME]          = FirstRast.YllCorner;
                drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_COLUMN_NAME]          = FirstRast.CellSize;
                drProp[Strings.DATASHEET_SPPIC_CELL_SIZE_UNITS_COLUMN_NAME]    = FirstRast.CellSizeUnits;
                drProp[Strings.DATASHEET_SPPIC_SRS_COLUMN_NAME]                = FirstRast.Projection;
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_OVERRIDE_COLUMN_NAME] = false;

                string          amountlabel  = null;
                TerminologyUnit destUnitsVal = 0;
                double          cellArea     = System.Math.Pow((double)FirstRast.CellSize, 2);

                TerminologyUtilities.GetAmountLabelTerminology(this.Project.GetDataSheet(Strings.DATASHEET_TERMINOLOGY_NAME), ref amountlabel, ref destUnitsVal);
                drProp[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = CalcCellArea(cellArea, FirstRast.CellSizeUnits, destUnitsVal);

                dsProp.Changes.Add(new ChangeRecord(this, "Added raster metadata"));
                dsProp.GetData().Rows.Add(drProp);
                dsProp.EndAddRows();
            }
        }
示例#2
0
        /// <summary>
        /// Handles the Validated event for the TextBoxCellAreaCalc text box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// If we are just refreshing the data, or the text has not really changed,
        /// then we don't want to do anything during this event.
        /// </remarks>
        private void TextBoxCellAreaCalc_Validated(object sender, EventArgs e)
        {
            if (this.m_InRefresh)
            {
                return;
            }

            if (!this.m_CellAreaCalcHasChanges)
            {
                return;
            }

            //Save the CellArea value
            DataSheet ds = this.DataFeed.GetDataSheet(Strings.DATASHEET_SPPIC_NAME);
            DataRow   dr = ds.GetDataRow();

            if (dr == null)
            {
                ds.BeginAddRows();
                dr = ds.GetData().NewRow();
                ds.GetData().Rows.Add(dr);
                ds.EndAddRows();
            }

            ds.BeginModifyRows();

            double cellArea = 0;

            if (double.TryParse(this.TextBoxCellAreaCalc.Text, out cellArea))
            {
                dr[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = cellArea;
            }
            else
            {
                dr[Strings.DATASHEET_SPPIC_CELL_AREA_COLUMN_NAME] = DBNull.Value;
            }

            ds.EndModifyRows();
            RefreshCalculatedValues();

            this.m_CellAreaCalcHasChanges = false;
        }
示例#3
0
        private void ButtonBrowse_Click(object sender, System.EventArgs e)
        {
            string RasterFile = RasterUtilities.ChooseRasterFileName("Digital Elevation Model File", this);

            if (RasterFile == null)
            {
                return;
            }

            using (HourGlass h = new HourGlass())
            {
                DataSheet ds             = this.GetDataSheet();
                DataRow   dr             = ds.GetDataRow();
                string    RasterFileName = Path.GetFileName(RasterFile);

                if (dr == null)
                {
                    dr = ds.GetData().NewRow();

                    ds.BeginAddRows();
                    dr[Strings.DATASHEET_DIGITAL_ELEVATION_MODEL_FILE_NAME_COLUMN_NAME] = RasterFileName;
                    ds.GetData().Rows.Add(dr);
                    ds.EndAddRows();
                }
                else
                {
                    ds.BeginModifyRows();
                    dr[Strings.DATASHEET_DIGITAL_ELEVATION_MODEL_FILE_NAME_COLUMN_NAME] = RasterFileName;
                    ds.EndModifyRows();
                }

                ds.AddExternalInputFile(RasterFile);

                this.RefreshControls();
                this.EnableButtons();
            }
        }