Browse Source

WPF - draw Rectangle

reports
Peter Forstmeier 12 years ago
parent
commit
24d659f52a
  1. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
  2. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs
  3. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs
  4. 34
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs
  5. 39
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs
  6. 15
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/FixedDocumentCreator.cs
  7. 10
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/Graphics/ExtendedLine.cs
  8. 30
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj

@ -146,6 +146,7 @@ @@ -146,6 +146,7 @@
<Compile Include="Src\Items\BaseTextItem.cs" />
<Compile Include="Src\Items\Graphics\BaseGraphics.cs" />
<Compile Include="Src\Items\Graphics\BaseLineItem.cs" />
<Compile Include="Src\Items\Graphics\BaseRectangleItem.cs" />
<Compile Include="Src\Items\GroupColumn.cs" />
<Compile Include="Src\Items\PrintableItem.cs" />
<Compile Include="Src\Items\ReportContainer.cs" />
@ -159,6 +160,7 @@ @@ -159,6 +160,7 @@
<Compile Include="Src\PageBuilder\ExportColumns\ExportColumn.cs" />
<Compile Include="Src\PageBuilder\ExportColumns\ExportContainer.cs" />
<Compile Include="Src\PageBuilder\ExportColumns\ExportLine.cs" />
<Compile Include="Src\PageBuilder\ExportColumns\ExportRectangle.cs" />
<Compile Include="Src\PageBuilder\ExportColumns\ExportText.cs" />
<Compile Include="Src\PageBuilder\ExportColumns\ExportPage.cs" />
<Compile Include="Src\PageBuilder\FormPageBuilder.cs" />

3
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/AbstractVisitor.cs

@ -57,6 +57,9 @@ namespace ICSharpCode.Reporting.Exporter.Visitors @@ -57,6 +57,9 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
{
}
public virtual void Visit (ExportRectangle exportRectangle) {
}
protected bool ShouldSetBackcolor (ExportColumn exportColumn) {
return exportColumn.BackColor != Color.White;

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/IVisitor.cs

@ -17,5 +17,6 @@ namespace ICSharpCode.Reporting.Exporter.Visitors @@ -17,5 +17,6 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
void Visit(ExportContainer exportColumn);
void Visit(ExportText exportColumn);
void Visit(ExportLine exportGraphics);
void Visit (ExportRectangle exportRectangle);
}
}

34
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.Reporting.Interfaces.Export;
using ICSharpCode.Reporting.PageBuilder.ExportColumns;
namespace ICSharpCode.Reporting.Items
{
/// <summary>
/// Description of BaseRectangleItem.
/// </summary>
public class BaseRectangleItem:BaseGraphics
{
public BaseRectangleItem()
{
}
public override IExportColumn CreateExportColumn()
{
var ex = new ExportRectangle();
ex.Location = Location;
ex.ForeColor = ForeColor;
ex.BackColor = BackColor;
ex.Size = Size;
ex.DesiredSize = Size;
ex.Thickness = Thickness;
ex.DashStyle = DashStyle;
ex.StartLineCap = StartLineCap;
ex.EndLineCap = EndLineCap;
return ex;
}
}
}

39
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Drawing.Drawing2D;
using ICSharpCode.Reporting.Exporter.Visitors;
using ICSharpCode.Reporting.Interfaces.Export;
namespace ICSharpCode.Reporting.PageBuilder.ExportColumns
{
/// <summary>
/// Description of ExportRectangle.
/// </summary>
public class ExportRectangle:ExportColumn,IExportGraphics,IAcceptor
{
public ExportRectangle()
{
}
public void Accept(IVisitor visitor)
{
visitor.Visit(this);
}
public override ICSharpCode.Reporting.Arrange.IMeasurementStrategy MeasurementStrategy()
{
throw new NotImplementedException();
}
public int Thickness {get;set;}
public DashStyle DashStyle {get;set;}
public LineCap StartLineCap {get;set;}
public LineCap EndLineCap {get;set;}
}
}

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

@ -251,10 +251,17 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -251,10 +251,17 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
public static Pen CreateWpfPen(IReportObject exportColumn){
if (exportColumn == null)
throw new ArgumentNullException("exportColumn");
var myPen = new Pen();
myPen.Brush = ConvertBrush(exportColumn.ForeColor);
myPen.Thickness = 1;
return myPen;
var pen = new Pen();
pen.Brush = ConvertBrush(exportColumn.ForeColor);
pen.Thickness = 1;
var exportGraphics = exportColumn as IExportGraphics;
if (exportGraphics != null) {
pen.Thickness = exportGraphics.Thickness;
pen.DashStyle = FixedDocumentCreator.DashStyle(exportGraphics);
pen.StartLineCap = FixedDocumentCreator.LineCap(exportGraphics.StartLineCap);
pen.EndLineCap = FixedDocumentCreator.LineCap(exportGraphics.EndLineCap);
}
return pen;
}

10
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/Graphics/ExtendedLine.cs

@ -14,10 +14,16 @@ using ICSharpCode.Reporting.PageBuilder.ExportColumns; @@ -14,10 +14,16 @@ using ICSharpCode.Reporting.PageBuilder.ExportColumns;
namespace ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics
{
class ExtendedLine : FrameworkElement{
class DrawingElement : FrameworkElement{
private VisualCollection children;
public DrawingElement(DrawingVisual visual) {
children = new VisualCollection(this);
children.Add(visual);
}
/*
public ExtendedLine(ExportLine exportGraphics,Pen pen){
children = new VisualCollection(this);
var visual = new DrawingVisual();
@ -29,7 +35,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics @@ -29,7 +35,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor.Graphics
new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y));
}
}
*/
protected override int VisualChildrenCount{
get { return children.Count; }

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

@ -81,15 +81,35 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor @@ -81,15 +81,35 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor
public override void Visit(ExportLine exportGraphics)
{
var pen = FixedDocumentCreator.CreateWpfPen(exportGraphics);
pen.Thickness = exportGraphics.Thickness;
pen.DashStyle = FixedDocumentCreator.DashStyle(exportGraphics);
pen.StartLineCap = FixedDocumentCreator.LineCap(exportGraphics.StartLineCap);
pen.EndLineCap = FixedDocumentCreator.LineCap(exportGraphics.EndLineCap);
ExtendedLine m = new ExtendedLine(exportGraphics,pen);
var visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
{
dc.DrawLine(pen,
new Point(exportGraphics.Location.X, exportGraphics.Location.Y),
new Point(exportGraphics.Location.X + exportGraphics.Size.Width,exportGraphics.Location.Y));
}
DrawingElement m = new DrawingElement(visual);
UIElement = m;
}
public override void Visit(ExportRectangle exportRectangle)
{
var pen = FixedDocumentCreator.CreateWpfPen(exportRectangle);
var visual = new DrawingVisual();
using (var dc = visual.RenderOpen())
{dc.DrawRectangle(FixedDocumentCreator.ConvertBrush(exportRectangle.BackColor),
pen,
new Rect(exportRectangle.Location.X,exportRectangle.Location.Y,
exportRectangle.Size.Width,exportRectangle.Size.Height));
}
DrawingElement m = new DrawingElement(visual);
UIElement = m;
}
protected UIElement UIElement {get;private set;}

Loading…
Cancel
Save