From a74586723f2d6e3c81ef3bd40279462bab1eeb43 Mon Sep 17 00:00:00 2001 From: Dilyan Traykov Date: Tue, 18 Dec 2018 18:43:53 +0200 Subject: [PATCH] Update examples --- .../ExportHierarchy_WPF.csproj | 2 + .../HierarchicalExportGridView.cs | 79 +++++-- GridView/ExportHierarchy/MainWindow.xaml | 15 +- GridView/ExportHierarchy/ParentExportInfo.cs | 13 ++ .../HighlightCustomColumn/HightlightColumn.cs | 2 +- Map/WPF/Map_WPF.sln | 6 + .../ProvidersFileSystemMapProvider/App.xaml | 8 + .../App.xaml.cs | 16 ++ .../FileSystemMapProvider.csproj | 217 ++++++++++++++++++ .../FileSystemProvider.cs | 37 +++ .../FileSystemTileSource.cs | 187 +++++++++++++++ .../MainWindow.xaml | 19 ++ .../MainWindow.xaml.cs | 57 +++++ .../OpenStreet Images/1/os_0_0_1.png | Bin 0 -> 11088 bytes .../OpenStreet Images/1/os_0_1_1.png | Bin 0 -> 3250 bytes .../OpenStreet Images/1/os_1_0_1.png | Bin 0 -> 10859 bytes .../OpenStreet Images/1/os_1_1_1.png | Bin 0 -> 3997 bytes .../OpenStreet Images/2/os_0_0_2.png | Bin 0 -> 6048 bytes .../OpenStreet Images/2/os_0_1_2.png | Bin 0 -> 4629 bytes .../OpenStreet Images/2/os_0_2_2.png | Bin 0 -> 103 bytes .../OpenStreet Images/2/os_0_3_2.png | Bin 0 -> 1645 bytes .../OpenStreet Images/2/os_1_0_2.png | Bin 0 -> 9345 bytes .../OpenStreet Images/2/os_1_1_2.png | Bin 0 -> 8809 bytes .../OpenStreet Images/2/os_1_2_2.png | Bin 0 -> 4175 bytes .../OpenStreet Images/2/os_1_3_2.png | Bin 0 -> 2285 bytes .../OpenStreet Images/2/os_2_0_2.png | Bin 0 -> 6076 bytes .../OpenStreet Images/2/os_2_1_2.png | Bin 0 -> 11520 bytes .../OpenStreet Images/2/os_2_2_2.png | Bin 0 -> 3316 bytes .../OpenStreet Images/2/os_2_3_2.png | Bin 0 -> 1446 bytes .../OpenStreet Images/2/os_3_0_2.png | Bin 0 -> 3565 bytes .../OpenStreet Images/2/os_3_1_2.png | Bin 0 -> 6691 bytes .../OpenStreet Images/2/os_3_2_2.png | Bin 0 -> 4679 bytes .../OpenStreet Images/2/os_3_3_2.png | Bin 0 -> 1572 bytes .../OpenStreet Images/3/oc_4149_2818_13.png | Bin 0 -> 43158 bytes .../OpenStreet Images/3/oc_4_2_3.png | Bin 0 -> 32578 bytes .../OpenStreet Images/3/os_0_0_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_0_1_3.png | Bin 0 -> 2050 bytes .../OpenStreet Images/3/os_0_2_3.png | Bin 0 -> 4565 bytes .../OpenStreet Images/3/os_0_3_3.png | Bin 0 -> 842 bytes .../OpenStreet Images/3/os_0_4_3.png | Bin 0 -> 366 bytes .../OpenStreet Images/3/os_0_5_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_0_6_3.png | Bin 0 -> 1631 bytes .../OpenStreet Images/3/os_0_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_1_0_3.png | Bin 0 -> 1804 bytes .../OpenStreet Images/3/os_1_1_3.png | Bin 0 -> 11419 bytes .../OpenStreet Images/3/os_1_2_3.png | Bin 0 -> 5334 bytes .../OpenStreet Images/3/os_1_3_3.png | Bin 0 -> 4059 bytes .../OpenStreet Images/3/os_1_4_3.png | Bin 0 -> 288 bytes .../OpenStreet Images/3/os_1_5_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_1_6_3.png | Bin 0 -> 1888 bytes .../OpenStreet Images/3/os_1_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_2_0_3.png | Bin 0 -> 6549 bytes .../OpenStreet Images/3/os_2_1_3.png | Bin 0 -> 10645 bytes .../OpenStreet Images/3/os_2_2_3.png | Bin 0 -> 9358 bytes .../OpenStreet Images/3/os_2_3_3.png | Bin 0 -> 6911 bytes .../OpenStreet Images/3/os_2_4_3.png | Bin 0 -> 6371 bytes .../OpenStreet Images/3/os_2_5_3.png | Bin 0 -> 5168 bytes .../OpenStreet Images/3/os_2_6_3.png | Bin 0 -> 3102 bytes .../OpenStreet Images/3/os_2_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_3_0_3.png | Bin 0 -> 4250 bytes .../OpenStreet Images/3/os_3_1_3.png | Bin 0 -> 4967 bytes .../OpenStreet Images/3/os_3_2_3.png | Bin 0 -> 5611 bytes .../OpenStreet Images/3/os_3_3_3.png | Bin 0 -> 6005 bytes .../OpenStreet Images/3/os_3_4_3.png | Bin 0 -> 1232 bytes .../OpenStreet Images/3/os_3_5_3.png | Bin 0 -> 378 bytes .../OpenStreet Images/3/os_3_6_3.png | Bin 0 -> 1842 bytes .../OpenStreet Images/3/os_3_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_4_0_3.png | Bin 0 -> 2208 bytes .../OpenStreet Images/3/os_4_1_3.png | Bin 0 -> 4895 bytes .../OpenStreet Images/3/os_4_2_3.png | Bin 0 -> 14818 bytes .../OpenStreet Images/3/os_4_3_3.png | Bin 0 -> 15358 bytes .../OpenStreet Images/3/os_4_4_3.png | Bin 0 -> 9892 bytes .../OpenStreet Images/3/os_4_5_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_4_6_3.png | Bin 0 -> 1552 bytes .../OpenStreet Images/3/os_4_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_5_0_3.png | Bin 0 -> 3234 bytes .../OpenStreet Images/3/os_5_1_3.png | Bin 0 -> 6315 bytes .../OpenStreet Images/3/os_5_2_3.png | Bin 0 -> 4203 bytes .../OpenStreet Images/3/os_5_3_3.png | Bin 0 -> 8985 bytes .../OpenStreet Images/3/os_5_4_3.png | Bin 0 -> 2002 bytes .../OpenStreet Images/3/os_5_5_3.png | Bin 0 -> 1028 bytes .../OpenStreet Images/3/os_5_6_3.png | Bin 0 -> 1616 bytes .../OpenStreet Images/3/os_5_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_6_0_3.png | Bin 0 -> 1836 bytes .../OpenStreet Images/3/os_6_1_3.png | Bin 0 -> 4059 bytes .../OpenStreet Images/3/os_6_2_3.png | Bin 0 -> 3961 bytes .../OpenStreet Images/3/os_6_3_3.png | Bin 0 -> 10988 bytes .../OpenStreet Images/3/os_6_4_3.png | Bin 0 -> 5722 bytes .../OpenStreet Images/3/os_6_5_3.png | Bin 0 -> 1280 bytes .../OpenStreet Images/3/os_6_6_3.png | Bin 0 -> 944 bytes .../OpenStreet Images/3/os_6_7_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_7_0_3.png | Bin 0 -> 103 bytes .../OpenStreet Images/3/os_7_1_3.png | Bin 0 -> 3010 bytes .../OpenStreet Images/3/os_7_2_3.png | Bin 0 -> 4727 bytes .../OpenStreet Images/3/os_7_3_3.png | Bin 0 -> 1656 bytes .../OpenStreet Images/3/os_7_4_3.png | Bin 0 -> 6168 bytes .../OpenStreet Images/3/os_7_5_3.png | Bin 0 -> 2854 bytes .../OpenStreet Images/3/os_7_6_3.png | Bin 0 -> 2604 bytes .../OpenStreet Images/3/os_7_7_3.png | Bin 0 -> 103 bytes .../Properties/AssemblyInfo.cs | 55 +++++ .../Properties/Resources.Designer.cs | 63 +++++ .../Properties/Resources.resx | 117 ++++++++++ .../Properties/Settings.Designer.cs | 26 +++ .../Properties/Settings.settings | 7 + .../ProvidersFileSystemMapProvider/Readme.md | 4 + .../ProvidersFileSystemMapProvider/app.config | 3 + 106 files changed, 909 insertions(+), 24 deletions(-) create mode 100644 GridView/ExportHierarchy/ParentExportInfo.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/App.xaml create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/App.xaml.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/FileSystemMapProvider.csproj create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/FileSystemProvider.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/FileSystemTileSource.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/MainWindow.xaml create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/MainWindow.xaml.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/1/os_0_0_1.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/1/os_0_1_1.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/1/os_1_0_1.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/1/os_1_1_1.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_0_0_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_0_1_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_0_2_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_0_3_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_1_0_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_1_1_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_1_2_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_1_3_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_2_0_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_2_1_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_2_2_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_2_3_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_3_0_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_3_1_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_3_2_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/2/os_3_3_2.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/oc_4149_2818_13.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/oc_4_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_0_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_1_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_2_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_3_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_4_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_5_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_6_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_0_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_1_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_2_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_3_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_4_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_5_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_6_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/OpenStreet Images/3/os_7_7_3.png create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Properties/AssemblyInfo.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Properties/Resources.Designer.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Properties/Resources.resx create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Properties/Settings.Designer.cs create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Properties/Settings.settings create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/Readme.md create mode 100644 Map/WPF/ProvidersFileSystemMapProvider/app.config diff --git a/GridView/ExportHierarchy/ExportHierarchy_WPF.csproj b/GridView/ExportHierarchy/ExportHierarchy_WPF.csproj index 301144bf..a50d6178 100644 --- a/GridView/ExportHierarchy/ExportHierarchy_WPF.csproj +++ b/GridView/ExportHierarchy/ExportHierarchy_WPF.csproj @@ -126,6 +126,7 @@ + @@ -150,6 +151,7 @@ Settings.Designer.cs + diff --git a/GridView/ExportHierarchy/HierarchicalExportGridView.cs b/GridView/ExportHierarchy/HierarchicalExportGridView.cs index 8a4ee793..857ef98b 100644 --- a/GridView/ExportHierarchy/HierarchicalExportGridView.cs +++ b/GridView/ExportHierarchy/HierarchicalExportGridView.cs @@ -18,14 +18,34 @@ namespace ExportHierarchy public class HierarchicalExportGridView : RadGridView { private int subItemsCount = 0; - private Dictionary subItemsDictionary = new Dictionary(); + private List parentItemsDictionary = new List(); private int headerRowCount; public HierarchicalExportGridView() { + this.ElementExportingToDocument += HierarchicalExportGridView_ElementExportingToDocument; this.ElementExportedToDocument += HierarchicalExportGridView_ElementExportedToDocument; } + private void HierarchicalExportGridView_ElementExportingToDocument(object sender, GridViewElementExportingToDocumentEventArgs e) + { + if (e.Element == ExportElement.HeaderRow) + { + (e.VisualParameters as GridViewDocumentVisualExportParameters).Style = new CellSelectionStyle() + { + IsBold = true, + Fill = new PatternFill(PatternType.Solid, Color.FromArgb(255, 232, 232, 232), Colors.Transparent), + }; + } + else if (e.Element == ExportElement.Row) + { + (e.VisualParameters as GridViewDocumentVisualExportParameters).Style = new CellSelectionStyle() + { + Fill = new PatternFill(PatternType.Solid, Color.FromArgb(255, 255, 142, 142), Colors.Transparent), + }; + } + } + private void HierarchicalExportGridView_ElementExportedToDocument(object sender, GridViewElementExportedToDocumentEventArgs e) { if (e.Element == ExportElement.Row && e.DataContext != null) @@ -39,11 +59,19 @@ namespace ExportHierarchy var subItems = item.GetType().GetProperty(property).GetValue(item) as IList; if (subItems.Count > 0) { - var index = gridView.Items.IndexOf(item) + 1 + subItemsCount; + var originalIndex = gridView.Items.IndexOf(item); + var newIndex = originalIndex + subItemsCount; subItemsCount += subItems.Count; - this.subItemsDictionary.Add(index, subItems); + this.parentItemsDictionary.Add(new ParentExportInfo() + { + OriginalIndex = originalIndex, + ExportIndex = newIndex, + SubItems = subItems + }); } } + + } } @@ -78,7 +106,7 @@ namespace ExportHierarchy } this.subItemsCount = 0; - this.subItemsDictionary.Clear(); + this.parentItemsDictionary.Clear(); } } @@ -90,29 +118,48 @@ namespace ExportHierarchy workbook = this.ExportToWorkbook(); var worksheet = workbook.ActiveWorksheet; - DataTemplate dt = this.HierarchyChildTemplate; - DependencyObject dio = dt.LoadContent(); - var childGrid = dio as RadGridView; + worksheet.GroupingProperties.SummaryRowIsBelow = false; + DataTemplate template = this.HierarchyChildTemplate; + DependencyObject content = template.LoadContent(); + var childGrid = content as RadGridView; + var parentItemCount = 0; - foreach (var subItem in subItemsDictionary) + foreach (var parentItem in parentItemsDictionary) { - var rowIndex = subItem.Key; - RowSelection selection = worksheet.Rows[rowIndex + 1, rowIndex + subItem.Value.Count]; + var rowIndex = parentItem.ExportIndex + headerRowCount + parentItemCount + 1; + parentItemCount++; + RowSelection selection = worksheet.Rows[rowIndex, rowIndex + parentItem.SubItems.Count]; selection.Insert(); - for (var i = 0; i < subItem.Value.Count; i++) + for (var j = 0; j < childGrid.Columns.Count; j++) { - var item = subItem.Value[i]; - for (var j = 0; j < childGrid.Columns.Count; j++) + var column = childGrid.Columns[j] as GridViewDataColumn; + var header = column.Header != null ? column.Header.ToString() : column.DataMemberBinding.Path.Path; + var headerCell = worksheet.Cells[rowIndex, j]; + headerCell.SetValueAsText(header); + var headerCellFill = new PatternFill(PatternType.Solid, Color.FromArgb(255, 150, 150, 150), Colors.Transparent); + headerCell.SetFill(headerCellFill); + headerCell.SetIsBold(true); + + for (var i = 0; i < parentItem.SubItems.Count; i++) { - var column = childGrid.Columns[j] as GridViewDataColumn; + var item = parentItem.SubItems[i]; + var cell = worksheet.Cells[rowIndex + 1 + i, j]; var property = item.GetType().GetProperty(column.DataMemberBinding.Path.Path); var value = property != null ? property.GetValue(item).ToString() : string.Empty; cell.SetValueAsText(value); - var solidPatternFill = new PatternFill(PatternType.Solid, Color.FromArgb(255, 46, 204, 113), Colors.Transparent); - cell.SetFill(solidPatternFill); + var subItemCellFill = new PatternFill(PatternType.Solid, Color.FromArgb(255, 46, 204, 113), Colors.Transparent); + cell.SetFill(subItemCellFill); } } + + selection.Group(); + var originalItem = this.Items[parentItem.OriginalIndex]; + var isExpanded = (bool)originalItem.GetType().GetProperty("IsExpanded").GetValue(originalItem); + if (!isExpanded) + { + selection.SetHidden(true); + } } for (var j = 0; j < childGrid.Columns.Count; j++) diff --git a/GridView/ExportHierarchy/MainWindow.xaml b/GridView/ExportHierarchy/MainWindow.xaml index 3d765e9e..2a8df666 100644 --- a/GridView/ExportHierarchy/MainWindow.xaml +++ b/GridView/ExportHierarchy/MainWindow.xaml @@ -5,8 +5,8 @@ xmlns:my="clr-namespace:ExportHierarchy" Title="MainWindow" Height="700" Width="700"> - - + + @@ -33,6 +33,7 @@ - - + - - - + +