Browse Source

Visual Controls and ReportItems now use the same drawing functions

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1359 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Peter Forstmeier 20 years ago
parent
commit
f8a7e02e13
  1. 2
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs
  2. 4
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs
  3. 2
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs
  4. 6
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs
  5. 23
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs
  6. 19
      src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs
  7. 1
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs
  8. 4
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs
  9. 1
      src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs
  10. 23
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs
  11. 4
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs
  12. 29
      src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs
  13. 49
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseLine.cs
  14. 40
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs
  15. 19
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs
  16. 10
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/FillPatterns.cs
  17. 22
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs
  18. 27
      src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs

2
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ControlHelper.cs

@ -15,7 +15,7 @@ namespace SharpReport.Designer @@ -15,7 +15,7 @@ namespace SharpReport.Designer
/// <summary>
/// Description of ControlHelper.
/// </summary>
internal class ControlHelper{
public class ControlHelper{
Control control;
public ControlHelper(Control control){

4
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportControlBase.cs

@ -129,6 +129,10 @@ namespace SharpReport.Designer{ @@ -129,6 +129,10 @@ namespace SharpReport.Designer{
this.Invalidate();
}
protected Rectangle FocusRectangle {
get {return this.controlHelper.BuildFocusRectangle;}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.

2
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportLineControl.cs

@ -39,7 +39,7 @@ namespace SharpReport.Designer{ @@ -39,7 +39,7 @@ namespace SharpReport.Designer{
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) {
base.OnPaint(pea);
base.DrawEdges (pea);
base.DrawDecorations(pea);
// base.DrawDecorations(pea);
shape.DrawShape(pea.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),

6
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRectangleControl.cs

@ -41,15 +41,15 @@ namespace SharpReport.Designer { @@ -41,15 +41,15 @@ namespace SharpReport.Designer {
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) {
base.OnPaint(pea);
base.DrawEdges (pea);
base.DrawDecorations(pea);
shape.FillShape(pea.Graphics,
new SolidFillPattern(this.BackColor),
(RectangleF)this.ClientRectangle);
(RectangleF)base.FocusRectangle);
shape.DrawShape (pea.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),
(RectangleF)this.ClientRectangle);
(RectangleF)base.FocusRectangle);
}

23
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportRowControl.cs

@ -21,7 +21,8 @@ namespace SharpReport.Designer{ @@ -21,7 +21,8 @@ namespace SharpReport.Designer{
/// </summary>
internal class ReportRowControl:ReportControlBase{
private RectangleShape shape = new RectangleShape();
private bool drawBorder;
public ReportRowControl():base(){
InitializeComponent();
this.SetStyle(ControlStyles.DoubleBuffer |
@ -39,10 +40,15 @@ namespace SharpReport.Designer{ @@ -39,10 +40,15 @@ namespace SharpReport.Designer{
#region overrides
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){
base.OnPaint(pea);
Rectangle r = new Rectangle(0,5,this.ClientSize.Width - 1,this.ClientSize.Height - 6);
base.DrawEdges (pea,r);
base.DrawEdges (pea,
new Rectangle(0,5,this.ClientSize.Width - 1,this.ClientSize.Height - 6) );
base.DrawDecorations(pea);
if (this.drawBorder) {
shape.DrawShape (pea.Graphics,
new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1),
base.FocusRectangle);
}
StringFormat fmt = GlobalValues.StandartStringFormat();
fmt.LineAlignment = StringAlignment.Near;
@ -54,11 +60,18 @@ namespace SharpReport.Designer{ @@ -54,11 +60,18 @@ namespace SharpReport.Designer{
}
public override string ToString() {
return this.Name;
return this.GetType().Name;
}
#endregion
public bool DrawBorder {
set {
drawBorder = value;
this.Invalidate();
}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.

19
src/AddIns/Misc/SharpReport/SharpReport/Designer/VisualControls/ReportTextControl.cs

@ -21,8 +21,10 @@ namespace SharpReport.Designer{ @@ -21,8 +21,10 @@ namespace SharpReport.Designer{
private StringTrimming stringTrimming;
private ContentAlignment contentAlignment;
TextDrawer textDrawer = new TextDrawer();
private bool drawBorder;
private TextDrawer textDrawer = new TextDrawer();
private RectangleShape shape = new RectangleShape();
public ReportTextControl():base(){
InitializeComponent();
@ -36,6 +38,12 @@ namespace SharpReport.Designer{ @@ -36,6 +38,12 @@ namespace SharpReport.Designer{
this.Size = GlobalValues.PreferedSize;
}
public bool DrawBorder {
set {
drawBorder = value;
this.Invalidate();
}
}
@ -61,7 +69,7 @@ namespace SharpReport.Designer{ @@ -61,7 +69,7 @@ namespace SharpReport.Designer{
}
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea){
base.OnPaint(pea);
base.DrawEdges (pea);
base.DrawDecorations(pea);
@ -74,9 +82,16 @@ namespace SharpReport.Designer{ @@ -74,9 +82,16 @@ namespace SharpReport.Designer{
str = this.Text;
}
if (this.drawBorder) {
shape.DrawShape (pea.Graphics,
new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1),
base.FocusRectangle);
}
this.textDrawer.DrawString (pea.Graphics,this.Text,this.Font,
new SolidBrush(this.ForeColor),(RectangleF)this.ClientRectangle,
this.stringTrimming,this.contentAlignment);
}

1
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ItemsHelper.cs

@ -53,7 +53,6 @@ namespace SharpReport { @@ -53,7 +53,6 @@ namespace SharpReport {
control.Size = item.Size;
control.Font = item.Font;
control.Name = item.Name;
BaseTextItem b = item as BaseTextItem;
}

4
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportRowItem.cs

@ -108,6 +108,7 @@ namespace SharpReport.ReportItems @@ -108,6 +108,7 @@ namespace SharpReport.ReportItems
private void BasePropertyChange (object sender, PropertyChangedEventArgs e){
ItemsHelper.UpdateControlFromTextBase (this.visualControl,this);
this.visualControl.DrawBorder = base.DrawBorder;
this.HandlePropertyChanged(e.PropertyName);
}
@ -115,6 +116,7 @@ namespace SharpReport.ReportItems @@ -115,6 +116,7 @@ namespace SharpReport.ReportItems
private void OnControlChanged (object sender, EventArgs e) {
this.SuspendLayout();
ItemsHelper.UpdateBaseFromTextControl (this.visualControl,this);
this.ResumeLayout();
this.HandlePropertyChanged("OnControlChanged");
@ -206,7 +208,7 @@ namespace SharpReport.ReportItems @@ -206,7 +208,7 @@ namespace SharpReport.ReportItems
}
public override string ToString(){
return this.Name;
return this.GetType().Name;
}
#endregion

1
src/AddIns/Misc/SharpReport/SharpReport/ReportItems/TextBased/ReportTextItem.cs

@ -57,6 +57,7 @@ namespace SharpReport.ReportItems { @@ -57,6 +57,7 @@ namespace SharpReport.ReportItems {
this.visualControl.ContentAlignment = base.ContentAlignment;
this.visualControl.StringTrimming = base.StringTrimming;
this.visualControl.DrawBorder = base.DrawBorder;
this.HandlePropertyChanged(e.PropertyName);
}

23
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/BaseTextItem.cs

@ -30,6 +30,7 @@ namespace SharpReportCore { @@ -30,6 +30,7 @@ namespace SharpReportCore {
private StringTrimming stringTrimming;
private TextDrawer textDrawer = new TextDrawer();
private ContentAlignment contentAlignment;
private RectangleShape shape = new RectangleShape();
#region Constructor
@ -63,27 +64,21 @@ namespace SharpReportCore { @@ -63,27 +64,21 @@ namespace SharpReportCore {
}
protected void FillBackGround (Graphics graphics,RectangleF rectangle) {
using (SolidBrush brush = new SolidBrush(base.BackColor)) {
graphics.FillRectangle(brush,rectangle);
}
shape.FillShape(graphics,
new SolidFillPattern(this.BackColor),
rectangle);
}
protected void DrawFrame (Graphics graphics,Rectangle border) {
protected void DrawFrame (Graphics graphics,Rectangle rectangle) {
if (base.DrawBorder == true) {
using (Pen pen = new Pen(Color.Black, 1)) {
graphics.DrawRectangle (pen,border);
}
//TODO use this class to draw a border
// RectangleShape shape = new RectangleShape();
// shape.DrawShape (graphics,
// new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1),
// border);
shape.DrawShape (graphics,
new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1),
rectangle);
}
}
protected RectangleF PrepareRectangle (ReportPageEventArgs rpea,string text) {
SizeF measureSize = new SizeF ();
measureSize = MeasureReportItem (rpea,text);
SizeF measureSize = MeasureReportItem (rpea,text);
RectangleF rect = base.DrawingRectangle (rpea,measureSize);
return rect;
}

4
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/Graphics/BaseRectangleItem.cs

@ -25,11 +25,9 @@ using System.Drawing; @@ -25,11 +25,9 @@ using System.Drawing;
namespace SharpReportCore {
public class BaseRectangleItem : SharpReportCore.BaseGraphicItem {
private ArrayList arrayList;
RectangleShape shape = new RectangleShape();
public BaseRectangleItem() {
arrayList = new ArrayList();
}
public override void Render(ReportPageEventArgs rpea) {
@ -39,7 +37,7 @@ namespace SharpReportCore { @@ -39,7 +37,7 @@ namespace SharpReportCore {
shape.FillShape(rpea.PrintPageEventArgs.Graphics,
new SolidFillPattern(this.BackColor),
rect);
shape.DrawShape (rpea.PrintPageEventArgs.Graphics,
new BaseLine (this.ForeColor,base.DashStyle,base.Thickness),
rect);

29
src/AddIns/Misc/SharpReport/SharpReportCore/BaseItems/RowItem.cs

@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Forms;
@ -25,6 +26,8 @@ namespace SharpReportCore{ @@ -25,6 +26,8 @@ namespace SharpReportCore{
private Padding padding;
private Color alternateBackColor;
private int changeBackColorEveryNRow;
private RectangleShape shape = new RectangleShape();
public RowItem():this (String.Empty){
}
@ -41,16 +44,7 @@ namespace SharpReportCore{ @@ -41,16 +44,7 @@ namespace SharpReportCore{
}
#region overrides
private void Decorate (ReportPageEventArgs rpea,Rectangle border) {
using (SolidBrush brush = new SolidBrush(base.BackColor)) {
rpea.PrintPageEventArgs.Graphics.FillRectangle(brush,border);
}
if (base.DrawBorder == true) {
using (Pen pen = new Pen(Color.Black, 1)) {
rpea.PrintPageEventArgs.Graphics.DrawRectangle (pen,border);
}
}
}
protected RectangleF PrepareRectangle (ReportPageEventArgs e) {
SizeF measureSize = new SizeF ((SizeF)this.Size);
@ -65,11 +59,20 @@ namespace SharpReportCore{ @@ -65,11 +59,20 @@ namespace SharpReportCore{
throw new ArgumentNullException("rpea");
}
System.Console.WriteLine("");
System.Console.WriteLine("--Start Row Item");
System.Console.WriteLine("--Start of {0}",this.ToString());
base.Render(rpea);
RectangleF rect = PrepareRectangle (rpea);
Decorate (rpea,System.Drawing.Rectangle.Ceiling (rect));
shape.FillShape(rpea.PrintPageEventArgs.Graphics,
new SolidFillPattern(this.BackColor),
rect);
if (base.DrawBorder == true) {
shape.DrawShape (rpea.PrintPageEventArgs.Graphics,
new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1),
rect);
}
foreach (BaseReportItem childItem in this.items) {
Point loc = new Point (childItem.Location.X,childItem.Location.Y);
@ -86,7 +89,7 @@ namespace SharpReportCore{ @@ -86,7 +89,7 @@ namespace SharpReportCore{
}
public override string ToString(){
return "RowItem";
return this.GetType().Name;
}
#endregion

49
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseLine.cs

@ -31,7 +31,7 @@ using System.Drawing.Drawing2D; @@ -31,7 +31,7 @@ using System.Drawing.Drawing2D;
/// created by - Forstmeier Peter
/// created on - 09.10.2005 18:37:51
/// </remarks>
namespace SharpReportCore {
namespace SharpReportCore {
public class BaseLine : object {
DashStyle dashStyle;
@ -45,10 +45,51 @@ namespace SharpReportCore { @@ -45,10 +45,51 @@ namespace SharpReportCore {
this.thickness = thickness;
}
public void CreatePen () {
throw new NotImplementedException("BaseLine:CreatePen");
}
public Pen CreatePen(){
return this.CreatePen(72f);
}
public Pen CreatePen(float resolution)
{
Pen pen;
if (this.thickness == 0f)
{
pen = new Pen(this.color, resolution / 72f);
}
else
{
pen = new Pen(this.color, (this.thickness * resolution) / 72f);
}
switch (this.dashStyle){
case DashStyle.Dot:
{
pen.DashStyle = DashStyle.Dot;
return pen;
}
case DashStyle.Dash:
{
pen.DashStyle = DashStyle.Dash;
return pen;
}
case DashStyle.DashDot:
{
pen.DashStyle = DashStyle.DashDot;
return pen;
}
case DashStyle.DashDotDot:
{
pen.DashStyle = DashStyle.DashDotDot;
return pen;
}
}
return pen;
}
public Color Color {
get {
return color;

40
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/BaseShape.cs

@ -31,33 +31,47 @@ using System.Drawing.Drawing2D; @@ -31,33 +31,47 @@ using System.Drawing.Drawing2D;
/// </remarks>
namespace SharpReportCore {
public class BaseShape : object {
public abstract class BaseShape : object {
public BaseShape() {
}
public virtual void DrawShape (Graphics graphics,BaseLine baseLine,RectangleF rectangle) {
public void FillShape (Graphics graphics, Brush brush,RectangleF rectangle) {
}
GraphicsPath path1 = this.CreatePath(rectangle);
graphics.FillPath(brush, path1);
public virtual void DrawShape (Graphics graphics,Pen pen,RectangleF rectangle) {
}
public void FillShape (Graphics graphics,AbstractFillPattern fillPattern,RectangleF rectangle) {
if (fillPattern != null){
using (Brush brush = fillPattern.CreateBrush(rectangle)){
if (brush != null){
this.FillShape(graphics, brush, rectangle);
}
}
}
}
public abstract GraphicsPath CreatePath (RectangleF rectangle) ;
public virtual void FillShape (Graphics graphics, Brush brush,RectangleF rectangle) {
}
public virtual void FillShape (Graphics graphics,AbstractFillPattern fillPattern,RectangleF rectangle) {
}
public virtual GraphicsPath CreatePath (RectangleF rectangleF) {
return null;
public void DrawShape(Graphics g, BaseLine line, RectangleF rectangle){
using (Pen pen = line.CreatePen()){
if (pen != null){
this.new_DrawShape(g, pen, rectangle);
}
}
}
public void new_DrawShape(Graphics g, Pen pen, RectangleF rectangle){
GraphicsPath path1 = this.CreatePath(rectangle);
g.DrawPath(pen, path1);
}
}
}

19
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/EllipseShape.cs

@ -20,6 +20,8 @@ @@ -20,6 +20,8 @@
// Peter Forstmeier (Peter.Forstmeier@t-online.de)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
/// <summary>
/// This class draws a Ellipse/Ellipse
/// </summary>
@ -37,19 +39,10 @@ namespace SharpReportCore { @@ -37,19 +39,10 @@ namespace SharpReportCore {
}
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
graphics.DrawEllipse(p,
rectangle);
}
}
public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
graphics.FillEllipse(fillPattern.Brush,
rectangle);
public override GraphicsPath CreatePath(RectangleF rectangle){
GraphicsPath path = new GraphicsPath();
path.AddEllipse(rectangle);
return path;
}
}

10
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/FillPatterns.cs

@ -39,7 +39,8 @@ namespace SharpReportCore { @@ -39,7 +39,8 @@ namespace SharpReportCore {
}
public abstract Brush CreateBrush(RectangleF rect);
protected Color Color {
get {
return color;
@ -64,7 +65,12 @@ namespace SharpReportCore { @@ -64,7 +65,12 @@ namespace SharpReportCore {
/// </summary>
public class SolidFillPattern : AbstractFillPattern {
public SolidFillPattern (Color color) :base(color){
base.Brush = new SolidBrush(color);
// base.Brush = new SolidBrush(color);
}
public override Brush CreateBrush(RectangleF rect){
return new SolidBrush(this.Color);
}
}
}

22
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/LineShape.cs

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
// Peter Forstmeier (Peter.Forstmeier@t-online.de)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
/// <summary>
/// Draw a Line, used by DesingerControls and printing stuff
@ -37,21 +37,13 @@ namespace SharpReportCore { @@ -37,21 +37,13 @@ namespace SharpReportCore {
/// </summary>
public LineShape() {
}
public override GraphicsPath CreatePath(RectangleF rectangle){
GraphicsPath path = new GraphicsPath();
float halfRect = rectangle.Top + (rectangle.Height /2);
path.AddLine(rectangle.Left, halfRect, rectangle.Right, halfRect);
return path;
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
float halfRect = rectangle.Top + (rectangle.Height / 2);
graphics.DrawLine (p,
rectangle.X,
halfRect,
rectangle.X + rectangle.Width,
halfRect);
}
}
}
}

27
src/AddIns/Misc/SharpReport/SharpReportCore/Printing/Graphics/RectangleShape.cs

@ -20,6 +20,7 @@ @@ -20,6 +20,7 @@
// Peter Forstmeier (Peter.Forstmeier@t-online.de)
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
/// <summary>
/// Draw a Rectangle, used by DesingerControls and printing stuff
@ -34,27 +35,13 @@ namespace SharpReportCore { @@ -34,27 +35,13 @@ namespace SharpReportCore {
public RectangleShape() {
}
public override void DrawShape(Graphics graphics, BaseLine baseLine, RectangleF rectangle) {
base.DrawShape(graphics,baseLine,rectangle);
using (Pen p = new Pen(baseLine.Color,baseLine.Thickness)) {
p.DashStyle = baseLine.DashStyle;
graphics.DrawRectangle (p,rectangle.Left,
rectangle.Top,
rectangle.Width,
rectangle.Height);
}
}
public override void FillShape(Graphics graphics, AbstractFillPattern fillPattern, RectangleF rectangle) {
graphics.FillRectangle(fillPattern.Brush,
rectangle);
}
public override void FillShape(Graphics graphics, Brush brush, RectangleF rectangle) {
graphics.FillRectangle(brush, rectangle);
public override GraphicsPath CreatePath(RectangleF rect){
GraphicsPath path1 = new GraphicsPath();
path1.AddRectangle(rect);
return path1;
}
}
}

Loading…
Cancel
Save