|
17 | 17 | // DEALINGS IN THE SOFTWARE. |
18 | 18 |
|
19 | 19 | using System; |
20 | | -using System.Collections.Generic; |
21 | 20 | using System.Windows; |
22 | 21 | using System.Windows.Controls; |
23 | 22 | using System.Windows.Documents; |
24 | 23 | using System.Windows.Media; |
25 | 24 |
|
| 25 | +using ICSharpCode.Reporting.BaseClasses; |
26 | 26 | using ICSharpCode.Reporting.Exporter.Visitors; |
27 | 27 | using ICSharpCode.Reporting.Interfaces.Export; |
28 | 28 | using ICSharpCode.Reporting.PageBuilder.ExportColumns; |
29 | 29 | using ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics; |
| 30 | +using System.Windows.Shapes; |
30 | 31 |
|
31 | 32 | namespace ICSharpCode.Reporting.WpfReportViewer.Visitor |
32 | 33 | { |
@@ -54,45 +55,49 @@ public override void Visit(ExportPage page){ |
54 | 55 | public override void Visit(ExportContainer exportContainer){ |
55 | 56 |
|
56 | 57 | sectionCanvas = FixedDocumentCreator.CreateContainer(exportContainer); |
57 | | - sectionCanvas.Name = exportContainer.Name; |
58 | | - CanvasHelper.SetPosition(sectionCanvas,new Point(exportContainer.Location.X,exportContainer.Location.Y)); |
59 | | - PerformList(sectionCanvas,exportContainer.ExportedItems); |
| 58 | + sectionCanvas = RenderSectionContainer(exportContainer); |
60 | 59 | } |
| 60 | + |
61 | 61 |
|
62 | | - |
63 | | - void PerformList(Canvas myCanvas, List<IExportColumn> exportedItems) |
64 | | - { |
65 | | - foreach (var element in exportedItems) { |
66 | | - var container = element as ExportContainer; |
67 | | - if (container != null) { |
68 | | - var containerCanvas = FixedDocumentCreator.CreateContainer(container); |
69 | | - CanvasHelper.SetPosition(containerCanvas,new Point(container.Location.X,container.Location.Y)); |
70 | | - if (container is ExportRectangle) { |
71 | | - DrawRectangleAsContainer(container); |
72 | | - containerCanvas.Children.Add(UIElement); |
73 | | - myCanvas.Children.Add(containerCanvas); |
74 | | - } else { |
75 | | - // var containerCanvas = FixedDocumentCreator.CreateContainer(container); |
76 | | - // CanvasHelper.SetPosition(containerCanvas,new Point(container.Location.X,container.Location.Y)); |
77 | | - myCanvas.Children.Add(containerCanvas); |
78 | | - PerformList(containerCanvas,container.ExportedItems); |
| 62 | + Canvas RenderSectionContainer (ExportContainer container) { |
| 63 | + var canvas = FixedDocumentCreator.CreateContainer(container); |
| 64 | + foreach (var element in container.ExportedItems) { |
| 65 | + if (IsContainer(element)) { |
| 66 | + if (element is ExportRectangle) { |
| 67 | + var graphContainer = RenderGraphicsContainer((IExportContainer)element); |
| 68 | + canvas.Children.Add(graphContainer); |
79 | 69 | } |
80 | 70 | } else { |
81 | 71 | var acceptor = element as IAcceptor; |
82 | 72 | acceptor.Accept(this); |
83 | | - myCanvas.Children.Add(UIElement); |
| 73 | + canvas.Children.Add(UIElement); |
84 | 74 | } |
85 | 75 | } |
| 76 | + canvas.Background = FixedDocumentCreator.ConvertBrush(container.BackColor); |
| 77 | + return canvas; |
86 | 78 | } |
87 | | - |
88 | | - void DrawRectangleAsContainer(ExportContainer container) |
| 79 | + |
| 80 | + |
| 81 | + bool IsContainer (IExportColumn column) { |
| 82 | + return (column is ExportContainer)|| (column is ExportRectangle); |
| 83 | + } |
| 84 | + |
| 85 | + |
| 86 | + Canvas RenderGraphicsContainer(IExportContainer container) |
89 | 87 | { |
| 88 | + |
90 | 89 | var rect = container as ExportRectangle; |
| 90 | + var graphCanvas = FixedDocumentCreator.CreateContainer(rect); |
| 91 | + CanvasHelper.SetPosition(graphCanvas, container.Location.ToWpf()); |
| 92 | + graphCanvas.Background = FixedDocumentCreator.ConvertBrush(container.BackColor); |
91 | 93 | if (rect != null) { |
92 | 94 | Visit(rect); |
| 95 | + graphCanvas.Children.Add(UIElement); |
93 | 96 | } |
| 97 | + return graphCanvas; |
94 | 98 | } |
95 | 99 |
|
| 100 | + |
96 | 101 | public override void Visit(ExportText exportColumn){ |
97 | 102 |
|
98 | 103 | var ft = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn); |
@@ -128,19 +133,25 @@ public override void Visit(ExportLine exportGraphics) |
128 | 133 |
|
129 | 134 | public override void Visit(ExportRectangle exportRectangle) |
130 | 135 | { |
131 | | - var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle); |
132 | | - |
133 | | - var visual = new DrawingVisual(); |
134 | | - using (var dc = visual.RenderOpen()){ |
135 | | - dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor), |
136 | | - pen, |
137 | | - new Rect(exportRectangle.Location.X,exportRectangle.Location.Y, |
138 | | - exportRectangle.Size.Width,exportRectangle.Size.Height)); |
| 136 | + var border = new Border(); |
| 137 | + border.BorderThickness = new Thickness(exportRectangle.Thickness); |
| 138 | + border.BorderBrush = FixedDocumentCreator.ConvertBrush(exportRectangle.ForeColor); |
| 139 | + border.Background = FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor); |
| 140 | + border.Width = exportRectangle.Size.Width; |
| 141 | + border.Height = exportRectangle.Size.Height; |
| 142 | + CanvasHelper.SetPosition(border, new Point(0,0)); |
| 143 | + var sp = new StackPanel(); |
| 144 | + sp.Orientation = Orientation.Horizontal; |
| 145 | + foreach (var element in exportRectangle.ExportedItems) { |
| 146 | + var acceptor = element as IAcceptor; |
| 147 | + acceptor.Accept(this); |
| 148 | + sp.Children.Add(UIElement); |
139 | 149 | } |
140 | | - var dragingElement = new DrawingElement(visual); |
141 | | - UIElement = dragingElement; |
| 150 | + border.Child = sp; |
| 151 | + UIElement = border; |
142 | 152 | } |
143 | 153 |
|
| 154 | + |
144 | 155 | public override void Visit(ExportCircle exportCircle) |
145 | 156 | { |
146 | 157 | var pen = FixedDocumentCreator.CreateWpfPen(exportCircle); |
|
0 commit comments