Exemplo n.º 1
0
    public static void PrintPreview()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;
        Print_HeaderFooter_Manager.Init();

        PreviewDlg.ShowDialog();
    }
Exemplo n.º 2
0
    public static void Print()
    {
        DocumentName = TabManager.GetFilename();
        Content      = TabManager.GetText();

        PrintDoc.DocumentName = DocumentName;
        Print_HeaderFooter_Manager.Init();

        DialogResult OK = PrintDlg.ShowDialog();

        if (OK == DialogResult.OK)
        {
            PrintDoc.Print();
        }
    }
Exemplo n.º 3
0
    private static void OnPrintPage(object Obj, PrintPageEventArgs EA)
    {
        Graphics Grfx      = EA.Graphics;
        Font     PrintFont = FontManager.GetPrinting();

        Rectangle PrintArea = new Rectangle();

        PrintArea = EA.MarginBounds;

        float FontHeight = PrintFont.GetHeight(Grfx);

        Print_HeaderFooter_Manager.Refresh();

        if (Print_HeaderFooter_Manager.HasHeader())
        {
            Rectangle Rect = new Rectangle();

            Rect.X      = PrintArea.X;
            Rect.Y      = PrintArea.Y;
            Rect.Width  = PrintArea.Width;
            Rect.Height = (int)(2 * FontHeight);

            PrintArea.Y      = PrintArea.Y + Rect.Height;
            PrintArea.Height = PrintArea.Height - Rect.Height;

            StringFormat StrFmt = new StringFormat();

            StrFmt.LineAlignment = StringAlignment.Near;

            StrFmt.Alignment = StringAlignment.Near;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_TopLeft(),
                            PrintFont, Brushes.Black, Rect, StrFmt);

            StrFmt.Alignment = StringAlignment.Far;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_TopRight(),
                            PrintFont, Brushes.Black, Rect, StrFmt);
        }


        if (Print_HeaderFooter_Manager.HasFooter())
        {
            Rectangle Rect = new Rectangle();

            Rect.Height = (int)(2 * FontHeight);
            Rect.X      = PrintArea.X;
            Rect.Y      = PrintArea.Bottom - Rect.Height;
            Rect.Width  = PrintArea.Width;

            PrintArea.Height = PrintArea.Height - Rect.Height;

            StringFormat StrFmt = new StringFormat();

            StrFmt.LineAlignment = StringAlignment.Far;

            StrFmt.Alignment = StringAlignment.Near;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_BottomLeft(),
                            PrintFont, Brushes.Black, Rect, StrFmt);

            StrFmt.Alignment = StringAlignment.Far;
            Grfx.DrawString(Print_HeaderFooter_Manager.Get_BottomRight(),
                            PrintFont, Brushes.Black, Rect, StrFmt);
        }

        int TotalLines = (int)Math.Floor(PrintArea.Height / FontHeight);

        PrintArea.Height = (int)(TotalLines * FontHeight);

        StringFormat PageFmt = new StringFormat();

        PageFmt.Trimming     = StringTrimming.EllipsisCharacter;
        PageFmt.FormatFlags |= StringFormatFlags.NoWrap;

        int Chars;
        int Lines;

        Grfx.MeasureString(Content, PrintFont, PrintArea.Size,
                           PageFmt, out Chars, out Lines);

        Grfx.DrawString(Content, PrintFont, Brushes.Black,
                        PrintArea, PageFmt);

        Content = Content.Substring(Chars);

        if (Content.Length == 0)
        {
            Content = TabManager.GetText();
        }
        else
        {
            EA.HasMorePages = true;
        }
    }