Browse Source

WpfExporter

reports
Peter Forstmeier 12 years ago
parent
commit
95fdb380c1
  1. 33
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs
  2. 9
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs
  3. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

33
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ExportRenderer/FixedDocumentCreator.cs

@ -40,8 +40,6 @@ namespace ICSharpCode.Reporting.ExportRenderer
var fixedPage = new FixedPage(); var fixedPage = new FixedPage();
fixedPage.Width = exportPage.Size.ToWpf().Width; fixedPage.Width = exportPage.Size.ToWpf().Width;
fixedPage.Height = exportPage.Size.ToWpf().Height; fixedPage.Height = exportPage.Size.ToWpf().Height;
// fixedPage.Background = ConvertBrush(System.Drawing.Color.Blue);
fixedPage.Background = new SolidColorBrush(System.Drawing.Color.Blue.ToWpf()); fixedPage.Background = new SolidColorBrush(System.Drawing.Color.Blue.ToWpf());
return fixedPage; return fixedPage;
} }
@ -49,7 +47,6 @@ namespace ICSharpCode.Reporting.ExportRenderer
public Canvas CreateContainer(ExportContainer container) { public Canvas CreateContainer(ExportContainer container) {
var canvas = CreateCanvas(container); var canvas = CreateCanvas(container);
Console.WriteLine("WPF Create Container with {0}",container.DesiredSize);
var size = container.DesiredSize.ToWpf(); var size = container.DesiredSize.ToWpf();
canvas.Measure(size); canvas.Measure(size);
canvas.Arrange(new Rect(new Point(),size )); canvas.Arrange(new Rect(new Point(),size ));
@ -104,25 +101,25 @@ namespace ICSharpCode.Reporting.ExportRenderer
} }
static Size MeasureTextInWpf(ExportText exportText){ static Size MeasureTextInWpf(ExportText exportText){
if (exportText.CanGrow) { if (exportText.CanGrow) {
var formattedText = new FormattedText(exportText.Text,
CultureInfo.CurrentCulture,
FlowDirection.LeftToRight,
new Typeface(exportText.Font.FontFamily.Name),
exportText.Font.Size,
new SolidColorBrush(exportText.ForeColor.ToWpf()),
null,
TextFormattingMode.Display);
FormattedText ft = new FormattedText(exportText.Text, formattedText.MaxTextWidth = exportText.DesiredSize.Width * 96.0 / 72.0;
CultureInfo.CurrentCulture, // ft.MaxTextHeight = exportText.DesiredSize.Height + 5 * 96.0 / 72.0;
System.Windows.FlowDirection.LeftToRight, // ft.MaxTextHeight = Double.MaxValue ;
new Typeface(exportText.Font.FontFamily.Name),
exportText.Font.Size,
new SolidColorBrush(exportText.ForeColor.ToWpf()),
null,
TextFormattingMode.Display);
ft.MaxTextWidth = exportText.Size.Width * 96.0 / 72.0;
ft.MaxTextHeight = Double.MaxValue ;
ft.SetFontSize(exportText.Font.Size * 96.0 / 72.0); formattedText.SetFontSize(exportText.Font.Size * 96.0 / 72.0);
// ft.SetFontSize(exportText.Font.Size);
var size = new Size { var size = new Size {
Width = ft.WidthIncludingTrailingWhitespace, Width = formattedText.WidthIncludingTrailingWhitespace,
Height = ft.Height}; Height = formattedText.Height + 6};
return size; return size;
} }
return new Size(exportText.Size.Width,exportText.Size.Height); return new Size(exportText.Size.Width,exportText.Size.Height);

9
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/MeasurementService.cs

@ -15,7 +15,7 @@ namespace ICSharpCode.Reporting.Globals
/// <summary> /// <summary>
/// Description of MeasurementService. /// Description of MeasurementService.
/// </summary> /// </summary>
internal static class MeasurementService static class MeasurementService
{ {
@ -26,16 +26,15 @@ namespace ICSharpCode.Reporting.Globals
var sf = new StringFormat(); var sf = new StringFormat();
sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces; sf.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
if (!String.IsNullOrEmpty(item.Text)) { if (!String.IsNullOrEmpty(item.Text)) {
SizeF size = graphics.MeasureString(item.Text.TrimEnd(), SizeF sizeF = graphics.MeasureString(item.Text.TrimEnd(),
item.Font, item.Font,
item.Size.Width); item.Size.Width);
if (size.Height < item.Size.Height) { if (sizeF.Height < item.Size.Height) {
return item.Size; return item.Size;
} }
return new Size(item.Size.Width,(int)Math.Ceiling(size.Height)); return new Size(item.Size.Width,(int)Math.Ceiling(sizeF.Height));
} }
return item.Size; return item.Size;
} }
} }

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/DataPageBuilder.cs

@ -85,7 +85,7 @@ namespace ICSharpCode.Reporting.PageBuilder
converter.SetParent(sectionContainer, headerItems); converter.SetParent(sectionContainer, headerItems);
headerRow.ExportedItems.AddRange(headerItems); headerRow.ExportedItems.AddRange(headerItems);
headerRow.Parent = sectionContainer;
sectionContainer.ExportedItems.Add(headerRow); sectionContainer.ExportedItems.Add(headerRow);
EvaluateExpressionsInGroups(sectionContainer,grouping); EvaluateExpressionsInGroups(sectionContainer,grouping);

Loading…
Cancel
Save