Beispiel #1
0
        public PrinterHint GetHeader(int pagewidth,string text)
        {
            int captionHeight = 45;
            Font font = new Font("����",20);
            Graphics g=this.button1.CreateGraphics();
            int height=(int)g.MeasureString(text, font).Height;
            int width = (int)g.MeasureString(text, font).Width;
            g.Dispose();
            PrinterHint header = new PrinterHint();
            header.Rectangle = new Rectangle(0, 0, pagewidth, height + captionHeight+12);
            header.PrintInEveryPage = true;
            header.Border = BordersEdgeStyle.None;
            TitleDraw title = new TitleDraw(text);
            title.Font = font;
            title.Rectangle = new Rectangle((pagewidth-width)/2, 0, width, height);
            title.Border = BordersEdgeStyle.Bottom;

            TitleDraw line = new TitleDraw("");
            line.Rectangle = new Rectangle((pagewidth - width) / 2, 2, width, height);
            line.Border = BordersEdgeStyle.Bottom;
            header.Add(title);
            header.Add(line);

            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;
            Font cap = new Font("����", 14);
            TextDraw header2 = new TextDraw("��ѵ��λ��                �������ͣ�          �������ڣ�      ��   ��   ��");
            header2.Formater = sf;
            header2.Font = cap;
            header2.Rectangle = new Rectangle(0, height + 7, pagewidth, captionHeight);

            header2.Border = BordersEdgeStyle.None;
            CompanyInfo compInfo = StaticCacheManager.GetConfig<CompanyInfo>();

            TextDraw comp = new TextDraw(compInfo.NickName);
             comp.Formater = sf;
             comp.Font = cap;
             comp.Rectangle = new Rectangle(100, height + 7, 200, captionHeight);
            comp.Border = BordersEdgeStyle.None;
            header.Add(comp);
            header.Add(header2);
            return header;
        }
        protected virtual PrinterHint BuildHeader()
        {
            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Far;
            sf.Alignment = StringAlignment.Far;

            StringFormat sf2 = new StringFormat();
            sf2.LineAlignment = StringAlignment.Center;
            sf2.Alignment = StringAlignment.Center;

            CompanyInfo comp = StaticCacheManager.GetConfig<CompanyInfo>();

            int pagewidth = customMargin.Width;
            int captionHeight = 70;
            Font font = new Font("����", 20);
            Font cap = new Font("����", 14);
            int height = 25;
            PrinterHint header = new PrinterHint();
            header.Rectangle = new Rectangle(0, 0, pagewidth, height + captionHeight + 12);
            header.PrintInEveryPage = false;
            header.Border = BordersEdgeStyle.None;
            //��ӡ��λ����
            TitleDraw title = new TitleDraw(comp.NickName+" "+System.DateTime.Now.ToShortDateString());
            title.Font = cap;
            title.Rectangle = new Rectangle(0, 0, pagewidth, height);
            title.Border = BordersEdgeStyle.None;
            title.Formater = sf;
            //��ӡ������
            TitleDraw titleMain = new TitleDraw(this.headerTitle);
            titleMain.Font = font;
            titleMain.Rectangle = new Rectangle(0, height, pagewidth, captionHeight);
            titleMain.Border = BordersEdgeStyle.None;
            titleMain.Formater = sf2;
            header.Add(title);
            header.Add(titleMain);
            return header;
        }