Form1.cs

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace CoolPrintPreview
{
    public partial class Form1 : Form
    {
        DateTime _start;
        int _page = 0;
        Font _font = new Font("Segoe UI", 14);

        public Form1()
        {
            InitializeComponent();
        }

        void printDocument1_BeginPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            _start = DateTime.Now;
            _page = 0;
        }
        void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            // fill page with text
            Rectangle rc = e.MarginBounds;
            rc.Height = _font.Height + 10;
            for (int i = 0; ; i++)
            {
                var text = string.Format("line {0} on page {1}", i + 1, _page + 1);
                e.Graphics.DrawString(text, _font, Brushes.Black, rc);
                rc.Y += rc.Height;
                if (rc.Bottom > e.MarginBounds.Bottom)
                {
                    break;
                }
            }
                
            // move on to next page
            _page++;
            e.HasMorePages = _chkLongDoc.Checked
                ? _page < 3000
                : _page < 30;
        }
        void printDocument1_EndPrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            Console.WriteLine("Document rendered in {0} ms", 
                DateTime.Now.Subtract(_start).TotalMilliseconds);
        }

        // show standard print preview
        void button1_Click(object sender, EventArgs e)
        {
            using (var dlg = new PrintPreviewDialog())
            {
                dlg.Document = this.printDocument1;
后面还有 15 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。