9 changed files with 343 additions and 91 deletions
@ -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 |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of AbstractGraphicItem.
|
||||||
|
/// </summary>
|
||||||
|
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(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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 |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of BaseRectangleItem.
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[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);
|
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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 |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of RectangleDesigner.
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
|
} |
||||||
|
} |
@ -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 |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of RectangleItemTypeProvider.
|
||||||
|
/// </summary>
|
||||||
|
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<PropertyDescriptor> allProperties = new List<PropertyDescriptor>(); |
||||||
|
|
||||||
|
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()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue