Beispiel #1
0
        protected override void OnBeginPrint(PrintContext context)
        {
            layout = PangoUtil.CreateLayout(context);
            layout.FontDescription = settings.Font;

            using (var PangoContext = context.CreatePangoContext())
                using (var metrics = PangoContext.GetMetrics(settings.Font, PangoContext.Language)) {
                    lineHeight = Math.Ceiling(0.5 + (metrics.Ascent + metrics.Descent) / Pango.Scale.PangoScale);
                }

            SetHeaderFormat(settings.HeaderFormat);
            SetFooterFormat(settings.FooterFormat);

            style = SyntaxHighlightingService.GetEditorTheme(settings.EditorTheme);

            pageWidth  = context.PageSetup.GetPageWidth(Unit.Pixel);
            pageHeight = context.PageSetup.GetPageHeight(Unit.Pixel);
            double contentHeight = pageHeight
                                   - (headerLines > 0? settings.HeaderPadding : 0)
                                   - (footerLines > 0? settings.FooterPadding : 0);

            linesPerPage = (int)(contentHeight / lineHeight) - (headerLines + footerLines);
            totalPages   = (int)Math.Ceiling((double)editor.LineCount / linesPerPage);

            NPages = totalPages;

            base.OnBeginPrint(context);
        }