Stimulsoft Reports.WPF教程:Designer中的自定义组件

本文主要介绍Stimulsoft报表Designer中的自定义组件。

【下载Stimulsoft Reports.WPF最新版本】

此示例显示如何将自定义组件添加到Designer。为此,您应该创建自定义组件的新类。例如,创建从StiComponent继承的MyCustomComponent类。还要为新组件定义BorderBrush属性:

[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    ////// Gets value to sort a position in the toolbox.    ///public override int ToolboxPosition    {        get        {            return 500;        }    }     public override StiToolboxCategory ToolboxCategory    {        get        {            return StiToolboxCategory.Components;        }    }     ////// 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 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 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)    {        PlaceOnToolbox = true;    }    #endregion}

要将自定义组件添加到Designer工具箱,只需向StiConfig.Services集合添加一个类。此外,应将此类添加到StiConfig.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();}

示例代码的结果如下图所示:

Stimulsoft

下载示例

购买Stimulsoft正版授权,请点击“咨询在线客服”哟!

FastReport2018.4

标签:报表解决方案报表报表控件WPF报表设计Stimulsoftstimulsoft reports.wpf

来源:慧都

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2018年8月16日
下一篇 2018年8月16日

相关推荐

发表回复

登录后才能评论