diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj index 4543a81365..0a3280f228 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj @@ -76,6 +76,7 @@ + @@ -93,8 +94,10 @@ + + @@ -108,6 +111,7 @@ + @@ -133,6 +137,7 @@ + diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/AbstractGraphicItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/AbstractGraphicItem.cs new file mode 100644 index 0000000000..cf7d3ce71f --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/AbstractGraphicItem.cs @@ -0,0 +1,62 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 05.04.2014 + * Time: 17:26 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.ComponentModel; +using System.Drawing.Drawing2D; + +namespace ICSharpCode.Reporting.Addin.DesignableItems +{ + /// + /// Description of AbstractGraphicItem. + /// + public class AbstractGraphicItem:AbstractItem + { + + float thickness; + DashStyle dashStyle; + + + public AbstractGraphicItem() + { + Thickness = 1; + DashStyle = DashStyle.Solid; + } + + protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) + { + e.Graphics.SmoothingMode = SmoothingMode.HighQuality; + base.OnPaint(e); + Draw(e.Graphics); + } + + public override void Draw(System.Drawing.Graphics graphics) + { + + } + + [Category("Appearance")] + public DashStyle DashStyle { + get { return dashStyle; } + set { + dashStyle = value; + Invalidate(); + } + } + + + [Category("Appearance")] + public float Thickness { + get { return thickness; } + set { + thickness = value; + Invalidate(); + } + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseLineItem.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseLineItem.cs index c3f1ed0eb2..46778def47 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseLineItem.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseLineItem.cs @@ -16,25 +16,23 @@ using ICSharpCode.Reporting.Addin.TypeProvider; namespace ICSharpCode.Reporting.Addin.DesignableItems { [Designer(typeof(LineDesigner))] - public class BaseLineItem:AbstractItem + public class BaseLineItem:AbstractGraphicItem { Point fromPoint; Point toPoint; LineCap startLineCap; LineCap endLineCap; DashCap dashLineCap; - DashStyle dashStyle; - float thickness; + public BaseLineItem() { - this.thickness = 1; - this.dashStyle = DashStyle.Solid; this.Size = new Size(50,10); TypeDescriptor.AddProvider(new LineItemTypeProvider(), typeof(BaseLineItem)); this.SetStartEndPoint(); } + void SetStartEndPoint () { fromPoint = new Point(ClientRectangle.Left + 10,ClientRectangle.Height / 2); @@ -59,9 +57,9 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems if (graphics == null) { throw new ArgumentNullException("graphics"); } - using (Pen p = new Pen(this.ForeColor,this.Thickness)) { - p.SetLineCap(this.StartLineCap,this.EndLineCap,this.DashLineCap); - graphics.DrawLine(p,this.fromPoint,this.toPoint); + using (var p = new Pen(ForeColor,Thickness)) { + p.SetLineCap(StartLineCap,EndLineCap,DashLineCap); + graphics.DrawLine(p,fromPoint,toPoint); } } @@ -70,13 +68,13 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems get { return fromPoint; } set { Point x = value; - if (!this.ClientRectangle.Contains(x)) { - this.fromPoint = new Point(x.X - this.Location.X, - x.Y - this.Location.Y); + if (!ClientRectangle.Contains(x)) { + fromPoint = new Point(x.X - Location.X,x.Y - Location.Y); + } else { - this.fromPoint = x; + fromPoint = x; } - this.Invalidate(); + Invalidate(); } } @@ -86,8 +84,8 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems set { Point x = value; if (!ClientRectangle.Contains(x)) { - this.toPoint = new Point(x.X - this.Location.X, - x.Y - this.Location.Y); + toPoint = new Point(x.X - Location.X,x.Y - Location.Y); + } else { toPoint = x; @@ -97,63 +95,34 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems } - -// [Browsable(true), -// Category("Appearance"), -// Description("LineStyle")] - public DashStyle DashStyle { - get { return dashStyle; } - set { - dashStyle = value; - this.Invalidate(); - } - } - - -// [Browsable(true), -// Category("Appearance"), -// Description("Thickness of Line")] - public float Thickness { - get { return thickness; } - set { - thickness = value; - this.Invalidate(); - } - } - -// [Browsable(true), -// Category("Appearance"), -// Description("LineCap at Startposition")] + [ Category("Appearance")] public LineCap StartLineCap { get { return startLineCap; } set { startLineCap = value; - this.Invalidate(); + Invalidate(); } } -// [Browsable(true), -// Category("Appearance"), -// Description("Linecap at Endposition")] + + [ Category("Appearance")] public LineCap EndLineCap { get { return endLineCap; } set { endLineCap = value; - this.Invalidate(); + Invalidate(); } } -// [Browsable(true), -// Category("Appearance"), -// Description("Dashlinecap")] + + [Category("Appearance")] public DashCap DashLineCap { get { return dashLineCap; } set { dashLineCap = value; - this.Invalidate(); + Invalidate(); } } - - } + } } 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 new file mode 100644 index 0000000000..2c3e4fd67d --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseRectangleItem.cs @@ -0,0 +1,66 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 05.04.2014 + * Time: 17:23 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.ComponentModel; +using System.Drawing; +using ICSharpCode.Reporting.Addin.DesignableItems; +using ICSharpCode.Reporting.Addin.Designer; +using ICSharpCode.Reporting.Addin.TypeProvider; + +namespace ICSharpCode.Reporting.Addin.DesignableItems +{ + /// + /// Description of BaseRectangleItem. + /// + /// + [Designer(typeof(ContainerDesigner))] + class BaseRectangleItem:AbstractGraphicItem + { + public BaseRectangleItem() + { + TypeDescriptor.AddProvider(new RectangleItemTypeProvider(), typeof(BaseRectangleItem)); + } + + public override void Draw(Graphics graphics) + { + if (graphics == null) { + throw new ArgumentNullException("graphics"); + } + + var rect = new Rectangle(ClientRectangle.Left, + ClientRectangle.Top, + ClientRectangle.Right -1, + ClientRectangle.Bottom -1); + + using (var pen = new Pen(ForeColor,Thickness)) { + graphics.DrawRectangle(pen,rect); + } + + +// backgroundShape.FillShape(graphics, +// new SolidFillPattern(this.BackColor), +// rect); + +// Border b = new Border(new BaseLine (this.ForeColor,System.Drawing.Drawing2D.DashStyle.Solid,1)); +// DrawFrame(graphics,b); +// BaseLine line = new BaseLine(base.ForeColor,DashStyle,Thickness,LineCap.Round,LineCap.Round,DashCap.Round); +// using (Pen pen = line.CreatePen(line.Thickness)){ +// shape.CornerRadius = this.CornerRadius; +// GraphicsPath path1 = shape.CreatePath(rect); +// graphics.DrawPath(pen, path1); +// +// } + +// shape.DrawShape (graphics, +// this.Baseline(), +// rect); + + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/ContainerDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/ContainerDesigner.cs new file mode 100644 index 0000000000..6fdcc3a04c --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/ContainerDesigner.cs @@ -0,0 +1,99 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 05.04.2014 + * Time: 18:06 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.ComponentModel; +using System.ComponentModel.Design; +using System.Drawing.Design; +using System.Windows.Forms; +using System.Windows.Forms.Design; +using ICSharpCode.Reporting.Addin.TypeProvider; + +namespace ICSharpCode.Reporting.Addin.Designer +{ + /// + /// Description of RectangleDesigner. + /// + public class ContainerDesigner:ParentControlDesigner + { + ISelectionService selectionService; + IComponentChangeService componentChangeService; + + + public override void Initialize(IComponent component) + { + if (component == null) { + throw new ArgumentNullException("component"); + } + base.Initialize(component); + GetService (); + } + + + protected override void PostFilterProperties(System.Collections.IDictionary properties) + { + TypeProviderHelper.RemoveProperties(properties); + base.PostFilterProperties(properties); + } + + + + protected override void OnDragDrop(DragEventArgs de) + { + base.OnDragDrop(de); + var toolboxService = (IToolboxService)this.GetService(typeof(IToolboxService)); + toolboxService.SetSelectedToolboxItem(null); + } + + + void OnSelectionChanged(object sender, EventArgs e) + { + Control.Invalidate( ); + } + + + void OnComponentRename(object sender,ComponentRenameEventArgs e) { + if (e.Component == this.Component) { + Control.Name = e.NewName; + Control.Invalidate(); + } + } + + + void GetService () + { + selectionService = GetService(typeof(ISelectionService)) as ISelectionService; + if (selectionService != null) + { + selectionService.SelectionChanged += OnSelectionChanged; + } + + componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService)); + if (componentChangeService != null) + { + componentChangeService.ComponentRename += new ComponentRenameEventHandler(OnComponentRename); + } + } + + + #region Dispose + protected override void Dispose(bool disposing) + { + if (selectionService != null) { + selectionService.SelectionChanged -= OnSelectionChanged; + } + + + if (componentChangeService != null) { + componentChangeService.ComponentRename -= OnComponentRename; + } + base.Dispose(disposing); + } + #endregion + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs index e044df968b..f2ceb709ac 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs @@ -97,21 +97,12 @@ namespace ICSharpCode.Reporting.Addin.Designer protected override void OnMouseDragBegin(int x, int y) { - System.Console.WriteLine("DragBegib"); Point p = this.baseLine.PointToClient(new Point(x, y)); overFromPoint = GetHandle(baseLine.FromPoint).Contains(p); - this.overToPoint = GetHandle(baseLine.ToPoint).Contains(p); + overToPoint = GetHandle(baseLine.ToPoint).Contains(p); if (overFromPoint || overToPoint ) { dragging = true; -// PropertyDescriptor pd = -// TypeDescriptor.GetProperties(this.baseLine)["FromPoint"]; -// pd.SetValue(this.baseLine, p); -// dragDirection = overToPoint; - // Point current = dragDirection ? - // (label.Origin + label.Direction) : - // label.Origin; - // dragOffset = current - new Size(p); } else { @@ -125,7 +116,7 @@ namespace ICSharpCode.Reporting.Addin.Designer { if (dragging) { - Point p = this.baseLine.PointToClient(new Point(x, y)); + Point p = baseLine.PointToClient(new Point(x, y)); if (overToPoint) { baseLine.ToPoint = p; } else { @@ -177,7 +168,6 @@ namespace ICSharpCode.Reporting.Addin.Designer base.OnMouseDragEnd(cancel); } - // #endregion diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Toolbox/ToolboxProvider.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Toolbox/ToolboxProvider.cs index 43718159df..f116a8f284 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Toolbox/ToolboxProvider.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Toolbox/ToolboxProvider.cs @@ -62,7 +62,7 @@ namespace ICSharpCode.Reporting.Addin.Toolbox }; sideTab.Items.Add(new SideTabItemDesigner(toolboxItem)); - + //DataItem toolboxItem = new ToolboxItem(typeof(BaseDataItem)) { DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataField"), // tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Column"); @@ -80,6 +80,13 @@ namespace ICSharpCode.Reporting.Addin.Toolbox sideTab.Items.Add(new SideTabItemDesigner(toolboxItem)); + + // Rectangle + toolboxItem = new ToolboxItem(typeof(BaseRectangleItem)) { + DisplayName = ResourceService.GetString("SharpReport.Toolbar.Rectangle"), + Bitmap = RectangleBitmap() + }; + sideTab.Items.Add(new SideTabItemDesigner(toolboxItem)); /* //GroupHeader tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.GroupHeader)); @@ -107,27 +114,9 @@ namespace ICSharpCode.Reporting.Addin.Toolbox tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Table"); sideTab.Items.Add(new SideTabItemDesigner(tb)); - - //BaseDataItem - tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseDataItem)); - tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataField"); -// tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Column"); - tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Column"); - sideTab.Items.Add(new SideTabItemDesigner(tb)); - + //Grahics - // Line - tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseLineItem)); - tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Line"); - tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16.16.SharpReport.Line").ToBitmap(); - sideTab.Items.Add(new SideTabItemDesigner(tb)); - - // Rectangle - tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseRectangleItem)); - tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Rectangle"); - tb.Bitmap = GlobalValues.RectangleBitmap(); - sideTab.Items.Add(new SideTabItemDesigner(tb)); - + // Circle tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseCircleItem)); tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Circle"); @@ -144,7 +133,15 @@ namespace ICSharpCode.Reporting.Addin.Toolbox return sideTab; } - + static Bitmap RectangleBitmap() + { + Bitmap b = new Bitmap (16,16); + using (Graphics g = Graphics.FromImage (b)){ + g.DrawRectangle (new Pen(Color.Black, 1), + 1,1,14,14); + } + return b; + } static SideTabItem CreateToolboxPointer(SideTab sideTab) { var pointer = new SharpDevelopSideTabItem("Pointer") { 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 new file mode 100644 index 0000000000..1ea0ab9ac4 --- /dev/null +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/RectangleItemTypeProvider.cs @@ -0,0 +1,67 @@ +/* + * Created by SharpDevelop. + * User: Peter Forstmeier + * Date: 05.04.2014 + * Time: 17:57 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using ICSharpCode.Reporting.Addin.DesignableItems; + +namespace ICSharpCode.Reporting.Addin.TypeProvider +{ + /// + /// Description of RectangleItemTypeProvider. + /// + class RectangleItemTypeProvider: TypeDescriptionProvider + { + public RectangleItemTypeProvider(): base(TypeDescriptor.GetProvider(typeof(AbstractItem))) + { + } + + public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance) + { + ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance); + return new RectangleItemTypeDescriptor(td, instance); + } + } + + + class RectangleItemTypeDescriptor : CustomTypeDescriptor + { + + public RectangleItemTypeDescriptor(ICustomTypeDescriptor parent, object instance) + : base(parent) + { + } + + + public override PropertyDescriptorCollection GetProperties() + { + return GetProperties(null); + } + + + public override PropertyDescriptorCollection GetProperties(Attribute[] attributes) + { + PropertyDescriptorCollection props = base.GetProperties(attributes); + List allProperties = new List(); + + TypeProviderHelper.AddDefaultProperties(allProperties,props); + TypeProviderHelper.AddGraphicProperties(allProperties,props); + + PropertyDescriptor prop = null; + +// prop = props.Find("CornerRadius",true); +// allProperties.Add(prop); + + prop = props.Find("Controls",true); + allProperties.Add(prop); + + return new PropertyDescriptorCollection(allProperties.ToArray()); + } + } +} diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TypeProviderHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TypeProviderHelper.cs index fbb06c83c0..5003275ea9 100644 --- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TypeProviderHelper.cs +++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TypeProviderHelper.cs @@ -78,10 +78,7 @@ namespace ICSharpCode.Reporting.Addin.TypeProvider prop = props.Find("BackColor",true); allProperties.Add(prop); -// prop = props.Find ("VisibleInReport",true); -// allProperties.Add(prop); - - + // need this for Contextmenu's prop = props.Find("ContextMenu",true); allProperties.Add(prop);