|
|
|
@ -7,7 +7,6 @@ |
|
|
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
|
|
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
|
|
|
|
|
|
|
|
using System.Globalization; |
|
|
|
using System.Globalization; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls; |
|
|
|
@ -56,25 +55,35 @@ namespace ICSharpCode.Reporting.ExportRenderer |
|
|
|
canvas.UpdateLayout(); |
|
|
|
canvas.UpdateLayout(); |
|
|
|
return canvas; |
|
|
|
return canvas; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public TextBlock CreateTextBlock(ExportText exportText,bool setBackcolor){ |
|
|
|
public TextBlock CreateTextBlock(ExportText exportText,bool setBackcolor){ |
|
|
|
var textBlock = new TextBlock(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var textBlock = new TextBlock(); |
|
|
|
|
|
|
|
|
|
|
|
textBlock.Foreground = ConvertBrush(exportText.ForeColor); |
|
|
|
textBlock.Foreground = ConvertBrush(exportText.ForeColor); |
|
|
|
|
|
|
|
/* |
|
|
|
if (setBackcolor) { |
|
|
|
if (setBackcolor) { |
|
|
|
textBlock.Background = ConvertBrush(exportText.BackColor); |
|
|
|
textBlock.Background = ConvertBrush(exportText.BackColor); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
textBlock.Background = ConvertBrush(System.Drawing.Color.LightPink); |
|
|
|
|
|
|
|
|
|
|
|
// textBlock.Background = ConvertBrush(System.Drawing.Color.LightGray);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SetFont(textBlock,exportText); |
|
|
|
SetFont(textBlock,exportText); |
|
|
|
|
|
|
|
|
|
|
|
textBlock.TextWrapping = TextWrapping.WrapWithOverflow; |
|
|
|
textBlock.TextWrapping = TextWrapping.Wrap; |
|
|
|
|
|
|
|
textBlock.TextTrimming = TextTrimming.CharacterEllipsis; |
|
|
|
|
|
|
|
|
|
|
|
string [] inlines = exportText.Text.Split(System.Environment.NewLine.ToCharArray()); |
|
|
|
CheckForNewLine (textBlock,exportText); |
|
|
|
|
|
|
|
SetContentAlignment(textBlock,exportText); |
|
|
|
|
|
|
|
MeasureTextBlock (textBlock,exportText); |
|
|
|
|
|
|
|
return textBlock; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void CheckForNewLine(TextBlock textBlock,ExportText exportText) { |
|
|
|
|
|
|
|
string [] inlines = exportText.Text.Split(Environment.NewLine.ToCharArray()); |
|
|
|
for (int i = 0; i < inlines.Length; i++) { |
|
|
|
for (int i = 0; i < inlines.Length; i++) { |
|
|
|
if (inlines[i].Length > 0) { |
|
|
|
if (inlines[i].Length > 0) { |
|
|
|
textBlock.Inlines.Add(new Run(inlines[i])); |
|
|
|
textBlock.Inlines.Add(new Run(inlines[i])); |
|
|
|
@ -83,45 +92,37 @@ namespace ICSharpCode.Reporting.ExportRenderer |
|
|
|
} |
|
|
|
} |
|
|
|
var li = textBlock.Inlines.LastInline; |
|
|
|
var li = textBlock.Inlines.LastInline; |
|
|
|
textBlock.Inlines.Remove(li); |
|
|
|
textBlock.Inlines.Remove(li); |
|
|
|
SetContentAlignment(textBlock,exportText); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void MeasureTextBlock(TextBlock textBlock,ExportText exportText) |
|
|
|
|
|
|
|
{ |
|
|
|
var wpfSize = MeasureTextInWpf(exportText); |
|
|
|
var wpfSize = MeasureTextInWpf(exportText); |
|
|
|
textBlock.Width = wpfSize.Width; |
|
|
|
textBlock.Width = wpfSize.Width; |
|
|
|
textBlock.Height = wpfSize.Height; |
|
|
|
textBlock.Height = wpfSize.Height; |
|
|
|
|
|
|
|
} |
|
|
|
// textBlock.Background = ConvertBrush(exportText.StyleDecorator.BackColor);
|
|
|
|
|
|
|
|
// SetContendAlignment(textBlock,exportText.StyleDecorator);
|
|
|
|
|
|
|
|
if (exportText.ContentAlignment != System.Drawing.ContentAlignment.TopLeft) { |
|
|
|
|
|
|
|
Console.WriteLine("----Aliogn --------{0}",exportText.ContentAlignment.ToString()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// SetContentAlignment(textBlock,exportText);
|
|
|
|
|
|
|
|
return textBlock; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static Size MeasureTextInWpf(ExportText exportText){ |
|
|
|
static Size MeasureTextInWpf(ExportText exportText){ |
|
|
|
if (exportText.CanGrow) { |
|
|
|
if (exportText.CanGrow) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FormattedText ft = new FormattedText(exportText.Text, |
|
|
|
FormattedText ft = new FormattedText(exportText.Text, |
|
|
|
CultureInfo.CurrentCulture, |
|
|
|
CultureInfo.CurrentCulture, |
|
|
|
System.Windows.FlowDirection.LeftToRight, |
|
|
|
System.Windows.FlowDirection.LeftToRight, |
|
|
|
new Typeface(exportText.Font.FontFamily.Name), |
|
|
|
new Typeface(exportText.Font.FontFamily.Name), |
|
|
|
exportText.Font.Size, |
|
|
|
exportText.Font.Size, |
|
|
|
new SolidColorBrush(exportText.ForeColor.ToWpf()), |
|
|
|
// System.Windows.Media.Brushes.Black,
|
|
|
|
null, |
|
|
|
new SolidColorBrush(exportText.ForeColor.ToWpf()), |
|
|
|
TextFormattingMode.Display); |
|
|
|
|
|
|
|
|
|
|
|
null, |
|
|
|
ft.MaxTextWidth = exportText.Size.Width * 96.0 / 72.0; |
|
|
|
TextFormattingMode.Display); |
|
|
|
ft.MaxTextHeight = Double.MaxValue ; |
|
|
|
|
|
|
|
|
|
|
|
ft.MaxTextWidth = exportText.Size.Width * 96.0 / 72.0; |
|
|
|
ft.SetFontSize(exportText.Font.Size * 96.0 / 72.0); |
|
|
|
ft.MaxTextHeight = Double.MaxValue ; |
|
|
|
|
|
|
|
|
|
|
|
var size = new Size { |
|
|
|
ft.SetFontSize(exportText.Font.Size * 96.0 / 72.0); |
|
|
|
Width = ft.WidthIncludingTrailingWhitespace, |
|
|
|
|
|
|
|
Height = ft.Height}; |
|
|
|
var ss = new Size { |
|
|
|
return size; |
|
|
|
Width = ft.WidthIncludingTrailingWhitespace, |
|
|
|
|
|
|
|
Height = ft.Height}; |
|
|
|
|
|
|
|
return ss; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return new Size(exportText.Size.Width,exportText.Size.Height); |
|
|
|
return new Size(exportText.Size.Width,exportText.Size.Height); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -185,7 +186,6 @@ namespace ICSharpCode.Reporting.ExportRenderer |
|
|
|
// http://social.msdn.microsoft.com/Forums/vstudio/en-US/e480abb9-a86c-4f78-8955-dddb866bcfef/vertical-text-alignment-in-textblock?forum=wpf
|
|
|
|
// http://social.msdn.microsoft.com/Forums/vstudio/en-US/e480abb9-a86c-4f78-8955-dddb866bcfef/vertical-text-alignment-in-textblock?forum=wpf
|
|
|
|
//Vertical alignment not working
|
|
|
|
//Vertical alignment not working
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("align {0}",exportText.ContentAlignment); |
|
|
|
|
|
|
|
switch (exportText.ContentAlignment) { |
|
|
|
switch (exportText.ContentAlignment) { |
|
|
|
case System.Drawing.ContentAlignment.TopLeft: |
|
|
|
case System.Drawing.ContentAlignment.TopLeft: |
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top; |
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top; |
|
|
|
@ -227,52 +227,8 @@ namespace ICSharpCode.Reporting.ExportRenderer |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
|
|
|
|
private void SetContendAlignment(TextBlock textBlock,TextStyleDecorator decorator) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (decorator.ContentAlignment) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case ContentAlignment.TopLeft: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Left; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.TopCenter: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Center; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.TopRight: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Top; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Right; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
// Middle
|
|
|
|
|
|
|
|
case ContentAlignment.MiddleLeft: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Center; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Left; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.MiddleCenter: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Center; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Center; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.MiddleRight: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Center; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Right; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
//Bottom
|
|
|
|
|
|
|
|
case ContentAlignment.BottomLeft: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Bottom; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Left; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.BottomCenter: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Bottom; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Center; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case ContentAlignment.BottomRight: |
|
|
|
|
|
|
|
textBlock.VerticalAlignment = VerticalAlignment.Bottom; |
|
|
|
|
|
|
|
textBlock.TextAlignment = TextAlignment.Right; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
void CreateStrikeout (TextBlock textBlock,IExportText exportColumn ){ |
|
|
|
void CreateStrikeout (TextBlock textBlock,IExportText exportColumn ){ |
|
|
|
if (textBlock == null) |
|
|
|
if (textBlock == null) |
|
|
|
throw new ArgumentNullException("textBlock"); |
|
|
|
throw new ArgumentNullException("textBlock"); |
|
|
|
|