From 76a841bc84162b6bb8b1afed46b34f663604e4c3 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Fri, 23 Jun 2017 10:52:02 +0200 Subject: [PATCH] Output.PrintersEnhanced.EnhancedPrintDocument updated. --- .../Enhanced/EnhancedPrintDocument.cs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs index 8410bc62c..9ace759fc 100644 --- a/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs +++ b/Results/Output/Printers/Enhanced/EnhancedPrintDocument.cs @@ -23,8 +23,11 @@ namespace Results.Output.Printers.Enhanced readonly int leftMargin; readonly int TitleX; readonly int TitleY; /// Depends on the size of the header - readonly int HdrTop; /// = TitleY + 60 + readonly int CommonTop; /// = TitleY + 60 readonly int BodyTop; /// = HdrTop + 160 + /// + int titleHeight; + int commonHeight; /// Size of the printed area without margins, after taking into account 'pageOrientation' int printHeight; @@ -87,8 +90,13 @@ namespace Results.Output.Printers.Enhanced TitleX = leftMargin; TitleY = topMargin; /// Depends on the size of the header - HdrTop = TitleY + 60; - BodyTop = HdrTop + 160; + /// + int headerLinesCount = (header.Contains(Environment.NewLine)) ? 2 : 1; + titleHeight = headerLinesCount * 30 + 20; + CommonTop = TitleY + titleHeight; + + commonHeight = commonItems.Count * 20 + 20; + BodyTop = CommonTop + commonHeight; DefaultPageSettings.Landscape = (pageOrientation == PageOrientation.Landscape); @@ -165,7 +173,7 @@ namespace Results.Output.Printers.Enhanced ///---------- /// Header ///---------- - RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, 40); + RectangleF printArea = new RectangleF(TitleX, TitleY, printWidth, titleHeight); e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea); ///---------------- @@ -189,8 +197,8 @@ namespace Results.Output.Printers.Enhanced /// Write aligned columns for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++) { - PrintAt(e, leftMargin, HdrTop + SpacingOne * i, leftColumn[i]); - PrintAt(e, 300, HdrTop + SpacingOne * i, rightColumn[i]); + PrintAt(e, leftMargin, CommonTop + SpacingOne * i, leftColumn[i]); + PrintAt(e, 300, CommonTop + SpacingOne * i, rightColumn[i]); } }