Browse Source

TextItemDesigner

reports
Peter Forstmeier 11 years ago
parent
commit
ae1f3133c2
  1. 3
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/ICSharpCode.Reporting.Addin.csproj
  2. 7
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/AbstractItem.cs
  3. 183
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseTextItem.cs
  4. 12
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/ReportRootDesigner.cs
  5. 51
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/RootReportModel.cs
  6. 134
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs
  7. 51
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/DesignerGenerator.cs
  8. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/InternalReportLoader.cs
  9. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/ReportDefinitionDeserializer.cs
  10. 19
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/DesignerGlobals.cs
  11. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/SectionItemTypeProvider.cs
  12. 81
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TextItemTypeProvider.cs
  13. 4
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/XML/ReportDesignerWriter.cs
  14. 1
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
  15. 143
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/TextDrawer.cs
  16. 10
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs

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

@ -80,6 +80,7 @@
<Compile Include="src\Commands\ViewCommands.cs" /> <Compile Include="src\Commands\ViewCommands.cs" />
<Compile Include="src\DesignableItems\AbstractItem.cs" /> <Compile Include="src\DesignableItems\AbstractItem.cs" />
<Compile Include="src\DesignableItems\BaseSection.cs" /> <Compile Include="src\DesignableItems\BaseSection.cs" />
<Compile Include="src\DesignableItems\BaseTextItem.cs" />
<Compile Include="src\DesignableItems\ReportSettings.cs" /> <Compile Include="src\DesignableItems\ReportSettings.cs" />
<Compile Include="src\DesignerBinding\DesignerBinding.cs" /> <Compile Include="src\DesignerBinding\DesignerBinding.cs" />
<Compile Include="src\DesignerBinding\DesignerGenerator.cs" /> <Compile Include="src\DesignerBinding\DesignerGenerator.cs" />
@ -91,6 +92,7 @@
<Compile Include="src\Designer\ReportSettingsDesigner.cs" /> <Compile Include="src\Designer\ReportSettingsDesigner.cs" />
<Compile Include="src\Designer\RootReportModel.cs" /> <Compile Include="src\Designer\RootReportModel.cs" />
<Compile Include="src\Designer\SectionDesigner.cs" /> <Compile Include="src\Designer\SectionDesigner.cs" />
<Compile Include="src\Designer\TextItemDesigner.cs" />
<Compile Include="src\Globals\DesignerGlobals.cs" /> <Compile Include="src\Globals\DesignerGlobals.cs" />
<Compile Include="src\Globals\StringWriterWithEncoding.cs" /> <Compile Include="src\Globals\StringWriterWithEncoding.cs" />
<Compile Include="src\Services\DefaultMemberRelationshipService.cs" /> <Compile Include="src\Services\DefaultMemberRelationshipService.cs" />
@ -105,6 +107,7 @@
<Compile Include="src\Services\UIService.cs" /> <Compile Include="src\Services\UIService.cs" />
<Compile Include="src\TypeProvider\AbstractItemTypeProvider.cs" /> <Compile Include="src\TypeProvider\AbstractItemTypeProvider.cs" />
<Compile Include="src\TypeProvider\SectionItemTypeProvider.cs" /> <Compile Include="src\TypeProvider\SectionItemTypeProvider.cs" />
<Compile Include="src\TypeProvider\TextItemTypeProvider.cs" />
<Compile Include="src\TypeProvider\TypeProviderHelper.cs" /> <Compile Include="src\TypeProvider\TypeProviderHelper.cs" />
<Compile Include="src\Views\DesignerView.cs" /> <Compile Include="src\Views\DesignerView.cs" />
<Compile Include="src\Views\XmlView.cs" /> <Compile Include="src\Views\XmlView.cs" />

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

@ -19,7 +19,7 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems
// [TypeDescriptionProvider(typeof(AbstractItemTypeProvider))] // [TypeDescriptionProvider(typeof(AbstractItemTypeProvider))]
public abstract class AbstractItem:System.Windows.Forms.Control public abstract class AbstractItem:System.Windows.Forms.Control
{ {
private Color frameColor = Color.Black; Color frameColor = Color.Black;
protected AbstractItem() protected AbstractItem()
@ -31,8 +31,8 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems
protected void DrawControl (Graphics graphics,Rectangle borderRectangle) protected void DrawControl (Graphics graphics,Rectangle borderRectangle)
{ {
if (this.DrawBorder == true) { if (DrawBorder == true) {
graphics.DrawRectangle(new Pen(this.frameColor),borderRectangle); graphics.DrawRectangle(new Pen(frameColor),borderRectangle);
} }
System.Windows.Forms.ControlPaint.DrawBorder3D(graphics, this.ClientRectangle, System.Windows.Forms.ControlPaint.DrawBorder3D(graphics, this.ClientRectangle,
System.Windows.Forms.Border3DStyle.Etched); System.Windows.Forms.Border3DStyle.Etched);
@ -66,6 +66,7 @@ namespace ICSharpCode.Reporting.Addin.DesignableItems
Description("Draw a Border around the Item")] Description("Draw a Border around the Item")]
public bool DrawBorder {get;set;} public bool DrawBorder {get;set;}
protected new Size DefaultSize {get;set;} protected new Size DefaultSize {get;set;}

183
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignableItems/BaseTextItem.cs

@ -0,0 +1,183 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.03.2014
* Time: 20:30
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.Drawing;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.Globals;
using ICSharpCode.Reporting.Addin.Designer;
using ICSharpCode.Reporting.Addin.TypeProvider;
namespace ICSharpCode.Reporting.Addin.DesignableItems
{
/// <summary>
/// Description of BaseTextItem.
/// </summary>
[Designer(typeof(TextItemDesigner))]
public class BaseTextItem:AbstractItem
{
string formatString;
StringFormat stringFormat;
StringTrimming stringTrimming;
ContentAlignment contentAlignment;
public BaseTextItem():base()
{
DefaultSize = GlobalValues.PreferedSize;
Size = GlobalValues.PreferedSize;
BackColor = Color.White;
contentAlignment = ContentAlignment.TopLeft;
TypeDescriptor.AddProvider(new TextItemTypeProvider(), typeof(BaseTextItem));
}
[EditorBrowsableAttribute()]
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
base.OnPaint(e);
this.Draw(e.Graphics);
}
public override void Draw(Graphics graphics)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
using (var backgroundBrush = new SolidBrush(this.BackColor)){
graphics.FillRectangle(backgroundBrush, base.DrawingRectangle);
}
var designTrimmimg = StringTrimming.EllipsisCharacter;
if (stringTrimming != StringTrimming.None) {
designTrimmimg = stringTrimming;
}
stringFormat = TextDrawer.BuildStringFormat(designTrimmimg, contentAlignment);
using (var textBrush = new SolidBrush(ForeColor)) {
TextDrawer.DrawString(graphics, Text, Font, textBrush, ClientRectangle, stringFormat);
}
// if (this.RightToLeft == System.Windows.Forms.RightToLeft.Yes) {
// stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft;
// }
//
DrawControl(graphics, base.DrawingRectangle);
}
// [EditorAttribute(typeof(DefaultTextEditor),
// typeof(System.Drawing.Design.UITypeEditor) )]
public override string Text {
get { return base.Text; }
set { base.Text = value;
this.Invalidate();
}
}
#region Format and alignment
// [Browsable(true),
// Category("Appearance"),
// Description("String to format Number's Date's etc")]
// [DefaultValue("entry1")]
// [TypeConverter(typeof(FormatStringConverter))]
public string FormatString {
get { return formatString; }
set {
formatString = value;
Invalidate();
}
}
[Browsable(false)]
public StringFormat StringFormat {
get { return stringFormat; }
set {
stringFormat = value;
Invalidate();
}
}
[Category("Appearance")]
public StringTrimming StringTrimming {
get { return stringTrimming; }
set {
stringTrimming = value;
Invalidate();
}
}
// [Category("Appearance")]
// [EditorAttribute(typeof(ContentAlignmentEditor),
// typeof(UITypeEditor) )]
public ContentAlignment ContentAlignment {
get { return contentAlignment; }
set {
contentAlignment = value;
Invalidate();
}
}
#endregion
#region RighToLeft
[Category("Appearance")]
public System.Windows.Forms.RightToLeft RTL
{
get { return base.RightToLeft; }
set { base.RightToLeft = value; }
}
#endregion
#region DataType
// [Browsable(true),
// Category("Databinding"),
// Description("Datatype of the underlying Column")]
// [DefaultValue("System.String")]
// [TypeConverter(typeof(DataTypeStringConverter))]
public string DataType {get;set;}
#endregion
#region Expression
// [Browsable(true),
// Category("Expression"),
// Description("Enter a valid Expression")]
// [EditorAttribute(typeof(DefaultTextEditor),
// typeof(System.Drawing.Design.UITypeEditor) )]
public string Expression {get;set;}
#endregion
#region CanGrow/CanShrink
public bool CanGrow {get;set;}
public bool CanShrink {get;set;}
#endregion
}
}

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

@ -59,20 +59,15 @@ namespace ICSharpCode.Reporting.Addin.Designer
} }
} }
// private new void DisplayError(Exception ex)
// {
// MessageBox.Show(ex.Message + "\n" + ex.StackTrace, "Fehler im Designer", MessageBoxButtons.OK, MessageBoxIcon.Error);
// }
private void InitializeGUI() void InitializeGUI()
{ {
reportSettings = host.Container.Components[1] as ICSharpCode.Reporting.Items.ReportSettings; reportSettings = host.Container.Components[1] as ICSharpCode.Reporting.Items.ReportSettings;
InitializeRootReportModel(); InitializeRootReportModel();
} }
private void InitializeRootReportModel () void InitializeRootReportModel ()
{ {
rootReportModel = host.Container.Components[0] as RootReportModel; rootReportModel = host.Container.Components[0] as RootReportModel;
rootReportModel.PageMargin = CalculateMargins(); rootReportModel.PageMargin = CalculateMargins();
@ -201,7 +196,6 @@ namespace ICSharpCode.Reporting.Addin.Designer
{ {
section.Location = new Point(reportSettings.LeftMargin,locY); section.Location = new Point(reportSettings.LeftMargin,locY);
locY = locY + section.Size.Height + DesignerGlobals.GabBetweenSection; locY = locY + section.Size.Height + DesignerGlobals.GabBetweenSection;
section.Invalidate();
} }
Control.Invalidate(); Control.Invalidate();
} }
@ -211,7 +205,7 @@ namespace ICSharpCode.Reporting.Addin.Designer
void OnLoadComplete(object sender, EventArgs e) void OnLoadComplete(object sender, EventArgs e)
{ {
var host = (IDesignerHost)sender; var host = (IDesignerHost)sender;
host.LoadComplete -= new EventHandler(this.OnLoadComplete); host.LoadComplete -= OnLoadComplete;
InitializeGUI(); InitializeGUI();
} }

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

@ -23,13 +23,13 @@ namespace ICSharpCode.Reporting.Addin.Designer
public class RootReportModel:RootDesignedComponent public class RootReportModel:RootDesignedComponent
{ {
bool showDebugFrame;
[EditorBrowsableAttribute()] [EditorBrowsableAttribute()]
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea) protected override void OnPaint(System.Windows.Forms.PaintEventArgs pea)
{ {
Console.WriteLine("RootReportModel:Onpaint : {0}",this.BackColor);
base.OnPaint(pea); base.OnPaint(pea);
PrintMargin(pea.Graphics);
using (Font font = DesignerGlobals.DesignerFont) { using (Font font = DesignerGlobals.DesignerFont) {
foreach(System.Windows.Forms.Control ctrl in this.Controls) foreach(System.Windows.Forms.Control ctrl in this.Controls)
{ {
@ -41,6 +41,53 @@ namespace ICSharpCode.Reporting.Addin.Designer
} }
} }
void PrintMargin( Graphics graphics)
{
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture,
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]",
Page.Size, Landscape, PageMargin);
using (var font = DesignerGlobals.DesignerFont){
SizeF size = graphics.MeasureString(header,font);
graphics.DrawString(header,font,
new SolidBrush(Color.LightGray),
new Rectangle(
3,
3 + (int)font.GetHeight(),
(int)size.Width,
(int)size.Height));
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2,
Page.Width - PageMargin.Left - PageMargin.Right + 2,
Size.Height - PageMargin.Top - PageMargin.Bottom + 2);
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect);
// e.FillRectangle(new SolidBrush(SystemColors.Window),rect);
}
}
void old_PrintMargin( Graphics graphics)
{
string header = String.Format(System.Globalization.CultureInfo.CurrentCulture,
"[Size : {0}] [Landscape : {1}] [Bounds : {2}]",
this.Page,this.Landscape,this.PageMargin);
using (var font = DesignerGlobals.DesignerFont){
SizeF size = graphics.MeasureString(header,font);
graphics.DrawString(header,font,
new SolidBrush(Color.LightGray),
new Rectangle(PageMargin.Left + 100,
this.PageMargin.Top - (int)font.GetHeight() - 3,
(int)size.Width,
(int)size.Height));
var rect = new Rectangle(PageMargin.Left - 2,PageMargin.Top - 2,
Page.Width - PageMargin.Left - PageMargin.Right + 2,
Size.Height - PageMargin.Top - PageMargin.Bottom + 2);
graphics.DrawRectangle(new Pen(Color.LightGray,1),rect);
}
}
public Margins PageMargin {get;set;} public Margins PageMargin {get;set;}
public Rectangle Page {get;set;} public Rectangle Page {get;set;}

134
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Designer/TextItemDesigner.cs

@ -0,0 +1,134 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.03.2014
* Time: 20:24
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Windows.Forms.Design;
using ICSharpCode.Reporting.Items;
using ICSharpCode.Reporting.Addin.TypeProvider;
namespace ICSharpCode.Reporting.Addin.Designer
{
/// <summary>
/// Description of TextItemDesigner.
/// </summary>
public class TextItemDesigner:ControlDesigner
{
ISelectionService selectionService;
IComponentChangeService componentChangeService;
BaseTextItem ctrl;
public override void Initialize(IComponent component)
{
base.Initialize(component);
GetService();
ctrl = (BaseTextItem) component;
}
protected override void PostFilterProperties(System.Collections.IDictionary properties)
{
TypeProviderHelper.RemoveProperties(properties);
base.PostFilterProperties(properties);
}
private 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);
}
}
private void OnSelectionChanged(object sender, EventArgs e)
{
Control.Invalidate( );
}
private void OnComponentRename(object sender,ComponentRenameEventArgs e) {
if (e.Component == this.Component) {
Control.Name = e.NewName;
Control.Invalidate();
}
}
#region SmartTag
// public override DesignerActionListCollection ActionLists {
// get {
// var actions = new DesignerActionListCollection ();
// actions.Add (new TextBasedDesignerActionList(this.Component));
// return actions;
// }
// }
#endregion
#region ContextMenu
/*
public override DesignerVerbCollection Verbs {
get {
var verbs = new DesignerVerbCollection();
var v1 = new DesignerVerb ("TextEditor",OnRunTextEditor);
verbs.Add (v1);
return verbs;
}
}
private void OnRunTextEditor (object sender,EventArgs e)
{
IStringBasedEditorDialog ed = new TextEditorDialog (ctrl.Text,ctrl.Name);
if (ed.ShowDialog() == DialogResult.OK) {
ctrl.Text = ed.TextValue;
this.SetProperty ("Name",ed.TextValue);
}
}
private void SetProperty (string prop, object value)
{
PropertyDescriptor p = TypeDescriptor.GetProperties(Control)[prop];
if (p == null) {
throw new ArgumentException (this.ctrl.Text);
} else {
p.SetValue (Control,value);
}
}
*/
#endregion
protected override void Dispose(bool disposing)
{
if (this.selectionService != null) {
selectionService.SelectionChanged -= OnSelectionChanged;
}
if (componentChangeService != null) {
componentChangeService.ComponentRename -= OnComponentRename;
}
base.Dispose(disposing);
}
}
}

51
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/DesignerGenerator.cs

@ -8,6 +8,7 @@
*/ */
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Xml; using System.Xml;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -53,36 +54,15 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding
public void MergeFormChanges(System.CodeDom.CodeCompileUnit unit) public void MergeFormChanges(System.CodeDom.CodeCompileUnit unit)
{ {
System.Diagnostics.Trace.WriteLine("Generator:MergeFormChanges"); System.Diagnostics.Trace.WriteLine("Generator:MergeFormChanges");
var writer = new StringWriterWithEncoding(System.Text.Encoding.UTF8); var writer = InternalMergeFormChanges();
var xml = XmlHelper.CreatePropperWriter(writer);
InternalMergeFormChanges(xml);
Console.WriteLine(writer.ToString());
viewContent.ReportFileContent = writer.ToString(); viewContent.ReportFileContent = writer.ToString();
} }
public bool InsertComponentEvent(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
{
throw new NotImplementedException();
}
public System.CodeDom.Compiler.CodeDomProvider CodeDomProvider { StringWriter InternalMergeFormChanges()
get {
throw new NotImplementedException();
}
}
public DesignerView ViewContent {
get {return viewContent;}
}
#endregion
void InternalMergeFormChanges(XmlTextWriter xml)
{ {
if (xml == null) { var writer = new StringWriterWithEncoding(System.Text.Encoding.UTF8);
throw new ArgumentNullException("xml"); var xml = XmlHelper.CreatePropperWriter(writer);
}
var rpd = new ReportDesignerWriter(); var rpd = new ReportDesignerWriter();
XmlHelper.CreatePropperDocument(xml); XmlHelper.CreatePropperDocument(xml);
@ -108,6 +88,27 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding
xml.WriteEndElement(); xml.WriteEndElement();
xml.WriteEndDocument(); xml.WriteEndDocument();
xml.Close(); xml.Close();
return writer;
} }
public DesignerView ViewContent {
get {return viewContent;}
}
public bool InsertComponentEvent(System.ComponentModel.IComponent component, System.ComponentModel.EventDescriptor edesc, string eventMethodName, string body, out string file, out int position)
{
throw new NotImplementedException();
}
public System.CodeDom.Compiler.CodeDomProvider CodeDomProvider {
get {
throw new NotImplementedException();
}
}
#endregion
} }
} }

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/InternalReportLoader.cs

@ -91,9 +91,5 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding
var reportModel = deserializer.CreateModelFromXml(document.DocumentElement); var reportModel = deserializer.CreateModelFromXml(document.DocumentElement);
return reportModel; return reportModel;
} }
// public ReportModel ReportModel {get; private set;}
} }
} }

1
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/DesignerBinding/ReportDefinitionDeserializer.cs

@ -65,7 +65,6 @@ namespace ICSharpCode.Reporting.Addin.DesignerBinding
var reportSettings = CreateReportSettings(elem); var reportSettings = CreateReportSettings(elem);
// var reportModel = new ReportModel();
var reportModel = ReportModelFactory.Create(); var reportModel = ReportModelFactory.Create();
reportModel.ReportSettings = reportSettings; reportModel.ReportSettings = reportSettings;

19
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/Globals/DesignerGlobals.cs

@ -14,7 +14,7 @@ namespace ICSharpCode.Reporting.Addin.Globals
/// <summary> /// <summary>
/// Description of DesignerGlobals. /// Description of DesignerGlobals.
/// </summary> /// </summary>
class DesignerGlobals{ static class DesignerGlobals{
public static Font DesignerFont public static Font DesignerFont
{ {
@ -29,5 +29,22 @@ namespace ICSharpCode.Reporting.Addin.Globals
public static int GabBetweenSection{ public static int GabBetweenSection{
get {return 15;} get {return 15;}
} }
public static void DrawString(Graphics graphics,string text,
Font font,Brush brush,
RectangleF rectangle,
StringFormat format)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
graphics.DrawString(text,
font,
brush,
rectangle,
format);
}
} }
} }

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

@ -31,7 +31,7 @@ namespace ICSharpCode.Reporting.Addin.TypeProvider
} }
internal class SectionItemDescriptor : CustomTypeDescriptor class SectionItemDescriptor : CustomTypeDescriptor
{ {

81
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/TypeProvider/TextItemTypeProvider.cs

@ -0,0 +1,81 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.03.2014
* Time: 20:38
*
* 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 TextItemTypeProvider.
/// </summary>
class TextItemTypeProvider : TypeDescriptionProvider
{
public TextItemTypeProvider() : base(TypeDescriptor.GetProvider(typeof(AbstractItem)))
{
}
public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
{
ICustomTypeDescriptor td = base.GetTypeDescriptor(objectType,instance);
return new TextItemTypeDescriptor(td, instance);
}
}
class TextItemTypeDescriptor : CustomTypeDescriptor
{
BaseTextItem instance;
public TextItemTypeDescriptor(ICustomTypeDescriptor parent, object instance)
: base(parent)
{
instance = instance as BaseTextItem;
}
public override PropertyDescriptorCollection GetProperties()
{
return GetProperties(null);
}
public override PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
var props = base.GetProperties(attributes);
var allProperties = new List<PropertyDescriptor>();
TypeProviderHelper.AddDefaultProperties(allProperties,props);
TypeProviderHelper.AddTextBasedProperties(allProperties,props);
var prop = props.Find("Text", true);
allProperties.Add(prop);
prop = props.Find("DrawBorder",true);
allProperties.Add(prop);
prop = props.Find("FrameColor",true);
allProperties.Add(prop);
prop = props.Find("ForeColor",true);
allProperties.Add(prop);
prop = props.Find("Visible",true);
allProperties.Add(prop);
prop = props.Find("Expression",true);
allProperties.Add(prop);
return new PropertyDescriptorCollection(allProperties.ToArray());
}
}
}

4
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/XML/ReportDesignerWriter.cs

@ -15,10 +15,6 @@ namespace ICSharpCode.Reporting.Addin.XML
/// </summary> /// </summary>
public class ReportDesignerWriter:MycroWriter public class ReportDesignerWriter:MycroWriter
{ {
public ReportDesignerWriter()
{
}
protected override string GetTypeName(Type t) protected override string GetTypeName(Type t)
{ {
if (t.BaseType != null && t.BaseType.Name.StartsWith("Base",StringComparison.InvariantCultureIgnoreCase)) { if (t.BaseType != null && t.BaseType.Name.StartsWith("Base",StringComparison.InvariantCultureIgnoreCase)) {

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

@ -87,6 +87,7 @@
<Compile Include="Src\BaseClasses\BasicParameter.cs" /> <Compile Include="Src\BaseClasses\BasicParameter.cs" />
<Compile Include="Src\BaseClasses\ExtensionMethods.cs" /> <Compile Include="Src\BaseClasses\ExtensionMethods.cs" />
<Compile Include="Src\BaseClasses\PageInfo.cs" /> <Compile Include="Src\BaseClasses\PageInfo.cs" />
<Compile Include="Src\BaseClasses\TextDrawer.cs" />
<Compile Include="Src\Collections.cs" /> <Compile Include="Src\Collections.cs" />
<Compile Include="Src\Configuration\AssemblyInfo.cs" /> <Compile Include="Src\Configuration\AssemblyInfo.cs" />
<Compile Include="Src\DataManager\Listhandling\CollectionDataSource.cs" /> <Compile Include="Src\DataManager\Listhandling\CollectionDataSource.cs" />

143
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/BaseClasses/TextDrawer.cs

@ -0,0 +1,143 @@
/*
* Created by SharpDevelop.
* User: Peter Forstmeier
* Date: 21.03.2014
* Time: 20:35
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Drawing.Text;
namespace ICSharpCode.Reporting.BaseClasses
{
/// <summary>
/// Description of TextDrawer.
/// </summary>
public sealed class TextDrawer
{
private TextDrawer()
{
}
public static void DrawString(Graphics graphics,string text,
Font font,Brush brush,
RectangleF rectangle,
StringFormat format)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
graphics.DrawString(text,
font,
brush,
rectangle,
format);
}
public static void DrawString (Graphics graphics,string text)
{
if (graphics == null) {
throw new ArgumentNullException("graphics");
}
// if (decorator == null) {
// throw new ArgumentNullException("decorator");
// }
// StringFormat stringFormat = BuildStringFormat(decorator.StringTrimming,decorator.ContentAlignment);
//
// if (decorator.RightToLeft ==System.Windows.Forms.RightToLeft.Yes) {
// stringFormat.FormatFlags = stringFormat.FormatFlags | StringFormatFlags.DirectionRightToLeft;
// }
var formattedString = text;
// if (! String.IsNullOrEmpty(decorator.FormatString)) {
// formattedString = StandardFormatter.FormatOutput(text,decorator.FormatString,decorator.DataType,String.Empty);
// }
graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
// graphics.DrawString (formattedString,decorator.Font,
// new SolidBrush(decorator.ForeColor),
// new Rectangle(decorator.Location.X,
// decorator.Location.Y,
// decorator.Size.Width,
// decorator.Size.Height),
// stringFormat);
}
public static StringFormat BuildStringFormat(StringTrimming stringTrimming,ContentAlignment alignment)
{
StringFormat format = StringFormat.GenericTypographic;
format.Trimming = stringTrimming;
format.FormatFlags = StringFormatFlags.LineLimit;
if (alignment <= ContentAlignment.MiddleCenter){
switch (alignment){
case ContentAlignment.TopLeft:{
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Near;
return format;
}
case ContentAlignment.TopCenter:{
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Near;
return format;
}
case (ContentAlignment.TopCenter | ContentAlignment.TopLeft):{
return format;
}
case ContentAlignment.TopRight:{
format.Alignment = StringAlignment.Far;
format.LineAlignment = StringAlignment.Near;
return format;
}
case ContentAlignment.MiddleLeft:{
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Center;
return format;
}
case ContentAlignment.MiddleCenter:{
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Center;
return format;
}
}
return format;
}
if (alignment <= ContentAlignment.BottomLeft){
if (alignment == ContentAlignment.MiddleRight){
format.Alignment = StringAlignment.Far;
format.LineAlignment = StringAlignment.Center;
return format;
}
if (alignment != ContentAlignment.BottomLeft){
return format;
}
}
else{
if (alignment != ContentAlignment.BottomCenter){
if (alignment == ContentAlignment.BottomRight)
{
format.Alignment = StringAlignment.Far;
format.LineAlignment = StringAlignment.Far;
}
return format;
}
format.Alignment = StringAlignment.Center;
format.LineAlignment = StringAlignment.Far;
return format;
}
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Far;
return format;
}
}
}

10
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Globals/GlobalValues.cs

@ -33,20 +33,20 @@ namespace ICSharpCode.Reporting.Globals
public static string PlainFileName public static string PlainFileName
{ {
get { get {return DefaultReportName + ReportExtension;}
return DefaultReportName + ReportExtension;
}
} }
public static Font DefaultFont public static Font DefaultFont
{ {
get { get {return new Font("Microsoft Sans Serif",
return new Font("Microsoft Sans Serif",
10, 10,
FontStyle.Regular, FontStyle.Regular,
GraphicsUnit.Point); GraphicsUnit.Point);
} }
} }
public static Size PreferedSize {get {return new Size(100,20);}}
} }
} }

Loading…
Cancel
Save