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 2478f067e1..dd02ba201b 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
@@ -80,6 +80,7 @@
+
@@ -89,6 +90,8 @@
+
+
@@ -109,6 +112,7 @@
+
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
new file mode 100644
index 0000000000..c3f1ed0eb2
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseLineItem.cs
@@ -0,0 +1,159 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 23.03.2014
+ * Time: 17:54
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using ICSharpCode.Reporting.Addin.Designer;
+using ICSharpCode.Reporting.Addin.TypeProvider;
+
+namespace ICSharpCode.Reporting.Addin.DesignableItems
+{
+ [Designer(typeof(LineDesigner))]
+ public class BaseLineItem:AbstractItem
+ {
+ 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);
+ toPoint = new Point(ClientRectangle.Left + ClientRectangle.Width - 10,
+ ClientRectangle.Height/ 2);
+ Invalidate();
+ }
+
+
+
+// [System.ComponentModel.EditorBrowsableAttribute()]
+ protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
+ {
+ e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
+ base.OnPaint(e);
+ Draw(e.Graphics);
+ }
+
+
+ public override void Draw(Graphics graphics)
+ {
+ 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);
+ }
+ }
+
+
+ public Point FromPoint {
+ 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);
+ } else {
+ this.fromPoint = x;
+ }
+ this.Invalidate();
+ }
+ }
+
+
+ public Point ToPoint {
+ get { return toPoint; }
+ set {
+ Point x = value;
+ if (!ClientRectangle.Contains(x)) {
+ this.toPoint = new Point(x.X - this.Location.X,
+ x.Y - this.Location.Y);
+ }
+ else {
+ toPoint = x;
+ }
+ Invalidate();
+ }
+ }
+
+
+
+// [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")]
+ public LineCap StartLineCap {
+ get { return startLineCap; }
+ set {
+ startLineCap = value;
+ this.Invalidate();
+ }
+ }
+
+// [Browsable(true),
+// Category("Appearance"),
+// Description("Linecap at Endposition")]
+ public LineCap EndLineCap {
+ get { return endLineCap; }
+ set {
+ endLineCap = value;
+ this.Invalidate();
+ }
+ }
+
+// [Browsable(true),
+// Category("Appearance"),
+// Description("Dashlinecap")]
+ public DashCap DashLineCap {
+ get { return dashLineCap; }
+ set {
+ dashLineCap = value;
+ this.Invalidate();
+ }
+ }
+
+ }
+
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs
new file mode 100644
index 0000000000..930cd1ca51
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/AbstractDesigner.cs
@@ -0,0 +1,33 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 23.03.2014
+ * Time: 18:22
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.ComponentModel.Design;
+using System.Windows.Forms.Design;
+
+namespace ICSharpCode.Reporting.Addin.Designer
+{
+ ///
+ /// Description of AbstractDesigner.
+ ///
+ public class AbstractDesigner:ControlDesigner
+ {
+
+ public override void Initialize(System.ComponentModel.IComponent component)
+ {
+ base.Initialize(component);
+ SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
+ ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
+ }
+
+
+ protected ISelectionService SelectionService {get; private set;}
+
+ protected IComponentChangeService ComponentChangeService {get;private set;}
+ }
+}
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
new file mode 100644
index 0000000000..d931205351
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/LineDesigner.cs
@@ -0,0 +1,241 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 23.03.2014
+ * Time: 17:56
+ *
+ * To change this template use Tools | Options | Coding | Edit Standard Headers.
+ */
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Windows.Forms;
+using ICSharpCode.Reporting.Addin.DesignableItems;
+using ICSharpCode.Reporting.Addin.TypeProvider;
+
+namespace ICSharpCode.Reporting.Addin.Designer
+{
+ ///
+ /// Description of LineDesigner.
+ ///
+ public class LineDesigner:AbstractDesigner
+ {
+ BaseLineItem baseLine;
+ bool dragging;
+ bool overToPoint;
+ bool overFromPoint;
+
+
+ public override void Initialize(IComponent component)
+ {
+ if (component == null) {
+ throw new ArgumentNullException("component");
+ }
+ base.Initialize(component);
+ baseLine = (BaseLineItem)component;
+
+ ComponentChangeService.ComponentChanging += OnComponentChanging;
+ ComponentChangeService.ComponentChanged += OnComponentChanged;
+ ComponentChangeService.ComponentRename += OnComponentRename;
+ SelectionService.SelectionChanged += OnSelectionChanged;
+ }
+
+ protected override void PostFilterProperties(System.Collections.IDictionary properties)
+ {
+ TypeProviderHelper.RemoveProperties(properties);
+ base.PostFilterProperties(properties);
+ }
+
+
+ #region events
+
+ private void OnComponentChanging (object sender,ComponentChangingEventArgs e)
+ {
+// System.Console.WriteLine("changing");
+// System.Console.WriteLine("{0}",this.baseLine.ClientRectangle);
+ Control.Invalidate( );
+ }
+
+
+ void OnComponentChanged(object sender,ComponentChangedEventArgs e)
+ {
+ Console.WriteLine("changed");
+ Console.WriteLine("{0}",this.baseLine.ClientRectangle);
+ Control.Invalidate( );
+ }
+
+
+ void OnComponentRename(object sender,ComponentRenameEventArgs e) {
+ if (e.Component == this.Component) {
+ Control.Name = e.NewName;
+ Control.Invalidate();
+ Control.Invalidate( );
+ }
+ }
+
+
+ void OnSelectionChanged(object sender, EventArgs e)
+ {
+ Control.Invalidate( );
+ }
+
+
+ #endregion
+
+
+ protected override void OnPaintAdornments(PaintEventArgs pe)
+ {
+ var label = Control as BaseLineItem;
+
+ if (SelectionService != null)
+ {
+ if (SelectionService.GetComponentSelected(label))
+ {
+ // Paint grab handles.
+ var grapRectangle = GetHandle(label.FromPoint);
+ ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true);
+ grapRectangle = GetHandle(label.ToPoint);
+ ControlPaint.DrawGrabHandle(pe.Graphics, grapRectangle, true, true);
+
+ }
+ }
+ }
+
+
+ static Rectangle GetHandle(Point pt)
+ {
+ var handle = new Rectangle(pt, new Size(7, 7));
+ handle.Offset(-3, -3);
+ return handle;
+ }
+
+
+ protected override void OnSetCursor( )
+ {
+ // Get mouse cursor position relative to
+ // the control's coordinate space.
+
+ var label = (BaseLineItem) Control;
+ var p = label.PointToClient(Cursor.Position);
+
+ // Display a resize cursor if the mouse is
+ // over a grab handle; otherwise show a
+ // normal arrow.
+ if (GetHandle(label.FromPoint).Contains(p) ||
+ GetHandle(label.ToPoint).Contains(p))
+ {
+ Cursor.Current = Cursors.SizeAll;
+ }
+ else
+ {
+ Cursor.Current = Cursors.Default;
+ }
+ }
+
+
+ #region Drag handling state and methods
+
+ protected override void OnMouseDragBegin(int x, int y)
+ {
+ System.Console.WriteLine("DragBegib");
+ Point p = this.baseLine.PointToClient(new Point(x, y));
+ overFromPoint = GetHandle(this.baseLine.FromPoint).Contains(p);
+ this.overToPoint = GetHandle(this.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
+ {
+ dragging = false;
+ base.OnMouseDragBegin(x, y);
+ }
+ }
+
+
+ protected override void OnMouseDragMove(int x, int y)
+ {
+ if (dragging)
+ {
+ Point p = this.baseLine.PointToClient(new Point(x, y));
+ if (this.overToPoint) {
+ this.baseLine.ToPoint = p;
+ } else {
+ this.baseLine.FromPoint = p;
+ }
+
+// this.baseLine.Invalidate();
+// this.dragOffset = p;
+ }
+ else
+ {
+ base.OnMouseDragMove(x, y);
+ }
+ }
+
+
+ protected override void OnMouseDragEnd(bool cancel)
+ {
+ if (dragging)
+ {
+ // Update property via PropertyDescriptor to
+ // make sure that VS.NET notices.
+
+// PropertyDescriptor pd =
+// TypeDescriptor.GetProperties(this.baseLine)["ToPoint"];
+// pd.SetValue(this.baseLine, this.dragOffset);
+ /*
+ DirectionalLabel label = (DirectionalLabel) Control;
+ if (dragDirection)
+ {
+ Size d = label.Direction;
+ PropertyDescriptor pd =
+ TypeDescriptor.GetProperties(label)["Direction"];
+ pd.SetValue(label, d);
+ }
+ else
+ {
+ Point o = label.Origin;
+ PropertyDescriptor pd =
+ TypeDescriptor.GetProperties(label)["Origin"];
+ pd.SetValue(label, o);
+ }
+ */
+ dragging = false;
+ this.baseLine.Invalidate();
+ }
+
+ // Always call base class.
+ base.OnMouseDragEnd(cancel);
+
+ }
+ //
+
+ #endregion
+
+
+ protected override void Dispose(bool disposing)
+ {
+
+ if (ComponentChangeService != null) {
+ ComponentChangeService.ComponentChanging -= OnComponentChanging;
+ ComponentChangeService.ComponentChanged -= OnComponentChanged;
+ ComponentChangeService.ComponentRename -= OnComponentRename;
+ }
+ if (SelectionService != null) {
+ SelectionService.SelectionChanged -= OnSelectionChanged;
+ }
+
+ base.Dispose(disposing);
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs
index 9402e52dea..0acfe72cf0 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs
@@ -9,8 +9,7 @@
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
-using System.Windows.Forms.Design;
-using ICSharpCode.Reporting.Items;
+using ICSharpCode.Reporting.Addin.DesignableItems;
using ICSharpCode.Reporting.Addin.TypeProvider;
@@ -19,18 +18,17 @@ namespace ICSharpCode.Reporting.Addin.Designer
///
/// Description of TextItemDesigner.
///
- public class TextItemDesigner:ControlDesigner
+ public class TextItemDesigner:AbstractDesigner
{
- ISelectionService selectionService;
- IComponentChangeService componentChangeService;
- ICSharpCode.Reporting.Addin.DesignableItems.BaseTextItem ctrl;
+ BaseTextItem ctrl;
public override void Initialize(IComponent component)
{
base.Initialize(component);
- GetService();
- ctrl = (ICSharpCode.Reporting.Addin.DesignableItems.BaseTextItem) component;
+ SelectionService.SelectionChanged += OnSelectionChanged;
+ ComponentChangeService.ComponentRename += OnComponentRename;
+ ctrl = (BaseTextItem) component;
}
protected override void PostFilterProperties(System.Collections.IDictionary properties)
@@ -40,23 +38,6 @@ namespace ICSharpCode.Reporting.Addin.Designer
}
- void GetService ()
- {
- selectionService = GetService(typeof(ISelectionService)) as ISelectionService;
- if (selectionService != null)
- {
- selectionService.SelectionChanged += OnSelectionChanged;
-
- }
-
- componentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
- if (componentChangeService != null) {
- componentChangeService.ComponentRename += OnComponentRename;
- }
-
- }
-
-
void OnSelectionChanged(object sender, EventArgs e)
{
Control.Invalidate( );
@@ -121,12 +102,12 @@ namespace ICSharpCode.Reporting.Addin.Designer
protected override void Dispose(bool disposing)
{
- if (selectionService != null) {
- selectionService.SelectionChanged -= OnSelectionChanged;
+ if (SelectionService != null) {
+ SelectionService.SelectionChanged -= OnSelectionChanged;
}
- if (componentChangeService != null) {
- componentChangeService.ComponentRename -= OnComponentRename;
+ if (ComponentChangeService != null) {
+ ComponentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing);
}
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 a54c247a20..6ba7dc0012 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
@@ -13,6 +13,7 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Widgets.SideBar;
+using ICSharpCode.Reporting.Addin.DesignableItems;
namespace ICSharpCode.Reporting.Addin.Toolbox
{
@@ -54,10 +55,19 @@ namespace ICSharpCode.Reporting.Addin.Toolbox
sideTab.Items.Add(CreateToolboxPointer(sideTab));
// TextItem
- var toolboxItem = new ToolboxItem(typeof(ICSharpCode.Reporting.Addin.DesignableItems.BaseTextItem)) {
+ var toolboxItem = new ToolboxItem(typeof(BaseTextItem)) {
DisplayName = ResourceService.GetString("SharpReport.Toolbar.TextBox"),
Bitmap = IconService.GetBitmap("Icons.16.16.SharpReport.Textbox")
};
+ sideTab.Items.Add(new SideTabItemDesigner(toolboxItem));
+
+ //Grahics
+ // Line
+ toolboxItem = new ToolboxItem(typeof(BaseLineItem)) {
+ DisplayName = ResourceService.GetString("SharpReport.Toolbar.Line"),
+ Bitmap = IconService.GetBitmap("Icons.16.16.SharpReport.Line")
+ };
+
sideTab.Items.Add(new SideTabItemDesigner(toolboxItem));
/*
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/LineItemTypeProvider.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/LineItemTypeProvider.cs
new file mode 100644
index 0000000000..c08ef163cb
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/LineItemTypeProvider.cs
@@ -0,0 +1,86 @@
+/*
+ * Created by SharpDevelop.
+ * User: Peter Forstmeier
+ * Date: 23.03.2014
+ * Time: 18:02
+ *
+ * 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 LineItemTypeProvider.
+ ///
+ class LineItemTypeProvider : TypeDescriptionProvider
+ {
+ public LineItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem)))
+ {
+ }
+
+ public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+ {
+ ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance);
+ return new LineItemTypeDescriptor(td, instance);
+ }
+ }
+
+
+
+ class LineItemTypeDescriptor : CustomTypeDescriptor
+ {
+
+
+ public LineItemTypeDescriptor(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);
+
+ PropertyDescriptor prop = null;
+ prop = props.Find("ForeColor",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("FromPoint",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("ToPoint",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("StartLineCap",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("EndLineCap",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("dashLineCap",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("DashStyle",true);
+ allProperties.Add(prop);
+
+ prop = props.Find("Thickness",true);
+ allProperties.Add(prop);
+
+ return new PropertyDescriptorCollection(allProperties.ToArray());
+ }
+ }
+}