Custom Component in the Designer
Unsere Beispiele der Projekte und Berichtsvorlagen helfen Ihnen, die Grundlagen der Arbeit mit unserer Software zu erlernen.Dieses Beispiel ist veraltet, checken Sie viele anderen aktualisierten Beispiele in dieser Kategorie aus.This example shows how to add a Custom Component to the Designer. For this, you should create a new class of the Custom Component. For example, create the
To add the Custom Component to the Designer Toolbox, it is enough to add a class to the
MyCustomComponent class inherited from the StiComponent. Also define the Border and Brush properties for the new component:
[StiToolbox(true)]
[StiContextTool(typeof(IStiShift))]
[StiContextTool(typeof(IStiGrowToHeight))]
[StiV1Builder(typeof(MyCustomComponentV1Builder))]
[StiV2Builder(typeof(MyCustomComponentV2Builder))]
[StiWpfPainter(typeof(MyCustomComponentWpfPainter))]
public class MyCustomComponent : StiComponent, IStiBorder, IStiBrush
{
#region StiComponent override
/// <summary>
/// Gets value to sort a position in the toolbox.
/// </summary>
public override int ToolboxPosition
{
get
{
return 500;
}
}
public override StiToolboxCategory ToolboxCategory
{
get
{
return StiToolboxCategory.Components;
}
}
/// <summary>
/// Gets a localized name of the component category.
/// </summary>
public override string LocalizedCategory
{
get
{
return StiLocalization.Get("Report", "Components");
}
}
/// <summary>
/// Gets a localized component name.
/// </summary>
public override string LocalizedName
{
get
{
return "MyCustomComponent1";
}
}
#endregion
#region IStiBorder
private StiBorder border = new StiBorder();
/// <summary>
/// Gets or sets frame of the component.
/// </summary>
[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);
/// <summary>
/// Gets or sets a brush to fill a component.
/// </summary>
[StiCategory("Appearance")]
[StiSerializable]
[Description("Gets or sets a brush to fill a component.")]
public StiBrush Brush
{
get
{
return brush;
}
set
{
brush = value;
}
}
#endregion
#region this
/// <summary>
/// Creates a new component of the type MyCustomComponent.
/// </summary>
public MyCustomComponent() : this(RectangleD.Empty)
{
}
/// <summary>
/// Creates a new component of the type MyCustomComponent.
/// </summary>
/// <param name="rect">The rectangle describes size and position of the component.</param>
public MyCustomComponent(RectangleD rect) : base(rect)
{
PlaceOnToolbox = true;
}
#endregion
}
To add the Custom Component to the Designer Toolbox, it is enough to add a class to the
StiConfig.Services collection. Also, this class should be added into the StiConfig.Engine collection for its recognition of the report engine:
public Window1()
{
StiOptions.Wpf.CurrentTheme = StiOptions.Wpf.Themes.Office2013Theme;
InitializeComponent();
AddCustomComponent();
}
private static void AddCustomComponent()
{
StiConfig.Load();
StiOptions.Engine.ReferencedAssemblies = new string[] {
"System.Dll",
"System.Drawing.Dll",
"System.Windows.Forms.Dll",
"System.Data.Dll",
"System.Xml.Dll",
"Stimulsoft.Base.Dll",
"Stimulsoft.Report.Dll",
#region Add reference to your assembly
"CustomComponent.Wpf.exe"
#endregion
};
StiConfig.Services.Add(new MyCustomComponent());
StiConfig.Save();
}