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

Commit 2b141af

Browse files
BaseClass for designers
1 parent 70da82b commit 2b141af

7 files changed

Lines changed: 544 additions & 30 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<Compile Include="Configuration\AssemblyInfo.cs" />
8181
<Compile Include="src\Commands\ViewCommands.cs" />
8282
<Compile Include="src\DesignableItems\AbstractItem.cs" />
83+
<Compile Include="src\DesignableItems\BaseLineItem.cs" />
8384
<Compile Include="src\DesignableItems\BaseSection.cs" />
8485
<Compile Include="src\DesignableItems\BaseTextItem.cs" />
8586
<Compile Include="src\DesignableItems\ReportSettings.cs" />
@@ -89,6 +90,8 @@
8990
<Compile Include="src\DesignerBinding\InternalReportLoader.cs" />
9091
<Compile Include="src\DesignerBinding\ReportDefinitionDeserializer.cs" />
9192
<Compile Include="src\DesignerBinding\ReportDesignerLoader.cs" />
93+
<Compile Include="src\Designer\AbstractDesigner.cs" />
94+
<Compile Include="src\Designer\LineDesigner.cs" />
9295
<Compile Include="src\Designer\ReportRootDesigner.cs" />
9396
<Compile Include="src\Designer\ReportSettingsDesigner.cs" />
9497
<Compile Include="src\Designer\RootReportModel.cs" />
@@ -109,6 +112,7 @@
109112
<Compile Include="src\Toolbox\SideTabItemDesigner.cs" />
110113
<Compile Include="src\Toolbox\ToolboxProvider.cs" />
111114
<Compile Include="src\TypeProvider\AbstractItemTypeProvider.cs" />
115+
<Compile Include="src\TypeProvider\LineItemTypeProvider.cs" />
112116
<Compile Include="src\TypeProvider\SectionItemTypeProvider.cs" />
113117
<Compile Include="src\TypeProvider\TextItemTypeProvider.cs" />
114118
<Compile Include="src\TypeProvider\TypeProviderHelper.cs" />
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Peter Forstmeier
4+
* Date: 23.03.2014
5+
* Time: 17:54
6+
*
7+
* To change this template use Tools | Options | Coding | Edit Standard Headers.
8+
*/
9+
using System;
10+
using System.ComponentModel;
11+
using System.Drawing;
12+
using System.Drawing.Drawing2D;
13+
using ICSharpCode.Reporting.Addin.Designer;
14+
using ICSharpCode.Reporting.Addin.TypeProvider;
15+
16+
namespace ICSharpCode.Reporting.Addin.DesignableItems
17+
{
18+
[Designer(typeof(LineDesigner))]
19+
public class BaseLineItem:AbstractItem
20+
{
21+
Point fromPoint;
22+
Point toPoint;
23+
LineCap startLineCap;
24+
LineCap endLineCap;
25+
DashCap dashLineCap;
26+
DashStyle dashStyle;
27+
float thickness;
28+
29+
public BaseLineItem()
30+
{
31+
this.thickness = 1;
32+
this.dashStyle = DashStyle.Solid;
33+
this.Size = new Size(50,10);
34+
TypeDescriptor.AddProvider(new LineItemTypeProvider(), typeof(BaseLineItem));
35+
this.SetStartEndPoint();
36+
}
37+
38+
void SetStartEndPoint ()
39+
{
40+
fromPoint = new Point(ClientRectangle.Left + 10,ClientRectangle.Height / 2);
41+
toPoint = new Point(ClientRectangle.Left + ClientRectangle.Width - 10,
42+
ClientRectangle.Height/ 2);
43+
Invalidate();
44+
}
45+
46+
47+
48+
// [System.ComponentModel.EditorBrowsableAttribute()]
49+
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
50+
{
51+
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
52+
base.OnPaint(e);
53+
Draw(e.Graphics);
54+
}
55+
56+
57+
public override void Draw(Graphics graphics)
58+
{
59+
if (graphics == null) {
60+
throw new ArgumentNullException("graphics");
61+
}
62+
using (Pen p = new Pen(this.ForeColor,this.Thickness)) {
63+
p.SetLineCap(this.StartLineCap,this.EndLineCap,this.DashLineCap);
64+
graphics.DrawLine(p,this.fromPoint,this.toPoint);
65+
}
66+
}
67+
68+
69+
public Point FromPoint {
70+
get { return fromPoint; }
71+
set {
72+
Point x = value;
73+
if (!this.ClientRectangle.Contains(x)) {
74+
this.fromPoint = new Point(x.X - this.Location.X,
75+
x.Y - this.Location.Y);
76+
} else {
77+
this.fromPoint = x;
78+
}
79+
this.Invalidate();
80+
}
81+
}
82+
83+
84+
public Point ToPoint {
85+
get { return toPoint; }
86+
set {
87+
Point x = value;
88+
if (!ClientRectangle.Contains(x)) {
89+
this.toPoint = new Point(x.X - this.Location.X,
90+
x.Y - this.Location.Y);
91+
}
92+
else {
93+
toPoint = x;
94+
}
95+
Invalidate();
96+
}
97+
}
98+
99+
100+
101+
// [Browsable(true),
102+
// Category("Appearance"),
103+
// Description("LineStyle")]
104+
public DashStyle DashStyle {
105+
get { return dashStyle; }
106+
set {
107+
dashStyle = value;
108+
this.Invalidate();
109+
}
110+
}
111+
112+
113+
// [Browsable(true),
114+
// Category("Appearance"),
115+
// Description("Thickness of Line")]
116+
public float Thickness {
117+
get { return thickness; }
118+
set {
119+
thickness = value;
120+
this.Invalidate();
121+
}
122+
}
123+
124+
// [Browsable(true),
125+
// Category("Appearance"),
126+
// Description("LineCap at Startposition")]
127+
public LineCap StartLineCap {
128+
get { return startLineCap; }
129+
set {
130+
startLineCap = value;
131+
this.Invalidate();
132+
}
133+
}
134+
135+
// [Browsable(true),
136+
// Category("Appearance"),
137+
// Description("Linecap at Endposition")]
138+
public LineCap EndLineCap {
139+
get { return endLineCap; }
140+
set {
141+
endLineCap = value;
142+
this.Invalidate();
143+
}
144+
}
145+
146+
// [Browsable(true),
147+
// Category("Appearance"),
148+
// Description("Dashlinecap")]
149+
public DashCap DashLineCap {
150+
get { return dashLineCap; }
151+
set {
152+
dashLineCap = value;
153+
this.Invalidate();
154+
}
155+
}
156+
157+
}
158+
159+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Peter Forstmeier
4+
* Date: 23.03.2014
5+
* Time: 18:22
6+
*
7+
* To change this template use Tools | Options | Coding | Edit Standard Headers.
8+
*/
9+
using System;
10+
using System.ComponentModel.Design;
11+
using System.Windows.Forms.Design;
12+
13+
namespace ICSharpCode.Reporting.Addin.Designer
14+
{
15+
/// <summary>
16+
/// Description of AbstractDesigner.
17+
/// </summary>
18+
public class AbstractDesigner:ControlDesigner
19+
{
20+
21+
public override void Initialize(System.ComponentModel.IComponent component)
22+
{
23+
base.Initialize(component);
24+
SelectionService = GetService(typeof(ISelectionService)) as ISelectionService;
25+
ComponentChangeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
26+
}
27+
28+
29+
protected ISelectionService SelectionService {get; private set;}
30+
31+
protected IComponentChangeService ComponentChangeService {get;private set;}
32+
}
33+
}

0 commit comments

Comments
 (0)