Browse Source

Change text drawing to FormattedText and DrawingVisual

reports
Peter Forstmeier 12 years ago
parent
commit
6570b60e68
  1. 4
      src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs
  2. 4
      src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd
  3. 55
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs
  4. 24
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs

4
src/AddIns/Analysis/CodeQuality/Reporting/OverviewReport.cs

@ -81,9 +81,9 @@ namespace ICSharpCode.CodeQuality.Reporting @@ -81,9 +81,9 @@ namespace ICSharpCode.CodeQuality.Reporting
if (sectionName == ReportSectionNames.ReportHeader) {
var param1 = (BaseTextItem)e.Section.Items.FirstOrDefault(n => n.Name == "Param1");
FileInfo fi =new FileInfo(FileNames[0]);
// FileInfo fi =new FileInfo(FileNames[0]);
// var s = fi..Directory + fi.Name;
param1.Text = fi.Name;
param1.Text = FileNames[0];
var param2 = (BaseTextItem)e.Section.Items.FirstOrDefault(n => n.Name == "Param2");
param2.Text = list.Count.ToString();
}

4
src/AddIns/Analysis/CodeQuality/Reporting/Overviewreport.srd

@ -116,12 +116,12 @@ @@ -116,12 +116,12 @@
</BaseTextItem>
<BaseTextItem>
<Location>139, 91</Location>
<Size>438, 20</Size>
<Size>377, 20</Size>
<BackColor>White</BackColor>
<Font>Segoe UI, 9pt</Font>
<StringTrimming>None</StringTrimming>
<ContentAlignment>TopLeft</ContentAlignment>
<CanGrow>False</CanGrow>
<CanGrow>True</CanGrow>
<CanShrink>False</CanShrink>
<RTL>No</RTL>
<Text>Parameters!param1</Text>

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

@ -59,7 +59,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -59,7 +59,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
return canvas;
}
/*
public static TextBlock CreateTextBlock(ExportText exportText,bool setBackcolor){
var textBlock = new TextBlock();
@ -79,8 +79,9 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -79,8 +79,9 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
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++) {
@ -101,22 +102,15 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -101,22 +102,15 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
textBlock.Height = wpfSize.Height;
}
*/
/*
static Size MeasureTextInWpf(ExportText exportText){
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);
var formattedText = NewMethod(exportText);
formattedText.MaxTextWidth = exportText.DesiredSize.Width * 96.0 / 72.0;
// ft.MaxTextHeight = exportText.DesiredSize.Height + 5 * 96.0 / 72.0;
// ft.MaxTextHeight = Double.MaxValue ;
formattedText.SetFontSize(Math.Floor(exportText.Font.Size * 96.0 / 72.0));
@ -128,6 +122,34 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -128,6 +122,34 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
return new Size(exportText.Size.Width,exportText.Size.Height);
}
*/
public static FormattedText CreateFormattedText(ExportText exportText)
{
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.MaxTextWidth = exportText.DesiredSize.Width * 96.0 / 72.0;
formattedText.SetFontSize(Math.Floor(exportText.Font.Size * 96.0 / 72.0));
var td = new TextDecorationCollection() ;
CheckUnderline(td,exportText);
formattedText.SetTextDecorations(td);
return formattedText;
}
static void CheckUnderline(TextDecorationCollection td, ExportText exportText)
{
if (exportText.Font.Underline) {
td.Add(new TextDecoration{Location = TextDecorationLocation.Underline});
}
}
static Canvas CreateCanvas(ExportContainer container){
var canvas = new Canvas();
@ -158,7 +180,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -158,7 +180,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
FixedPage.SetTop(element,exportColumn.Location.Y);
}
/*
static void SetFont(TextBlock textBlock,IExportText exportText){
textBlock.FontFamily = new FontFamily(exportText.Font.FontFamily.Name);
@ -180,7 +202,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -180,7 +202,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
CreateStrikeout(textBlock,exportText);
}
}
*/
static void SetContentAlignment(TextBlock textBlock,ExportText exportText)
{
@ -244,7 +266,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -244,7 +266,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
textBlock.TextDecorations.Add(strikeOut);
}
/*
static void CreateUnderline(TextBlock textBlock,IExportText exportColumn){
if (exportColumn == null)
throw new ArgumentNullException("exportColumn");
@ -256,7 +278,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -256,7 +278,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended;
textBlock.TextDecorations.Add(underLine);
}
*/
public static Pen CreateWpfPen(IReportObject exportColumn){
if (exportColumn == null)
@ -264,6 +286,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -264,6 +286,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
var pen = new Pen();
pen.Brush = ConvertBrush(exportColumn.ForeColor);
pen.Thickness = 1;
var exportGraphics = exportColumn as IExportGraphics;
if (exportGraphics != null) {
pen.Thickness = exportGraphics.Thickness;

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

@ -79,11 +79,27 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -79,11 +79,27 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
public override void Visit(ExportText exportColumn){
/*
var textBlock = FixedDocumentCreator.CreateTextBlock((ExportText)exportColumn,ShouldSetBackcolor(exportColumn));
CanvasHelper.SetPosition(textBlock,new Point(exportColumn.Location.X,exportColumn.Location.Y));
UIElement = textBlock;
*/
var ft = FixedDocumentCreator.CreateFormattedText((ExportText)exportColumn);
var visual = new DrawingVisual();
var location = new Point(exportColumn.Location.X,exportColumn.Location.Y);
using (var dc = visual.RenderOpen()){
if (ShouldSetBackcolor(exportColumn)) {
dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportColumn.BackColor),
null,
new Rect(location,new Size(exportColumn.Size.Width,exportColumn.Size.Height)));
}
dc.DrawText(ft,location);
}
var dragingElement = new DrawingElement(visual);
UIElement = dragingElement;
}
public override void Visit(ExportLine exportGraphics)
@ -111,8 +127,8 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -111,8 +127,8 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
new Rect(exportRectangle.Location.X,exportRectangle.Location.Y,
exportRectangle.Size.Width,exportRectangle.Size.Height));
}
DrawingElement m = new DrawingElement(visual);
UIElement = m;
var dragingElement = new DrawingElement(visual);
UIElement = dragingElement;
}
public override void Visit(ExportCircle exportCircle)
@ -132,8 +148,8 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -132,8 +148,8 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
}
DrawingElement m = new DrawingElement(visual);
UIElement = m;
var dragingElement = new DrawingElement(visual);
UIElement = dragingElement;
}
static Point CalcRad(System.Drawing.Size size) {

Loading…
Cancel
Save