Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 8b6c86d

Browse files
Designer can draw Sections
1 parent aa90e22 commit 8b6c86d

9 files changed

Lines changed: 89 additions & 70 deletions

File tree

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<Compile Include="src\Services\HelpService.cs" />
104104
<Compile Include="src\Services\ToolboxService.cs" />
105105
<Compile Include="src\Services\UIService.cs" />
106+
<Compile Include="src\TypeProvider\AbstractItemTypeProvider.cs" />
106107
<Compile Include="src\TypeProvider\SectionItemTypeProvider.cs" />
107108
<Compile Include="src\TypeProvider\TypeProviderHelper.cs" />
108109
<Compile Include="src\Views\DesignerView.cs" />

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/AbstractItem.cs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System;
1010
using System.ComponentModel;
1111
using System.Drawing;
12+
using ICSharpCode.Reporting.Addin.TypeProvider;
1213

1314
namespace ICSharpCode.Reporting.Addin.DesignableItems
1415
{
@@ -24,8 +25,7 @@ public abstract class AbstractItem:System.Windows.Forms.Control
2425
protected AbstractItem()
2526
{
2627
InitializeComponent();
27-
// TypeDescriptor.AddProvider(new AbstractItemTypeProvider(), typeof(AbstractItem));
28-
// VisibleInReport = true;
28+
TypeDescriptor.AddProvider(new AbstractItemTypeProvider(), typeof(AbstractItem));
2929
}
3030

3131

@@ -45,9 +45,9 @@ protected Rectangle DrawingRectangle {
4545
get {
4646

4747
return new Rectangle(this.ClientRectangle.Left ,
48-
this.ClientRectangle.Top ,
49-
this.ClientRectangle.Width -1,
50-
this.ClientRectangle.Height -1);
48+
ClientRectangle.Top ,
49+
ClientRectangle.Width -1,
50+
ClientRectangle.Height -1);
5151
}
5252
}
5353

@@ -68,22 +68,16 @@ public Color FrameColor {
6868

6969
protected new Size DefaultSize {get;set;}
7070

71-
// public bool VisibleInReport {get;set;}
7271

7372
#endregion
7473

75-
[System.ComponentModel.EditorBrowsableAttribute()]
76-
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
77-
{
78-
base.OnPaint(e);
79-
}
8074

8175
public abstract void Draw(Graphics graphics);
8276

8377
private void InitializeComponent()
8478
{
85-
this.SuspendLayout();
86-
this.ResumeLayout(false);
79+
SuspendLayout();
80+
ResumeLayout(false);
8781
}
8882
}
8983
}

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseSection.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems
1616
/// <summary>
1717
/// Description of BaseSection.
1818
/// </summary>
19-
[TypeDescriptionProvider(typeof(SectionItemTypeProvider))]
19+
[TypeDescriptionProvider(typeof(SectionItemTypeProvider))]
2020
[Designer(typeof(ICSharpCode.Reporting.Addin.Designer.SectionDesigner))]
21-
public class BaseSection:AbstractItem
21+
public class BaseSection:AbstractItem
2222
{
23-
23+
2424
public BaseSection():base()
2525
{
26-
base.FrameColor = Color.Black;
26+
FrameColor = Color.Black;
2727
TypeDescriptor.AddProvider(new SectionItemTypeProvider(), typeof(BaseSection));
2828
}
2929

3030

31-
[EditorBrowsableAttribute()]
31+
// [EditorBrowsableAttribute()]
3232
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
3333
{
34+
Console.WriteLine("BaseSection:OnPaint");
3435
base.OnPaint(e);
3536
Draw(e.Graphics);
3637
}

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/ReportRootDesigner.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,7 @@ public class ReportRootDesigner: DocumentDesigner
4747
IComponentChangeService componentChangeService;
4848
List<BaseSection> sections;
4949
ICSharpCode.Reporting.Items.ReportSettings reportSettings;
50-
RootReportModel rootReportModel;
51-
52-
public ReportRootDesigner()
53-
{
54-
Console.WriteLine("Create RootDesigner");
55-
// Control.BackColor = Color.Chocolate;
56-
}
50+
RootReportModel rootReportModel;
5751

5852

5953
void ShowMessage(Exception e)
@@ -234,7 +228,7 @@ private void OnComponentAdded(object sender, ComponentEventArgs ce)
234228
// this.host.Container.Add(cc);
235229
// }
236230
//
237-
// this.Control.Controls.Add(section);
231+
this.Control.Controls.Add(section);
238232
RecalculateSections();
239233
}
240234
}

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/RootReportModel.cs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.ComponentModel.Design;
1212
using System.Drawing;
1313
using System.Drawing.Printing;
14-
using ICSharpCode.Reporting.Items;
1514
using ICSharpCode.Reporting.Addin.Globals;
1615

1716
namespace ICSharpCode.Reporting.Addin.Designer
@@ -24,21 +23,13 @@ namespace ICSharpCode.Reporting.Addin.Designer
2423

2524
public class RootReportModel:RootDesignedComponent
2625
{
27-
2826
bool showDebugFrame;
2927

30-
public RootReportModel(){
31-
Console.WriteLine("create RootReportModel");
32-
}
33-
34-
3528
[EditorBrowsableAttribute()]
3629
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
3730
{
31+
Console.WriteLine("RootReportModel:Onpaint : {0}",this.BackColor);
3832
base.OnPaint(pea);
39-
if (this.showDebugFrame) {
40-
PrintMargin(pea.Graphics);
41-
}
4233
using (Font font = DesignerGlobals.DesignerFont) {
4334
foreach(System.Windows.Forms.Control ctrl in this.Controls)
4435
{
@@ -50,34 +41,6 @@ protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
5041
}
5142
}
5243

53-
public void Toggle ()
54-
{
55-
showDebugFrame = !this.showDebugFrame;
56-
Invalidate(true);
57-
}
58-
59-
private void PrintMargin( Graphics graphics)
60-
{
61-
string s = String.Format(System.Globalization.CultureInfo.CurrentCulture,
62-
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]",
63-
this.Page,this.Landscape,this.PageMargin);
64-
using (Font font = DesignerGlobals.DesignerFont){
65-
SizeF size = graphics.MeasureString(s,font);
66-
graphics.DrawString(s,font,
67-
new SolidBrush(Color.LightGray),
68-
new Rectangle(this.PageMargin.Left + 100,
69-
this.PageMargin.Top - (int)font.GetHeight() - 3,
70-
(int)size.Width,
71-
(int)size.Height));
72-
73-
var rectangle = new Rectangle(this.PageMargin.Left - 2,this.PageMargin.Top - 2,
74-
this.Page.Width - this.PageMargin.Left - this.PageMargin.Right + 2,
75-
this.Size.Height - this.PageMargin.Top - this.PageMargin.Bottom + 2);
76-
graphics.DrawRectangle(new Pen(Color.LightGray,1),rectangle);
77-
}
78-
}
79-
80-
8144
public Margins PageMargin {get;set;}
8245

8346
public Rectangle Page {get;set;}

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/SectionDesigner.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public override SelectionRules SelectionRules {
4848

4949
protected override void OnPaintAdornments(PaintEventArgs pe)
5050
{
51+
Console.WriteLine("SectionDesigner:OnPaintAdornments");
5152
base.OnPaintAdornments(pe);
5253
}
5354

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Peter Forstmeier
4+
* Date: 18.03.2014
5+
* Time: 20:05
6+
*
7+
* To change this template use Tools | Options | Coding | Edit Standard Headers.
8+
*/
9+
using System;
10+
using System.Collections.Generic;
11+
using System.ComponentModel;
12+
using ICSharpCode.Reporting.Addin.DesignableItems;
13+
14+
namespace ICSharpCode.Reporting.Addin.TypeProvider
15+
{
16+
/// <summary>
17+
/// Description of AbstractItemTypeProvider.
18+
/// </summary>
19+
20+
class AbstractItemTypeProvider : TypeDescriptionProvider {
21+
public AbstractItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem)))
22+
{
23+
}
24+
25+
public AbstractItemTypeProvider(TypeDescriptionProvider parent): base(parent)
26+
{
27+
}
28+
29+
30+
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
31+
{
32+
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType, instance);
33+
return new AbstractItemTypeDescriptor(td, instance);
34+
}
35+
}
36+
37+
internal class AbstractItemTypeDescriptor : CustomTypeDescriptor
38+
{
39+
// private AbstractItem _instance;
40+
41+
public AbstractItemTypeDescriptor(ICustomTypeDescriptor parent, object instance)
42+
: base(parent)
43+
{
44+
// _instance = instance as AbstractItem;
45+
}
46+
47+
48+
49+
public override PropertyDescriptorCollection GetProperties()
50+
{
51+
return GetProperties(null);
52+
}
53+
54+
55+
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
56+
{
57+
PropertyDescriptorCollection props = base.GetProperties(attributes);
58+
List<PropertyDescriptor> allProperties = new List<PropertyDescriptor>();
59+
60+
foreach (PropertyDescriptor p in props)
61+
{
62+
allProperties.Add(p);
63+
}
64+
return new PropertyDescriptorCollection(allProperties.ToArray());
65+
}
66+
}
67+
}

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/SectionItemTypeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace ICSharpCode.Reporting.Addin.TypeProvider
1616
/// <summary>
1717
/// Description of SectionItemTypeProvider.
1818
/// </summary>
19-
internal class SectionItemTypeProvider : TypeDescriptionProvider
19+
class SectionItemTypeProvider : TypeDescriptionProvider
2020
{
2121
public SectionItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem)))
2222
{

src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Views/DesignerView.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,11 +333,9 @@ public IDesignerHost Host {
333333

334334
void SetupDesignSurface()
335335
{
336-
// Control c = null;
337-
var c = designSurface.View as Control;
338-
c.BackColor = System.Drawing.Color.Green;
339-
c.Parent = panel;
340-
c.Dock = DockStyle.Fill;
336+
var ctrl = designSurface.View as Control;
337+
ctrl.Parent = panel;
338+
ctrl.Dock = DockStyle.Fill;
341339
}
342340

343341

0 commit comments

Comments
 (0)