Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit a98e696

Browse files
CanGrow
1 parent 627081e commit a98e696

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ public static FormattedText CreateFormattedText(ExportText exportText)
6666
FlowDirection flowDirection;
6767

6868
var culture = CultureInfo.CurrentCulture;
69-
if (culture.TextInfo.IsRightToLeft) {
70-
flowDirection = FlowDirection.RightToLeft;
71-
} else {
72-
flowDirection = FlowDirection.LeftToRight;
73-
}
69+
flowDirection = culture.TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
7470

7571
var emSize = ExtensionMethodes.ToPoints((int)exportText.Font.SizeInPoints +1);
7672

@@ -81,8 +77,14 @@ public static FormattedText CreateFormattedText(ExportText exportText)
8177
emSize,
8278
new SolidColorBrush(exportText.ForeColor.ToWpf()), null, TextFormattingMode.Display);
8379

84-
formattedText.MaxTextWidth = ExtensionMethodes.ToPoints(exportText.DesiredSize.Width);
80+
formattedText.MaxTextWidth = exportText.DesiredSize.Width ;
8581

82+
// formattedText.TextAlignment = TextAlignment.Justify;
83+
if (!exportText.CanGrow) {
84+
formattedText.MaxTextHeight = exportText.Size.Height;
85+
} else {
86+
formattedText.MaxTextHeight = ExtensionMethodes.ToPoints(exportText.DesiredSize.Height );
87+
}
8688
ApplyPrintStyles(formattedText,exportText);
8789

8890
return formattedText;

src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,26 +120,22 @@ Canvas RenderGraphicsContainer(IExportColumn column)
120120
public override void Visit(ExportText exportColumn){
121121

122122
var formattedText = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);
123-
var visual = new DrawingVisual();
124-
125123
var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
126124

127-
using (var dc = visual.RenderOpen()){
125+
var visual = new DrawingVisual();
126+
using (var drawingContext = visual.RenderOpen()){
128127
if (ShouldSetBackcolor(exportColumn)) {
129-
dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
128+
drawingContext.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
130129
null,
131130
new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height)));
132131
}
133-
132+
//http://stackoverflow.com/questions/4542717/length-of-string-that-will-fit-in-a-specific-width
134133
// http://stackoverflow.com/questions/9264398/how-to-calculate-wpf-textblock-width-for-its-known-font-size-and-characters
135134

136-
// if (exportColumn.ContentAlignment == System.Drawing.ContentAlignment.MiddleCenter) {
137-
// location = new Point(location.X + (exportColumn.Size.Width - formattedText.Width) /2,location.Y + (exportColumn.Size.Height - formattedText.Height) / 2);
138-
// }
139135
var offset = FixedDocumentCreator.CalculateAlignmentOffset(formattedText,exportColumn);
140136
var newLoc = new Point(location.X + offset.X,location.Y + offset.Y);
141-
// dc.DrawText(formattedText,location);
142-
dc.DrawText(formattedText,newLoc);
137+
138+
drawingContext.DrawText(formattedText,newLoc);
143139
}
144140
var dragingElement = new DrawingElement(visual);
145141
UIElement = dragingElement;

0 commit comments

Comments
 (0)