We are a Software development company and currently use CrystalReports.NET as integrated reporting solution for our software. We are completely unsatisfied with this, because we want to display custom data (own datatype, binary) from our database in the reports, which seemed impossible within CR (we only managed to get a very slow hard to use solution).
After a whole lot of search I finally found Stimulsoft Reports.NET and (almost) quickly found a solution to be able to transform the data into viewable objects by using a Custom Component.
We are almost about to buy Stimulsoft Reports.NET, the only problem I'm still having is how to bind data to the CustomComponent.
Here is the changed code from your example, please provide me with information on how to be able to get data attached in the designer to this component like I do with a simple textbox.
Code: Select all
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using Stimulsoft.Base;
using Stimulsoft.Base.Drawing;
using Stimulsoft.Base.Serializing;
using Stimulsoft.Base.Services;
using Stimulsoft.Base.Design;
using Stimulsoft.Base.Localization;
using Stimulsoft.Report.Components;
using Stimulsoft.Report.Events;
using Stimulsoft.Report.Components.Design;
using Datos.WTNT.Util;
namespace CustomComponent
{
[StiServiceBitmap(typeof(MyCustomComponent), "CustomComponent.MyCustomComponent1.gif")]
[StiToolbox(true)]
[StiContextTool(typeof(IStiShift))]
[StiContextTool(typeof(IStiGrowToHeight))]
[StiDesigner(typeof(MyCustomComponentDesigner))]
public class MyCustomComponent : StiComponent, IStiBorder, IStiBrush
{
private WTComp wtc;
#region StiComponent override
///
/// Gets value to sort a position in the toolbox.
///
public override int ToolboxPosition
{
get
{
return 500;
}
}
///
/// Gets a localized name of the component category.
///
public override string LocalizedCategory
{
get
{
return StiLocalization.Get("Report", "Components");
}
}
///
/// Gets a localized component name.
///
public override string LocalizedName
{
get
{
return "MyCustomComponent1";
}
}
#endregion
#region Render override
///
/// Rendering of the component without events.
///
/// Rendered component.
/// Panel in which rendering will be done.
/// Is rendering finished or not.
protected override bool RenderComponent(ref StiComponent renderedComponent, StiContainer outContainer)
{
MyCustomComponent component = (MyCustomComponent)this.Clone();
component.InvokeEvents();
outContainer.Components.Add(component);
renderedComponent = component;
return true;
}
#endregion
#region IStiBorder
private StiBorder border = new StiBorder();
///
/// Gets or sets frame of the component.
///
[StiCategory("Appearance")]
[StiSerializable]
[Description("Gets or sets frame of the component.")]
public StiBorder Border
{
get
{
return border;
}
set
{
border = value;
}
}
#endregion
#region IStiBrush
private StiBrush brush = new StiSolidBrush(Color.Transparent);
///
/// Gets or sets a brush to fill a component.
///
[StiCategory("Appearance")]
[StiSerializable]
[Description("Gets or sets a brush to fill a component.")]
public StiBrush Brush
{
get
{
return brush;
}
set
{
brush = value;
}
}
#endregion
#region Paint
///
/// Paints a component.
///
/// Argument for painting.
public override void Paint(StiPaintEventArgs e)
{
InvokePainting(this, e);
if (!e.Cancel)
{
Graphics g = e.Graphics;
RectangleD rect = GetPaintRectangle();
if (rect.Width > 0 && rect.Height > 0 && (e.ClipRectangle.IsEmpty || rect.IntersectsWith(e.ClipRectangle)))
{
//#region Fill rectangle
//if (this.Brush is StiSolidBrush &&
// ((StiSolidBrush)this.Brush).Color == Color.Transparent &&
// Report.Info.FillComponent &&
// IsDesigning)
//{
// Color color = Color.FromArgb(150, Color.Green);
// StiDrawing.FillRectangle(g, color, rect.Left, rect.Top, rect.Width, rect.Height);
//}
//else StiDrawing.FillRectangle(g, Brush, rect);
//#endregion
//******************
//Draw control
//******************
//wtc.Width = (int)rect.Width;
//wtc.Height = (int)rect.Height;
#region Markers
PaintMarkers(g, rect);
#endregion
#region Border
if (this.HighlightState == StiHighlightState.Hide)
Border.Draw(g, rect, Page.Zoom);
#endregion
System.IO.MemoryStream ms = new System.IO.MemoryStream(wtc.get_png((int)rect.Width, (int)rect.Height, 100));
e.Graphics.DrawImage(new Bitmap(ms), (int)rect.Location.X, (int)rect.Location.Y);
PaintEvents(e.Graphics, rect);
}
}
//e.Cancel = false;
InvokePainted(this, e);
}
#endregion
#region ICloneable override
///
/// Creates a new object that is a copy of the current instance.
///
/// A new object that is a copy of this instance.
public override object Clone()
{
return base.Clone();
}
#endregion
#region this
///
/// Creates a new component of the type MyCustomComponent.
///
public MyCustomComponent() : this(RectangleD.Empty)
{
}
///
/// Creates a new component of the type MyCustomComponent.
///
/// The rectangle describes size and position of the component.
public MyCustomComponent(RectangleD rect) : base(rect)
{
}
#endregion
}
}
Code: Select all
wtc.set_bin_data((byte[])DatabaseValueGoesHere);