private void GetMultiplierFile(int rowIndex) { if (!this.m_IsEnabled) { return; } DataSheet ds = this.Scenario.GetDataSheet(Strings.DATASHEET_TRANSITION_SPATIAL_INITIATION_MULTIPLIER_NAME); string RasterFile = RasterUtilities.ChooseRasterFileName("Transition Spatial Initiation Mulitplier Raster File", this); if (RasterFile == null) { return; } DataGridViewEditMode OldMode = this.m_MultipliersDataGrid.EditMode; this.m_MultipliersDataGrid.EditMode = DataGridViewEditMode.EditProgrammatically; this.m_MultipliersDataGrid.CurrentCell = this.m_MultipliersDataGrid.Rows[rowIndex].Cells[FILE_NAME_COLUMN_INDEX]; this.m_MultipliersDataGrid.Rows[rowIndex].Cells[FILE_NAME_COLUMN_INDEX].Value = Path.GetFileName(RasterFile); this.m_MultipliersDataGrid.NotifyCurrentCellDirty(true); this.m_MultipliersDataGrid.BeginEdit(false); this.m_MultipliersDataGrid.EndEdit(); this.m_MultipliersDataGrid.CurrentCell = this.m_MultipliersDataGrid.Rows[rowIndex].Cells[BROWSE_COLUMN_INDEX]; ds.AddExternalInputFile(RasterFile); this.m_MultipliersDataGrid.EditMode = OldMode; }
/// <summary> /// Chooses a new raster file /// </summary> /// <remarks> /// Just store the filename. For now, no path required. In the future may want to support absolute path, differentiated by x:\\ /// </remarks> private void ChooseRasterFile(int rowIndex, int colIndex) { string FileName = RasterUtilities.ChooseRasterFileName("Initial Conditions Raster File", this); if (FileName == null) { return; } Application.DoEvents(); using (HourGlass h = new HourGlass()) { try { StochasticTimeRaster rast = new StochasticTimeRaster(FileName, RasterDataType.DTInteger); if (colIndex == PRIMARY_STRATUM_FILE_NAME_COLUMN_INDEX && rast.Projection == null) { const string msg = "There is no projection associated with this raster file. The model will still run but outputs will also have no projection."; FormsUtilities.InformationMessageBox(msg); } SetICSpatialFile(rowIndex, colIndex, FileName); } catch (Exception e) { FormsUtilities.ErrorMessageBox(e.Message); return; } } }
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(); } }