/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if ((rowIndex < m_RowCount) && (rowIndex >= 0) && (columnIndex < m_ColumnCount) && (columnIndex >= 0)) { string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); m_SetOfUsedPropertyIndices.Add(rowIndex); m_Range.CreateDropdownList(rowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_Data[rowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_Data[rowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific Excel cell. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="inputCell">The input Excel cell.</param> /// <param name="value">The value of the Excel cell (output).</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> private ExcelCellValueState TryGetValue <TEnum>(object inputCell, out TEnum value, EnumStringRepresentationUsage enumStringRepresentationUsage) where TEnum : struct, IComparable, IConvertible, IFormattable { object excelCellValue; if (inputCell == null) { value = default(TEnum); return(ExcelCellValueState.NoValidValue); } else if (inputCell is ExcelReference) { ExcelReference excelRange = (ExcelReference)inputCell; string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); excelRange.CreateDropdownList(0, 0, valueDropDownListAsString); excelCellValue = excelRange.GetValue(); } else { excelCellValue = inputCell; } if (ExcelDataConverter.IsEmptyCell(excelCellValue) == true) { value = default(TEnum); return(ExcelCellValueState.EmptyOrMissingExcelCell); } return((ExcelDataConverter.TryGetCellValue <TEnum>(excelCellValue, enumStringRepresentationUsage, out value) == true) ? ExcelCellValueState.ProperValue : ExcelCellValueState.NoValidValue); }
/// <summary>Initializes a new instance of the <see cref="UserControlConfigurationGeneral"/> class. /// </summary> public UserControlConfigurationGeneral() { InitializeComponent(); foreach (var dropDownAdviseType in EnumString <ExcelLowLevel.DropDownListCreationType> .GetValues()) { comboBoxAddDropDownList.Items.Add(dropDownAdviseType); } RestoreConfiguration(); }
/// <summary>Initializes a new instance of the <see cref="UserControlConfigurationLogFile"/> class. /// </summary> public UserControlConfigurationLogFile() { InitializeComponent(); foreach (var loggingLevel in EnumString <ExcelPoolLoggingLevel> .GetValues()) { comboBoxGlobalLoggingLevel.Items.Add(loggingLevel); } foreach (var localOutputUsage in EnumString <ExcelLogger.OutputUsage> .GetValues()) { comboBoxLocalOutputUsage.Items.Add(localOutputUsage); } RestoreConfiguration(); }
/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if (typeof(TEnum).IsEnum == false) { throw new ArgumentException("The type " + typeof(TEnum).ToString() + " does not represents a enumeration.", "TEnum"); } if ((rowIndex >= 0) && (rowIndex < m_RowCount)) { string dropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); if (columnIndex == 0) { m_PropertyNames.CreateDropdownList(0, rowIndex, dropDownListAsString); m_SetOfUsedPropertyIndices.Add(rowIndex); if (ExcelDataConverter.IsEmptyCell(m_PropertyNameArray[0, rowIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } if (ExcelDataConverter.TryGetCellValue <TEnum>(m_PropertyNameArray[0, rowIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else if ((columnIndex >= 1) && (columnIndex < m_ColumnCount)) { m_PropertyValues.CreateDropdownList(columnIndex - 1, rowIndex, dropDownListAsString); m_SetOfUsedPropertyIndices.Add(rowIndex); if (ExcelDataConverter.IsEmptyCell(m_PropertyValueArray[columnIndex - 1, rowIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_PropertyValueArray[columnIndex - 1, rowIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }
/// <summary>Gets the value of a specific property with respect to a null-based (row or column) index. /// </summary> /// <typeparam name="TEnum">The type of the output which is assumed to be a enumeration.</typeparam> /// <param name="rowIndex">The null-based index of the row.</param> /// <param name="columnIndex">The null-based index of the column.</param> /// <param name="enumStringRepresentationUsage">The method how to compute the <see cref="System.String"/> representation.</param> /// <param name="value">The value (output).</param> /// <returns>A value indicating whether <paramref name="value"/> contains valid data.</returns> /// <exception cref="ArgumentException">Thrown, if <typeparamref name="TEnum"/> does not represents a enumeration.</exception> public ExcelCellValueState TryGetValue <TEnum>(EnumStringRepresentationUsage enumStringRepresentationUsage, out TEnum value, int rowIndex, int columnIndex) where TEnum : struct, IComparable, IConvertible, IFormattable { if ((rowIndex < RowCount) && (rowIndex >= 0) && (columnIndex < ColumnCount) && (columnIndex >= 0)) { string valueDropDownListAsString = EnumString <TEnum> .GetValues(enumStringRepresentationUsage).AsExcelDropDownListString(); if (rowIndex < m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1) // query the header { m_HeaderRange.CreateDropdownList(rowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_HeaderData[rowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_HeaderData[rowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } else // query below the header { int adjRowIndex = rowIndex - (m_HeaderRange.RowLast - m_HeaderRange.RowFirst + 1); m_BelowHeaderRange.CreateDropdownList(adjRowIndex, columnIndex, valueDropDownListAsString); if (ExcelDataConverter.IsEmptyCell(m_BelowHeaderData[adjRowIndex, columnIndex]) == true) { value = default(TEnum); m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, typeof(TEnum)); return(ExcelCellValueState.EmptyOrMissingExcelCell); } else if (ExcelDataConverter.TryGetCellValue <TEnum>(m_BelowHeaderData[adjRowIndex, columnIndex], enumStringRepresentationUsage, out value) == true) { m_GuidedExcelDataQuery.SetData(rowIndex, columnIndex, value); return(ExcelCellValueState.ProperValue); } } } value = default(TEnum); return(ExcelCellValueState.NoValidValue); }