diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseRectangleItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseRectangleItem.cs index 34cce317e6..b7be7d2627 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseRectangleItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseRectangleItem.cs @@ -9,6 +9,7 @@ using System; using System.ComponentModel; using System.Drawing; +using System.Drawing.Drawing2D; using ICSharpCode.Reporting.Addin.DesignableItems; using ICSharpCode.Reporting.Addin.Designer; using ICSharpCode.Reporting.Addin.TypeProvider; @@ -22,6 +23,8 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems [Designer(typeof(ContainerDesigner))] class BaseRectangleItem:AbstractGraphicItem { + int cornerRadius = 1; + public BaseRectangleItem() { TypeDescriptor.AddProvider(new RectangleItemTypeProvider(), typeof(BaseRectangleItem)); @@ -38,10 +41,122 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems ClientRectangle.Right -1, ClientRectangle.Bottom -1); - using (var pen = new Pen(ForeColor,Thickness)) { - graphics.DrawRectangle(pen,rect); + var path = RoundedRectangle.Create(rect,CornerRadius, + RoundedRectangle.RectangleCorners.All); + + using (var pen = new Pen(this.ForeColor,Thickness)) { + graphics.DrawPath(pen, path); + } + } + + + [Category("Appearance")] + public int CornerRadius { + get { return cornerRadius; } + set { + cornerRadius = value; + Invalidate(); + } + } + } + + static class RoundedRectangle + { + public enum RectangleCorners + { + None = 0, TopLeft = 1, TopRight = 2, BottomLeft = 4, BottomRight = 8, + All = TopLeft | TopRight | BottomLeft | BottomRight + } + + public static GraphicsPath Create(int x, int y, int width, int height, + int radius, RectangleCorners corners) + { + int xw = x + width; + int yh = y + height; + int xwr = xw - radius; + int yhr = yh - radius; + int xr = x + radius; + int yr = y + radius; + int r2 = radius * 2; + int xwr2 = xw - r2; + int yhr2 = yh - r2; + + var p = new GraphicsPath(); + p.StartFigure(); + + //Top Left Corner + if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft) + { + p.AddArc(x, y, r2, r2, 180, 90); } + else + { + p.AddLine(x, yr, x, y); + p.AddLine(x, y, xr, y); + } + + //Top Edge + p.AddLine(xr, y, xwr, y); + //Top Right Corner + if ((RectangleCorners.TopRight & corners) == RectangleCorners.TopRight) + { + p.AddArc(xwr2, y, r2, r2, 270, 90); + } + else + { + p.AddLine(xwr, y, xw, y); + p.AddLine(xw, y, xw, yr); + } + + //Right Edge + p.AddLine(xw, yr, xw, yhr); + + //Bottom Right Corner + if ((RectangleCorners.BottomRight & corners) == RectangleCorners.BottomRight) + { + p.AddArc(xwr2, yhr2, r2, r2, 0, 90); + } + else + { + p.AddLine(xw, yhr, xw, yh); + p.AddLine(xw, yh, xwr, yh); + } + + //Bottom Edge + p.AddLine(xwr, yh, xr, yh); + + //Bottom Left Corner + if ((RectangleCorners.BottomLeft & corners) == RectangleCorners.BottomLeft) + { + p.AddArc(x, yhr2, r2, r2, 90, 90); + } + else + { + p.AddLine(xr, yh, x, yh); + p.AddLine(x, yh, x, yhr); + } + + //Left Edge + p.AddLine(x, yhr, x, yr); + + p.CloseFigure(); + return p; } + + public static GraphicsPath Create(Rectangle rect, int radius, RectangleCorners c) + { return Create(rect.X, rect.Y, rect.Width, rect.Height, radius, c); } + + public static GraphicsPath Create(int x, int y, int width, int height, int radius) + { return Create(x, y, width, height, radius, RectangleCorners.All); } + + public static GraphicsPath Create(Rectangle rect, int radius) + { return Create(rect.X, rect.Y, rect.Width, rect.Height, radius); } + + public static GraphicsPath Create(int x, int y, int width, int height) + { return Create(x, y, width, height, 5); } + + public static GraphicsPath Create(Rectangle rect) + { return Create(rect.X, rect.Y, rect.Width, rect.Height); } } } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/RectangleItemTypeProvider.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/RectangleItemTypeProvider.cs index 1ea0ab9ac4..34371541f2 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/RectangleItemTypeProvider.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/RectangleItemTypeProvider.cs @@ -55,8 +55,8 @@ namespace ICSharpCode.Reporting.Addin.TypeProvider PropertyDescriptor prop = null; -// prop = props.Find("CornerRadius",true); -// allProperties.Add(prop); + prop = props.Find("CornerRadius",true); + allProperties.Add(prop); prop = props.Find("Controls",true); allProperties.Add(prop); diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs index 94fc6db961..3c3fad2322 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Items/Graphics/BaseRectangleItem.cs @@ -31,6 +31,7 @@ namespace ICSharpCode.Reporting.Items public BaseRectangleItem() { Items = new List(); + CornerRadius = 0; } @@ -43,13 +44,15 @@ namespace ICSharpCode.Reporting.Items ex.Size = Size; ex.DesiredSize = Size; ex.Thickness = Thickness; + ex.CornerRadius = CornerRadius; ex.DashStyle = DashStyle; ex.StartLineCap = StartLineCap; ex.EndLineCap = EndLineCap; return ex; } - + public int CornerRadius { get; set; } + public List Items {get;private set;} } diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs index c59099d31e..514cc93607 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/ExportColumns/ExportRectangle.cs @@ -26,6 +26,7 @@ namespace ICSharpCode.Reporting.PageBuilder.ExportColumns /// public class ExportRectangle:GraphicsContainer,IExportGraphics { + public int CornerRadius { get; set; } public DashStyle DashStyle {get;set;} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs index a323b37337..167d923a61 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Wpf/Visitor/WpfVisitor.cs @@ -138,6 +138,7 @@ namespace ICSharpCode.Reporting.WpfReportViewer.Visitor public override void Visit(ExportRectangle exportRectangle) { var border = CreateBorder(exportRectangle); + border.CornerRadius = new CornerRadius(Convert.ToDouble(exportRectangle.CornerRadius)); CanvasHelper.SetPosition(border, new Point(0,0)); var panel = new StackPanel(); panel.Orientation = Orientation.Horizontal;