From 58c339c53e1d0732413012c604065c54f0609b01 Mon Sep 17 00:00:00 2001 From: SergeyNefyodov Date: Tue, 30 Apr 2024 16:45:55 +0200 Subject: [PATCH] =?UTF-8?q?Add=20TableSectionData=20support=20=E2=80=94=20?= =?UTF-8?q?some=20more=20methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Descriptors/TableSectionDataDescriptor.cs | 157 ++++++++++++++++++ 1 file changed, 157 insertions(+) diff --git a/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs b/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs index 1da0b1f0..35c35533 100644 --- a/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs +++ b/source/RevitLookup/Core/ComponentModel/Descriptors/TableSectionDataDescriptor.cs @@ -50,7 +50,17 @@ public ResolveSet Resolve(Document context, string target, ParameterInfo[] param nameof(TableSectionData.GetCellText) => ResolveCellText(), nameof(TableSectionData.GetCellType) when parameters.Length == 1 => ResolveCellTypeForColumns(), nameof(TableSectionData.GetCellType) when parameters.Length == 2 => ResolveCellTypeForTable(), + nameof(TableSectionData.GetColumnWidth) => ResolveColumnWidth(), + nameof(TableSectionData.GetColumnWidthInPixels) => ResolveColumnWidthInPixels(), + nameof(TableSectionData.GetMergedCell) => ResolveMergedCell(), nameof(TableSectionData.GetRowHeight) => ResolveRowHeight(), + nameof(TableSectionData.GetRowHeightInPixels) => ResolveRowHeightInPixels(), + nameof(TableSectionData.GetTableCellStyle) => ResolveTableCellStyle(), + nameof(TableSectionData.IsCellFormattable) => ResolveIsCellFormattable(), + nameof(TableSectionData.IsCellOverridden) when parameters.Length == 1 => ResolveIsCellOverriddenForColumns(), + nameof(TableSectionData.IsCellOverridden) when parameters.Length == 2 => ResolveIsCellOverriddenForTable(), + nameof(TableSectionData.IsValidColumnNumber) => ResolveIsValidColumnNumber(), + nameof(TableSectionData.IsValidRowNumber) => ResolveIsValidRowNumber(), nameof(TableSectionData.RefreshData) => ResolveSet.Append(false, "Overridden"), _ => null }; @@ -361,6 +371,50 @@ ResolveSet ResolveCellTypeForTable() return resolveSummary; } + ResolveSet ResolveColumnWidth() + { + var count = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) + { + var result = tableSectionData.GetColumnWidth(i); + resolveSummary.AppendVariant(result, $"{i}: {result.ToString(CultureInfo.InvariantCulture)} ft"); + } + + return resolveSummary; + } + + + ResolveSet ResolveColumnWidthInPixels() + { + var count = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) + { + var result = tableSectionData.GetColumnWidthInPixels(i); + resolveSummary.AppendVariant(result, $"{i}: {result.ToString(CultureInfo.InvariantCulture)} px"); + } + + return resolveSummary; + } + + ResolveSet ResolveMergedCell() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + for (var j = 0; j < rowsNumber; j++) + { + var result = tableSectionData.GetMergedCell(j, i); + resolveSummary.AppendVariant(result, $"Row {j}, Column {i}"); + } + } + + return resolveSummary; + } + ResolveSet ResolveRowHeight() { var count = tableSectionData.NumberOfRows; @@ -373,5 +427,108 @@ ResolveSet ResolveRowHeight() return resolveSummary; } + + ResolveSet ResolveRowHeightInPixels() + { + var count = tableSectionData.NumberOfRows; + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) + { + var result = tableSectionData.GetRowHeightInPixels(i); + resolveSummary.AppendVariant(result, $"{i}: {result.ToString(CultureInfo.InvariantCulture)} px"); + } + + return resolveSummary; + } + + ResolveSet ResolveTableCellStyle() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + for (var j = 0; j < rowsNumber; j++) + { + var result = tableSectionData.GetTableCellStyle(j, i); + resolveSummary.AppendVariant(result, $"Row {j}, Column {i}"); + } + } + + return resolveSummary; + } + + ResolveSet ResolveIsCellFormattable() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + for (var j = 0; j < rowsNumber; j++) + { + var result = tableSectionData.IsCellFormattable(j, i); + resolveSummary.AppendVariant(result, $"Row {j}, Column {i}: {result}"); + } + } + + return resolveSummary; + } + + ResolveSet ResolveIsCellOverriddenForColumns() + { + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + var columnResult = tableSectionData.IsCellOverridden(i); + resolveSummary.AppendVariant(columnResult, $"Column {i}: {columnResult}"); + } + + return resolveSummary; + } + + ResolveSet ResolveIsCellOverriddenForTable() + { + var rowsNumber = tableSectionData.NumberOfRows; + var columnsNumber = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(rowsNumber * columnsNumber); + for (var i = 0; i < columnsNumber; i++) + { + for (var j = 0; j < rowsNumber; j++) + { + var result = tableSectionData.IsCellOverridden(j, i); + resolveSummary.AppendVariant(result, $"Row {j}, Column {i}: {result}"); + } + } + + return resolveSummary; + } + + ResolveSet ResolveIsValidColumnNumber() + { + var count = tableSectionData.NumberOfColumns; + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) + { + var result = tableSectionData.IsValidColumnNumber(i); + resolveSummary.AppendVariant(result, $"{i}: {result}"); + } + + return resolveSummary; + } + + ResolveSet ResolveIsValidRowNumber() + { + var count = tableSectionData.NumberOfRows; + var resolveSummary = new ResolveSet(count); + for (var i = 0; i < count; i++) + { + var result = tableSectionData.IsValidRowNumber(i); + resolveSummary.AppendVariant(result, $"{i}: {result}"); + } + + return resolveSummary; + } } } \ No newline at end of file