From a7924d9bfb1f0a93fcff1f5562af0247cd6a53b8 Mon Sep 17 00:00:00 2001 From: Peter Forstmeier Date: Sun, 6 Dec 2015 20:17:28 +0100 Subject: [PATCH] =?UTF-8?q?Formatter=20angepa=C3=9Ft,=20DataPageBuilder=20?= =?UTF-8?q?-=20Locatio=20f=C3=BCr=20GroupItems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Src/Events/SectionEvent.cs | 4 ++- .../Src/Exporter/Visitors/FormatVisitor.cs | 3 +- .../Src/Globals/StandardFormatter.cs | 9 +++++ .../Src/PageBuilder/BasePageBuilder.cs | 4 ++- .../Src/PageBuilder/DataPageBuilder.cs | 33 +++++++++++++------ 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs index 69f415e7dc..43a268c164 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Events/SectionEvent.cs @@ -18,13 +18,15 @@ namespace ICSharpCode.Reporting { - public SectionEventArgs(IReportContainer section){ + public SectionEventArgs(IReportContainer section,int pageCount){ if (section == null) throw new ArgumentNullException("section"); Section = section; + PageCount = pageCount; } public IReportContainer Section {get;private set;} + public int PageCount {get; private set;} } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs index 03d7e53fab..17e5607dfb 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/FormatVisitor.cs @@ -30,8 +30,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors { - public override void Visit(ExportContainer exportContainer) - { + public override void Visit(ExportContainer exportContainer){ foreach (var element in exportContainer.ExportedItems) { var container = element as ExportContainer; if (container != null) { diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs index be4ded6e59..11114b1d41 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/StandardFormatter.cs @@ -31,6 +31,9 @@ namespace ICSharpCode.Reporting.Globals if (String.IsNullOrWhiteSpace(textColumn.Text)) { return; } + if (textColumn.Name == "xy") { + Console.WriteLine("stop"); + } if (!String.IsNullOrEmpty(textColumn.FormatString)) { if (textColumn.DataType.ToLower().Contains("timespan")) { textColumn.Text = HandleTimeSpan(textColumn.Text,textColumn.FormatString); @@ -38,6 +41,9 @@ namespace ICSharpCode.Reporting.Globals } else { var typeCode = TypeHelper.TypeCodeFromString(textColumn.DataType); textColumn.Text = FormatItem(textColumn.Text,textColumn.FormatString,typeCode); + if (textColumn.Name == "xy") { + Console.WriteLine("stop {0}",textColumn.Text); + } } } } @@ -156,8 +162,11 @@ namespace ICSharpCode.Reporting.Globals DateTime date; if (DateTime.TryParse(toFormat, out date)) { + string str = date.ToString(format, DateTimeFormatInfo.CurrentInfo); + + Console.WriteLine("---------{0} - {1} - {2}",toFormat,format, str); return str.Trim(); } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs index 784c15996a..d61931d4a3 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/BasePageBuilder.cs @@ -75,6 +75,7 @@ namespace ICSharpCode.Reporting.PageBuilder void BuildPageHeader(){ var pageHeader = CreateSection(ReportModel.PageHeader,CurrentLocation); DetailStart = new Point(ReportModel.ReportSettings.LeftMargin,pageHeader.Location.Y + pageHeader.DesiredSize.Height +1); +// var xx = pageHeader.ExportedItems.Where(x => x.Name.Contains("xy")).ToList(); AddSectionToPage(pageHeader); } @@ -121,7 +122,7 @@ namespace ICSharpCode.Reporting.PageBuilder #endregion protected IExportContainer CreateSection(IReportContainer container,Point location){ - var sea = new SectionEventArgs(container); + var sea = new SectionEventArgs(container,Pages.Count); Raise (SectionRendering,this,sea); var containerConverter = new ContainerConverter(location); var convertedContainer = containerConverter.ConvertToExportContainer(container); @@ -129,6 +130,7 @@ namespace ICSharpCode.Reporting.PageBuilder var list = containerConverter.CreateConvertedList(container.Items); containerConverter.SetParent(convertedContainer,list); + convertedContainer.ExportedItems.AddRange(list); //Run ExpressionEvaluator for every section, otherwise measure don't work ExpressionRunner.Visitor.Visit(convertedContainer as ExportContainer); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs index 1e82738667..dfce0b6bc2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs @@ -73,6 +73,7 @@ namespace ICSharpCode.Reporting.PageBuilder } } + /* void NewMethod(IContainerConverter converter, ref Point pagePosition, ref Point sectionPosition, IGrouping grouping, ExportContainer sectionContainer) { foreach (var child in grouping) { @@ -91,6 +92,7 @@ namespace ICSharpCode.Reporting.PageBuilder sectionContainer.Size = new Size(sectionContainer.Size.Width, sectionContainer.Size.Height + convertedItems[0].Size.Height); } } +*/ void BuildGroupedDetails (IContainerConverter converter,Point startPosition) { var pagePosition = startPosition; @@ -98,22 +100,22 @@ namespace ICSharpCode.Reporting.PageBuilder foreach (IGrouping grouping in DataSource.GroupedList) { - var groupHeader = (BaseRowItem)CurrentSection.Items.Where(p => p.GetType() == typeof(GroupHeader)).FirstOrDefault(); +// var groupHeader = (BaseRowItem)CurrentSection.Items.Where(p => p.GetType() == typeof(GroupHeader)).FirstOrDefault(); + var groupHeader = (BaseRowItem)CurrentSection + .Items. + FirstOrDefault(p => p.GetType() == typeof(GroupHeader)); var sectionContainer = CreateContainerForSection(CurrentPage, pagePosition); - DataSource.Fill(groupHeader.Items,grouping.FirstOrDefault()); var headerRow = converter.ConvertToExportContainer(groupHeader); + headerRow.Location = groupHeader.Location; + - headerRow.Location = new Point(headerRow.Location.X,groupHeader.Location.Y); - Console.WriteLine(headerRow.Location); var headerItems = converter.CreateConvertedList(groupHeader.Items); converter.SetParent(sectionContainer, headerItems); - headerRow.ExportedItems.AddRange(headerItems); - headerRow.Parent = sectionContainer; sectionContainer.ExportedItems.Add(headerRow); @@ -128,7 +130,13 @@ namespace ICSharpCode.Reporting.PageBuilder //Childs foreach (var child in grouping) { var dataItems = ExtractDataItems(CurrentSection.Items); - List convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter); + + var convertedItems = FillAndConvert(sectionContainer, child, dataItems, converter) + .OrderBy(p => p.Location.X).ToList(); + + var xx = convertedItems.FirstOrDefault().Location; + + Console.WriteLine(xx); AdjustLocationInSection(sectionPosition, convertedItems); @@ -242,9 +250,14 @@ namespace ICSharpCode.Reporting.PageBuilder static void AdjustLocationInSection(Point sectionPosition,List convertedItems){ - foreach (var element in convertedItems) { - element.Location = new Point(element.Location.X + sectionPosition.X , sectionPosition.Y); - } + + convertedItems.ForEach(element => {element.Location = new Point(element.Location.X,sectionPosition.Y); }); + + +// foreach (var element in convertedItems) { +//// element.Location = new Point(element.Location.X + sectionPosition.X , sectionPosition.Y); +// element.Location = new Point(element.Location.X , sectionPosition.Y); +// } }