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

Commit ae1f313

Browse files
TextItemDesigner
1 parent 8b6c86d commit ae1f313

16 files changed

Lines changed: 651 additions & 55 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
<Compile Include="src\Commands\ViewCommands.cs" />
8181
<Compile Include="src\DesignableItems\AbstractItem.cs" />
8282
<Compile Include="src\DesignableItems\BaseSection.cs" />
83+
<Compile Include="src\DesignableItems\BaseTextItem.cs" />
8384
<Compile Include="src\DesignableItems\ReportSettings.cs" />
8485
<Compile Include="src\DesignerBinding\DesignerBinding.cs" />
8586
<Compile Include="src\DesignerBinding\DesignerGenerator.cs" />
@@ -91,6 +92,7 @@
9192
<Compile Include="src\Designer\ReportSettingsDesigner.cs" />
9293
<Compile Include="src\Designer\RootReportModel.cs" />
9394
<Compile Include="src\Designer\SectionDesigner.cs" />
95+
<Compile Include="src\Designer\TextItemDesigner.cs" />
9496
<Compile Include="src\Globals\DesignerGlobals.cs" />
9597
<Compile Include="src\Globals\StringWriterWithEncoding.cs" />
9698
<Compile Include="src\Services\DefaultMemberRelationshipService.cs" />
@@ -105,6 +107,7 @@
105107
<Compile Include="src\Services\UIService.cs" />
106108
<Compile Include="src\TypeProvider\AbstractItemTypeProvider.cs" />
107109
<Compile Include="src\TypeProvider\SectionItemTypeProvider.cs" />
110+
<Compile Include="src\TypeProvider\TextItemTypeProvider.cs" />
108111
<Compile Include="src\TypeProvider\TypeProviderHelper.cs" />
109112
<Compile Include="src\Views\DesignerView.cs" />
110113
<Compile Include="src\Views\XmlView.cs" />

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems
1919
// [TypeDescriptionProvider(typeof(AbstractItemTypeProvider))]
2020
public abstract class AbstractItem:System.Windows.Forms.Control
2121
{
22-
private Color frameColor = Color.Black;
22+
Color frameColor = Color.Black;
2323

2424

2525
protected AbstractItem()
@@ -31,8 +31,8 @@ protected AbstractItem()
3131

3232
protected void DrawControl (Graphics graphics,Rectangle borderRectangle)
3333
{
34-
if (this.DrawBorder == true) {
35-
graphics.DrawRectangle(new Pen(this.frameColor),borderRectangle);
34+
if (DrawBorder == true) {
35+
graphics.DrawRectangle(new Pen(frameColor),borderRectangle);
3636
}
3737
System.Windows.Forms.ControlPaint.DrawBorder3D(graphics, this.ClientRectangle,
3838
System.Windows.Forms.Border3DStyle.Etched);
@@ -66,6 +66,7 @@ public Color FrameColor {
6666
Description("Draw a Border around the Item")]
6767
public bool DrawBorder {get;set;}
6868

69+
6970
protected new Size DefaultSize {get;set;}
7071

7172

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*
2+
* Created by SharpDevelop.
3+
* User: Peter Forstmeier
4+
* Date: 21.03.2014
5+
* Time: 20:30
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 ICSharpCode.Reporting.BaseClasses;
13+
using ICSharpCode.Reporting.Globals;
14+
using ICSharpCode.Reporting.Addin.Designer;
15+
using ICSharpCode.Reporting.Addin.TypeProvider;
16+
17+
namespace ICSharpCode.Reporting.Addin.DesignableItems
18+
{
19+
/// <summary>
20+
/// Description of BaseTextItem.
21+
/// </summary>
22+
[Designer(typeof(TextItemDesigner))]
23+
public class BaseTextItem:AbstractItem
24+
{
25+
26+
string formatString;
27+
StringFormat stringFormat;
28+
StringTrimming stringTrimming;
29+
ContentAlignment contentAlignment;
30+
31+
32+
public BaseTextItem():base()
33+
{
34+
DefaultSize = GlobalValues.PreferedSize;
35+
Size = GlobalValues.PreferedSize;
36+
BackColor = Color.White;
37+
contentAlignment = ContentAlignment.TopLeft;
38+
TypeDescriptor.AddProvider(new TextItemTypeProvider(), typeof(BaseTextItem));
39+
}
40+
41+
42+
[EditorBrowsableAttribute()]
43+
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
44+
{
45+
base.OnPaint(e);
46+
this.Draw(e.Graphics);
47+
}
48+
49+
50+
public override void Draw(Graphics graphics)
51+
{
52+
if (graphics == null) {
53+
throw new ArgumentNullException("graphics");
54+
}
55+
using (var backgroundBrush = new SolidBrush(this.BackColor)){
56+
graphics.FillRectangle(backgroundBrush, base.DrawingRectangle);
57+
}
58+
59+
var designTrimmimg = StringTrimming.EllipsisCharacter;
60+
61+
if (stringTrimming != StringTrimming.None) {
62+
designTrimmimg = stringTrimming;
63+
}
64+
65+
stringFormat = TextDrawer.BuildStringFormat(designTrimmimg, contentAlignment);
66+
using (var textBrush = new SolidBrush(ForeColor)) {
67+
TextDrawer.DrawString(graphics, Text, Font, textBrush, ClientRectangle, stringFormat);
68+
}
69+
70+
// if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes) {
71+
// stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft;
72+
// }
73+
//
74+
DrawControl(graphics, base.DrawingRectangle);
75+
}
76+
77+
78+
79+
// [EditorAttribute(typeof(DefaultTextEditor),
80+
// typeof(System.Drawing.Design.UITypeEditor) )]
81+
public override string Text {
82+
get { return base.Text; }
83+
set { base.Text = value;
84+
this.Invalidate();
85+
}
86+
}
87+
88+
89+
#region Format and alignment
90+
91+
// [Browsable(true),
92+
// Category("Appearance"),
93+
// Description("String to format Number's Date's etc")]
94+
// [DefaultValue("entry1")]
95+
// [TypeConverter(typeof(FormatStringConverter))]
96+
97+
public string FormatString {
98+
get { return formatString; }
99+
set {
100+
formatString = value;
101+
Invalidate();
102+
}
103+
}
104+
105+
106+
[Browsable(false)]
107+
public StringFormat StringFormat {
108+
get { return stringFormat; }
109+
set {
110+
stringFormat = value;
111+
Invalidate();
112+
}
113+
}
114+
115+
116+
[Category("Appearance")]
117+
public StringTrimming StringTrimming {
118+
get { return stringTrimming; }
119+
set {
120+
stringTrimming = value;
121+
Invalidate();
122+
}
123+
}
124+
125+
126+
127+
// [Category("Appearance")]
128+
// [EditorAttribute(typeof(ContentAlignmentEditor),
129+
// typeof(UITypeEditor) )]
130+
public ContentAlignment ContentAlignment {
131+
get { return contentAlignment; }
132+
set {
133+
contentAlignment = value;
134+
Invalidate();
135+
}
136+
}
137+
138+
#endregion
139+
140+
#region RighToLeft
141+
142+
[Category("Appearance")]
143+
public System.Windows.Forms.RightToLeft RTL
144+
{
145+
get { return base.RightToLeft; }
146+
set { base.RightToLeft = value; }
147+
}
148+
149+
#endregion
150+
151+
#region DataType
152+
153+
// [Browsable(true),
154+
// Category("Databinding"),
155+
// Description("Datatype of the underlying Column")]
156+
// [DefaultValue("System.String")]
157+
// [TypeConverter(typeof(DataTypeStringConverter))]
158+
159+
public string DataType {get;set;}
160+
161+
#endregion
162+
163+
#region Expression
164+
165+
// [Browsable(true),
166+
// Category("Expression"),
167+
// Description("Enter a valid Expression")]
168+
// [EditorAttribute(typeof(DefaultTextEditor),
169+
// typeof(System.Drawing.Design.UITypeEditor) )]
170+
public string Expression {get;set;}
171+
172+
#endregion
173+
174+
175+
#region CanGrow/CanShrink
176+
177+
public bool CanGrow {get;set;}
178+
179+
public bool CanShrink {get;set;}
180+
181+
#endregion
182+
}
183+
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,15 @@ void ShowMessage(Exception e)
5959
}
6060
}
6161

62-
// private new void DisplayError(Exception ex)
63-
// {
64-
// MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Fehler im Designer", MessageBoxButtons.OK, MessageBoxIcon.Error);
65-
// }
6662

67-
68-
private void InitializeGUI()
63+
void InitializeGUI()
6964
{
7065
reportSettings = host.Container.Components[1] as ICSharpCode.Reporting.Items.ReportSettings;
7166
InitializeRootReportModel();
7267
}
7368

7469

75-
private void InitializeRootReportModel ()
70+
void InitializeRootReportModel ()
7671
{
7772
rootReportModel = host.Container.Components[0] as RootReportModel;
7873
rootReportModel.PageMargin = CalculateMargins();
@@ -201,7 +196,6 @@ void RecalculateSections()
201196
{
202197
section.Location = new Point(reportSettings.LeftMargin,locY);
203198
locY = locY + section.Size.Height + DesignerGlobals.GabBetweenSection;
204-
section.Invalidate();
205199
}
206200
Control.Invalidate();
207201
}
@@ -211,7 +205,7 @@ void RecalculateSections()
211205
void OnLoadComplete(object sender, EventArgs e)
212206
{
213207
var host = (IDesignerHost)sender;
214-
host.LoadComplete -= new EventHandler(this.OnLoadComplete);
208+
host.LoadComplete -= OnLoadComplete;
215209
InitializeGUI();
216210
}
217211

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

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ namespace ICSharpCode.Reporting.Addin.Designer
2323

2424
public class RootReportModel:RootDesignedComponent
2525
{
26-
bool showDebugFrame;
26+
2727

2828
[EditorBrowsableAttribute()]
2929
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
3030
{
31-
Console.WriteLine("RootReportModel:Onpaint : {0}",this.BackColor);
3231
base.OnPaint(pea);
32+
PrintMargin(pea.Graphics);
3333
using (Font font = DesignerGlobals.DesignerFont) {
3434
foreach(System.Windows.Forms.Control ctrl in this.Controls)
3535
{
@@ -41,6 +41,53 @@ protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
4141
}
4242
}
4343

44+
45+
void PrintMargin( Graphics graphics)
46+
{
47+
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture,
48+
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]",
49+
Page.Size, Landscape, PageMargin);
50+
using (var font = DesignerGlobals.DesignerFont){
51+
SizeF size = graphics.MeasureString(header,font);
52+
graphics.DrawString(header,font,
53+
new SolidBrush(Color.LightGray),
54+
new Rectangle(
55+
3,
56+
3 + (int)font.GetHeight(),
57+
(int)size.Width,
58+
(int)size.Height));
59+
60+
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2,
61+
Page.Width - PageMargin.Left - PageMargin.Right + 2,
62+
Size.Height - PageMargin.Top - PageMargin.Bottom + 2);
63+
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect);
64+
// e.FillRectangle(new SolidBrush(SystemColors.Window),rect);
65+
}
66+
}
67+
68+
69+
void old_PrintMargin( Graphics graphics)
70+
{
71+
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture,
72+
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]",
73+
this.Page,this.Landscape,this.PageMargin);
74+
using (var font = DesignerGlobals.DesignerFont){
75+
SizeF size = graphics.MeasureString(header,font);
76+
graphics.DrawString(header,font,
77+
new SolidBrush(Color.LightGray),
78+
new Rectangle(PageMargin.Left + 100,
79+
this.PageMargin.Top - (int)font.GetHeight() - 3,
80+
(int)size.Width,
81+
(int)size.Height));
82+
83+
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2,
84+
Page.Width - PageMargin.Left - PageMargin.Right + 2,
85+
Size.Height - PageMargin.Top - PageMargin.Bottom + 2);
86+
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect);
87+
}
88+
}
89+
90+
4491
public Margins PageMargin {get;set;}
4592

4693
public Rectangle Page {get;set;}

0 commit comments

Comments
 (0)