private string GetRandomizerFile(enRandomDataType randomizerSource) { string folderPath = string.Empty; string selectedFile = string.Empty; switch (randomizerSource) { case enRandomDataType.RandomNamesAndLocations: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomNamesAndLocationsSubfolder); break; case enRandomDataType.CustomRandomValues: folderPath = Path.Combine(_randomizer.RandomDataFolder, _randomizer.RandomCustomDataSubfolder); break; case enRandomDataType.RandomNumbers: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomNumbersSubfolder); break; case enRandomDataType.RandomWords: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomWordsSubfolder); break; case enRandomDataType.RandomDatesAndTimes: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomDatesSubfolder); break; case enRandomDataType.RandomBooleans: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomBooleansSubfolder); break; default: folderPath = Path.Combine(_randomizer.RandomDefinitionsFolder, _randomizer.RandomNamesAndLocationsSubfolder); break; } _saveSelectionsFolder = folderPath; DialogResult res = ShowOpenFileDialog(); if (res == System.Windows.Forms.DialogResult.OK) { selectedFile = _saveSelectionsFile; } return(selectedFile); }
private void SaveColSpecChanges() { for (int r = 0; r < _colSpecs.Count; r++) { DataGridViewComboBoxCell randomizerSourceCell = (DataGridViewComboBoxCell)inputDataGrid.Rows[r].Cells[_randomizerSourceInx]; DataGridViewComboBoxCell randomizerFieldCell = (DataGridViewComboBoxCell)inputDataGrid.Rows[r].Cells[_randomizerFieldInx]; DataGridViewTextBoxCell randomizerFilePathCell = (DataGridViewTextBoxCell)inputDataGrid.Rows[r].Cells[_randomizerFileInx]; string cellValue = randomizerSourceCell.Value.ToString(); enRandomDataType randomizerSource = enRandomDataType.NotSpecified; if (cellValue.Trim() != string.Empty) { randomizerSource = (enRandomDataType)Enum.Parse(typeof(enRandomDataType), cellValue.Replace(" ", "")); } _colSpecs[r].RandomDataType = randomizerSource; _colSpecs[r].RandomDataFieldName = randomizerFieldCell.Value.ToString(); _colSpecs[r].RandomDataFileName = randomizerFilePathCell.Value.ToString(); } }
private void inputDataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e) { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { DataGridViewDisableButtonCell fileLookupCell = (DataGridViewDisableButtonCell)inputDataGrid.Rows[e.RowIndex].Cells[_lookupButtonInx]; DataGridViewComboBoxCell randomizerSourceCell = (DataGridViewComboBoxCell)inputDataGrid.Rows[e.RowIndex].Cells[_randomizerSourceInx]; DataGridViewTextBoxCell randomizerFilePathCell = (DataGridViewTextBoxCell)inputDataGrid.Rows[e.RowIndex].Cells[_randomizerFileInx]; if (fileLookupCell.Enabled) { string cellValue = randomizerSourceCell.Value.ToString(); enRandomDataType randomizerSource = (enRandomDataType)Enum.Parse(typeof(enRandomDataType), cellValue.Replace(" ", "")); string filepath = GetRandomizerFile(randomizerSource); if (filepath.Length > 0) { randomizerFilePathCell.Value = filepath; _dataHasChanged = true; } } } }