Browse Source

Circle and Rectangle in FixedPage

pull/15/head^2
peterforstmeier 14 years ago
parent
commit
65549f524e
  1. 1
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/ExtensionMethodes.cs
  2. 167
      src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs

1
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/ExtensionMethodes.cs

@ -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;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;

167
src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/WPF/FixedDocumentCreator.cs

@ -60,6 +60,11 @@ namespace ICSharpCode.Reports.Core.WPF
UIElement element = null; UIElement element = null;
System.Windows.Controls.Border border = null; System.Windows.Controls.Border border = null;
var graphicContainer = column as ExportGraphicContainer;
if ( graphicContainer != null) {
element = CreateGraphicsContainer(graphicContainer);
return element;
}
var container = column as ExportContainer; var container = column as ExportContainer;
if (container != null) { if (container != null) {
@ -73,19 +78,15 @@ namespace ICSharpCode.Reports.Core.WPF
var text = column as ExportText; var text = column as ExportText;
if (text != null) { if (text != null) {
if (column.StyleDecorator.DrawBorder) {
border = new System.Windows.Controls.Border();
border.Padding = new Thickness(1);
border.BorderThickness = new Thickness(2);
border.CornerRadius = new CornerRadius(2);
border.BorderBrush = brushConverter.ConvertFromString(column.StyleDecorator.ForeColor.Name) as SolidColorBrush;
var t = CreateTextBlock(text); var t = CreateTextBlock(text);
if (column.StyleDecorator.DrawBorder) {
border = CreateBorder(column.StyleDecorator as BaseStyleDecorator);
border.Child = t; border.Child = t;
element = border; element = border;
} else { }
else
element = CreateTextBlock (text); {
element = t;
} }
} }
@ -97,10 +98,23 @@ namespace ICSharpCode.Reports.Core.WPF
element = CreateImageColumn(image); element = CreateImageColumn(image);
} }
return element; return element;
} }
#region GraphicsElement (Line etc)
System.Windows.Controls.Border CreateBorder( BaseStyleDecorator column)
{
var border = new System.Windows.Controls.Border();
border.Padding = new Thickness(1);
border.BorderThickness = new Thickness(2);
border.CornerRadius = new CornerRadius(2);
border.BorderBrush = brushConverter.ConvertFromString(column.ForeColor.Name) as SolidColorBrush;
return border;
}
UIElement CreateGraphicsElement(ExportGraphic column) UIElement CreateGraphicsElement(ExportGraphic column)
{ {
var line = new System.Windows.Shapes.Line(); var line = new System.Windows.Shapes.Line();
@ -123,21 +137,53 @@ namespace ICSharpCode.Reports.Core.WPF
return line; return line;
} }
#endregion
private UIElement CreateContainer(ExportContainer container) #region Container
UIElement CreateGraphicsContainer(ExportGraphicContainer graphicContainer)
{ {
Console.WriteLine("GraphicContainer");
IGraphicStyleDecorator decorator = graphicContainer.StyleDecorator as IGraphicStyleDecorator;
UIElement shape = null;
var ss = decorator.Shape as EllipseShape;
if (ss != null) {
var circle = new System.Windows.Shapes.Ellipse();
SetDimension(circle,decorator);
circle.Fill = brushConverter.ConvertFromString(decorator.BackColor.Name) as SolidColorBrush;
circle.StrokeThickness = decorator.Thickness;
circle.Stroke = brushConverter.ConvertFromString(decorator.ForeColor.Name) as SolidColorBrush;
shape = circle;
var canvas = new Canvas();
canvas.Width = container.StyleDecorator.DisplayRectangle.Width;
canvas.Height = container.StyleDecorator.DisplayRectangle.Height;
var rect = container as ExportGraphicContainer;
if (rect != null) {
Console.WriteLine("GraphicContainer");
var bs = rect.StyleDecorator as IGraphicStyleDecorator;
DrawShape (canvas,bs);
} }
else
{
var border = CreateBorder(decorator as BaseStyleDecorator);
SetDimension(border,decorator);
RectangleShape rs = decorator.Shape as RectangleShape;
border.CornerRadius = new CornerRadius(rs.CornerRadius);
border.BorderThickness = new Thickness(decorator.Thickness);
border.BorderBrush = brushConverter.ConvertFromString(decorator.ForeColor.Name) as SolidColorBrush;
shape = border;
}
return shape;
}
private UIElement CreateContainer(ExportContainer container)
{
Console.WriteLine("CreateContainer");
var canvas = new Canvas();
SetDimension(canvas,container.StyleDecorator);
SolidColorBrush backgroundBrush = brushConverter.ConvertFromString(container.StyleDecorator.BackColor.Name) as SolidColorBrush; SolidColorBrush backgroundBrush = brushConverter.ConvertFromString(container.StyleDecorator.BackColor.Name) as SolidColorBrush;
canvas.Background = backgroundBrush; canvas.Background = backgroundBrush;
@ -155,11 +201,25 @@ namespace ICSharpCode.Reports.Core.WPF
return canvas; return canvas;
} }
void DrawShape(Canvas canvas, IGraphicStyleDecorator bs) #endregion
/*
void CreateShape(Canvas canvas, IGraphicStyleDecorator bs)
{ {
var shape = bs.Shape; var shape = bs.Shape;
UIElement element = null;
if (shape is RectangleShape) {
element = new System.Windows.Controls.Border();
}
if (element != null) {
canvas.Children.Add(element);
Canvas.SetLeft(element,bs.Location.X);
Canvas.SetTop(element,bs.Location.Y);
}
} }
*/
UIElement CreateTextColumn(ExportText et) UIElement CreateTextColumn(ExportText et)
@ -169,13 +229,14 @@ namespace ICSharpCode.Reports.Core.WPF
} }
#region Image
UIElement CreateImageColumn(ExportImage exportImage) UIElement CreateImageColumn(ExportImage exportImage)
{ {
System.Windows.Media.Imaging.BitmapImage bitmap = BitmapFromImage(exportImage); System.Windows.Media.Imaging.BitmapImage bitmap = BitmapFromImage(exportImage);
Image image = new Image(); Image image = new Image();
image.Source = bitmap; image.Source = bitmap;
image.Width = exportImage.StyleDecorator.DisplayRectangle.Width; SetDimension(image,exportImage.StyleDecorator);
image.Height = exportImage.StyleDecorator.DisplayRectangle.Height;
image.Stretch = System.Windows.Media.Stretch.Fill; image.Stretch = System.Windows.Media.Stretch.Fill;
return image; return image;
} }
@ -193,47 +254,44 @@ namespace ICSharpCode.Reports.Core.WPF
return bitmap; return bitmap;
} }
TextBlock CreateTextBlock(ExportText et) #endregion
#region TextBlock
TextBlock CreateTextBlock(ExportText exportText)
{ {
TextBlock tb = new TextBlock(); TextBlock textBlock = new TextBlock();
tb.Text = et.Text; textBlock.Text = exportText.Text;
SetFont(tb, et.StyleDecorator); SetFont(textBlock, exportText.StyleDecorator);
tb.Width = et.StyleDecorator.DisplayRectangle.Width; SetDimension(textBlock,exportText.StyleDecorator);
tb.Height = et.StyleDecorator.DisplayRectangle.Height; return textBlock;
// SetDimension(tb,et.StyleDecorator);
tb.MaxHeight = et.StyleDecorator.DisplayRectangle.Height;
tb.MaxWidth = et.StyleDecorator.DisplayRectangle.Width;
return tb;
} }
// void SetDimension (System.Windows.Controls.Control element,BaseStyleDecorator decorator)
// {
// element.Width = decorator.DisplayRectangle.Width;
// }
void SetFont(TextBlock tb, TextStyleDecorator styleDecorator)
void SetFont(TextBlock textBlock, TextStyleDecorator styleDecorator)
{ {
tb.FontFamily = new FontFamily(styleDecorator.Font.FontFamily.Name); textBlock.FontFamily = new FontFamily(styleDecorator.Font.FontFamily.Name);
var b = styleDecorator.Font.Size; var b = styleDecorator.Font.Size;
tb.FontSize = b * 96/72; textBlock.FontSize = b * 96/72;
tb.Foreground = brushConverter.ConvertFromString(styleDecorator.ForeColor.Name) as SolidColorBrush; textBlock.Foreground = brushConverter.ConvertFromString(styleDecorator.ForeColor.Name) as SolidColorBrush;
if (styleDecorator.Font.Bold) { if (styleDecorator.Font.Bold) {
tb.FontWeight = FontWeights.Bold; textBlock.FontWeight = FontWeights.Bold;
} }
if (styleDecorator.Font.Underline) { if (styleDecorator.Font.Underline) {
CreateUnderline(tb,styleDecorator); CreateUnderline(textBlock,styleDecorator);
} }
if (styleDecorator.Font.Italic) { if (styleDecorator.Font.Italic) {
tb.FontStyle = System.Windows.FontStyles.Italic ; textBlock.FontStyle = System.Windows.FontStyles.Italic ;
} }
if (styleDecorator.Font.Strikeout) { if (styleDecorator.Font.Strikeout) {
CreateStrikeout(tb,styleDecorator); CreateStrikeout(textBlock,styleDecorator);
} }
} }
void CreateStrikeout (TextBlock tb, TextStyleDecorator styleDecorator) void CreateStrikeout (TextBlock textBlock, TextStyleDecorator styleDecorator)
{ {
TextDecoration strikeOut = new TextDecoration(); TextDecoration strikeOut = new TextDecoration();
strikeOut.Location = TextDecorationLocation.Strikethrough; strikeOut.Location = TextDecorationLocation.Strikethrough;
@ -241,18 +299,20 @@ namespace ICSharpCode.Reports.Core.WPF
Pen p = CreateWpfPen(styleDecorator); Pen p = CreateWpfPen(styleDecorator);
strikeOut.Pen = p ; strikeOut.Pen = p ;
strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended; strikeOut.PenThicknessUnit = TextDecorationUnit.FontRecommended;
tb.TextDecorations.Add(strikeOut); textBlock.TextDecorations.Add(strikeOut);
} }
void CreateUnderline(TextBlock tb,TextStyleDecorator styleDecorator)
void CreateUnderline(TextBlock textBlock,TextStyleDecorator styleDecorator)
{ {
TextDecoration underLine = new TextDecoration(); TextDecoration underLine = new TextDecoration();
Pen p = CreateWpfPen(styleDecorator); Pen p = CreateWpfPen(styleDecorator);
underLine.Pen = p ; underLine.Pen = p ;
underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended; underLine.PenThicknessUnit = TextDecorationUnit.FontRecommended;
tb.TextDecorations.Add(underLine); textBlock.TextDecorations.Add(underLine);
} }
#endregion
Pen CreateWpfPen(TextStyleDecorator styleDecorator) Pen CreateWpfPen(TextStyleDecorator styleDecorator)
{ {
@ -264,6 +324,15 @@ namespace ICSharpCode.Reports.Core.WPF
} }
void SetDimension (FrameworkElement element,IBaseStyleDecorator decorator)
{
element.Width = decorator.DisplayRectangle.Width;
element.Height = decorator.DisplayRectangle.Height;
// element.MaxHeight = decorator.DisplayRectangle.Height;
// element.MaxWidth = decorator.DisplayRectangle.Width;
}
public void ArrangePage(Size pageSize, FixedPage page) public void ArrangePage(Size pageSize, FixedPage page)
{ {
page.Measure(pageSize); page.Measure(pageSize);

Loading…
Cancel
Save