彩票走势图

【Stimulsoft Reports.WinForms教程】使用报表页面画布获取版权

翻译|使用教程|编辑:王香|2018-09-04 11:40:25.000|阅读 246 次

概述:本文主要讲解在Stimulsoft中Designer保存和加载报表。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

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

此示例显示如何在报表页面上放置水印,页面上的水印可以是文本,表达的结果或图像。水印也可以放在页面的任何位置。在此示例中,我们将添加文本水印。为此,我们使用报表的绘图页面事件:

static void Main() 
{
    StiPage.PagePainting += new StiPagePaintEventHandler(OnPagePainting);
    StiPage.PagePainted += new StiPagePaintEventHandler(OnPagePainted);
 
    Application.EnableVisualStyles();
    Application.Run(new Form1());
}
 
private static void OnPagePainting(StiPage sender, StiPagePaintEventArgs e)
{
    if (copyrightPosition == Position.Behind)
    {
        StiPage page = sender as StiPage;
        DrawCopyright(page, e);
    }
}
 
private static void OnPagePainted(StiPage sender, StiPagePaintEventArgs e)
{
    if (copyrightPosition == Position.Front)
    {
        StiPage page = sender as StiPage;
        DrawCopyright(page, e);
    }
}

渲染水印的方法如下:

private static void DrawCopyright(StiPage page, StiPagePaintEventArgs e)
{
    if (e.IsPrinting && (!printer))return;
    if (e.IsDesigning && (!designer))return;
    if ((!e.IsDesigning) && (!e.IsPrinting) && (!preview))return;
 
    Rectangle rect = e.FullRectangle;
    if (rectClient)rect = e.ClientRectangle;
 
    using (Font font = new Font("Arial", 20 * (float)page.Zoom))
    using (StringFormat sf = new StringFormat())
    {
        switch (copyrightPlace)
        {
            case Place.TopLeft:
                sf.Alignment = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Near;
                break;
 
            case Place.TopRight:
                sf.Alignment = StringAlignment.Far;
                sf.LineAlignment = StringAlignment.Near;
                break;
 
            case Place.Center:
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                break;
 
            case Place.BottomLeft:
                sf.Alignment = StringAlignment.Near;
                sf.LineAlignment = StringAlignment.Far;
                break;
 
            case Place.BottomRight:
                sf.Alignment = StringAlignment.Far;
                sf.LineAlignment = StringAlignment.Far;
                break;
        }
 
        e.Graphics.DrawString(copyrightString, font, Brushes.Red, rect, sf);
    }
}

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

Stimulsoft


标签:报表解决方案报表报表控件报表设计StimulsoftWinForms

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP