Modifications in Output.Printers.Zapiska, multiple-line headers are possible, ver. 2.17.731
This commit is contained in:
parent
a2620870ad
commit
6d616ca4cc
@ -202,7 +202,7 @@ namespace Results.Output.Printers.Zapiska
|
||||
///----------
|
||||
/// Title
|
||||
///----------
|
||||
int titleWid = (int)(e.Graphics.MeasureString(header, titleFont).Width + 1);
|
||||
int titleWid = System.Windows.Forms.TextRenderer.MeasureText(header, titleFont).Width + 1;
|
||||
RectangleF printArea = new RectangleF(cfg.LeftMargin + Math.Max(0, (printWidth - titleWid)) / 2, cfg.TopMargin,
|
||||
titleWid, titleHeight);
|
||||
e.Graphics.DrawString(header, titleFont, Brushes.Black, printArea);
|
||||
@ -242,7 +242,7 @@ namespace Results.Output.Printers.Zapiska
|
||||
string[] lines = paragraph.Split(new char[] { '~' });
|
||||
foreach (var line in lines)
|
||||
{
|
||||
int itemWidth = (int)e.Graphics.MeasureString(paragraph, font).Width;
|
||||
int itemWidth = Measure(paragraph, this.font).Width + 1;
|
||||
if (itemWidth > leftColWidth) leftColWidth = itemWidth;
|
||||
}
|
||||
}
|
||||
@ -250,8 +250,8 @@ namespace Results.Output.Printers.Zapiska
|
||||
/// Write aligned columns
|
||||
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
|
||||
{
|
||||
PrintAt(e, lMargin, CommonTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, CommonTop + SpacingOne * i, rightColumn[i]);
|
||||
PrintAt(e, lMargin, CommonTop + SpacingOne * i, leftColWidth, leftColumn[i], this.font, commonItems[i].Alignment);
|
||||
PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, CommonTop + SpacingOne * i, 0, rightColumn[i], this.font, Alignment.Left);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,7 +306,7 @@ namespace Results.Output.Printers.Zapiska
|
||||
string[] lines = paragraph.Split(new char[] { '~' });
|
||||
foreach (var line in lines)
|
||||
{
|
||||
int itemWidth = (int)e.Graphics.MeasureString(paragraph, font).Width;
|
||||
int itemWidth = System.Windows.Forms.TextRenderer.MeasureText(paragraph, font).Width + 1;
|
||||
if (itemWidth > leftColWidth) leftColWidth = itemWidth;
|
||||
}
|
||||
}
|
||||
@ -314,20 +314,20 @@ namespace Results.Output.Printers.Zapiska
|
||||
/// Write aligned columns
|
||||
for (int i = 0; i < Math.Min(leftColumn.Length, rightColumn.Length); i++)
|
||||
{
|
||||
PrintAt(e, lMargin, nextTableTop + SpacingOne * i, leftColumn[i]);
|
||||
PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, nextTableTop + SpacingOne * i, rightColumn[i]);
|
||||
PrintAt(e, lMargin, nextTableTop + SpacingOne * i, leftColWidth, leftColumn[i], this.font, belowItems[i].Alignment);
|
||||
PrintAt(e, lMargin + leftColWidth + GapBetweenCommonColumns, nextTableTop + SpacingOne * i, 0, rightColumn[i], this.font, Alignment.Left);
|
||||
}
|
||||
}
|
||||
|
||||
///----------
|
||||
/// Footer
|
||||
///----------
|
||||
int footerWidth = (int)e.Graphics.MeasureString(footer, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, footer);
|
||||
int footerWidth = Measure(footer, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - footerWidth) / 2, topMargin + printHeight - 2 * SpacingOne, 0, footer, font, Alignment.Left);
|
||||
|
||||
string pageNrText = string.Format("{0} {1}/{2}", Strings.Page, pageNr++, nrPages);
|
||||
int pageNrWidth = (int)e.Graphics.MeasureString(pageNrText, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, pageNrText);
|
||||
int pageNrWidth = System.Windows.Forms.TextRenderer.MeasureText(pageNrText, font).Width;
|
||||
PrintAt(e, leftMargin + (printWidth - pageNrWidth) / 2, topMargin + printHeight - SpacingOne, 0, pageNrText, font, Alignment.Left);
|
||||
}
|
||||
|
||||
|
||||
@ -344,12 +344,17 @@ namespace Results.Output.Printers.Zapiska
|
||||
/// Determine column widths
|
||||
WMeterRsltItemSpec.TableRowNr = 99;
|
||||
WMeterRsltItemSpec.TableColumnNr = 99;
|
||||
float[] columnPos = new float[selectedItems.Count + 1];
|
||||
columnPos[0] = (float)leftMargin;
|
||||
int[] columnWidth = new int[selectedItems.Count];
|
||||
int[] columnPos = new int[selectedItems.Count + 1];
|
||||
int headerHeight = 0;
|
||||
columnPos[0] = leftMargin;
|
||||
|
||||
for (int i = 0; i < selectedItems.Count; i++)
|
||||
{
|
||||
float columnWidth = e.Graphics.MeasureString(selectedItems[i].Caption, headerFont).Width;
|
||||
Size size = Measure(selectedItems[i].Caption, headerFont);
|
||||
columnWidth[i] = size.Width + 1;
|
||||
if (size.Height > headerHeight) headerHeight = size.Height;
|
||||
|
||||
foreach (var wm in wms)
|
||||
{
|
||||
if (!cfg.GoodOnly || wm.Passed)
|
||||
@ -360,11 +365,11 @@ namespace Results.Output.Printers.Zapiska
|
||||
string[] texts = itemText.Split(new char[] { '|' });
|
||||
if (texts.Length == 2) { itemText = texts[0]; }
|
||||
|
||||
float width = e.Graphics.MeasureString(itemText, font).Width;
|
||||
if (width > columnWidth) columnWidth = width;
|
||||
int width = Measure(itemText, font).Width + 1;
|
||||
if (width > columnWidth[i]) columnWidth[i] = width;
|
||||
}
|
||||
}
|
||||
columnPos[i + 1] = columnPos[i] + columnWidth + (float)GapBetweenTableColumns;
|
||||
columnPos[i + 1] = columnPos[i] + columnWidth[i] + GapBetweenTableColumns;
|
||||
}
|
||||
int tableLeftX = (int)columnPos[0];
|
||||
int tableRightX = (int)columnPos[selectedItems.Count] - GapBetweenTableColumns;
|
||||
@ -375,19 +380,19 @@ namespace Results.Output.Printers.Zapiska
|
||||
|
||||
for (int i = 0; i < selectedItems.Count; i++)
|
||||
{
|
||||
PrintHeaderAt(e, (int)columnPos[i], top + (int)(1.6 * SpacingOne4Header), selectedItems[i].Caption);
|
||||
PrintAt(e, (int)columnPos[i], top + (int)(1.7 * SpacingOne4Header), columnWidth[i], selectedItems[i].Caption, this.headerFont, Alignment.Center);
|
||||
}
|
||||
|
||||
/// Horizontal line
|
||||
horY = top + (int)(2.8 * SpacingOne4Header);
|
||||
horY = top + 21 * SpacingOne4Header / 10 + headerHeight;
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
||||
|
||||
int rowsCount = 0;
|
||||
foreach (var wm in wms)
|
||||
{
|
||||
rowsCount++;
|
||||
if (!cfg.GoodOnly || wm.Passed)
|
||||
{
|
||||
WMeterRsltItemSpec.TableRowNr = ++rowsCount;
|
||||
WMeterRsltItemSpec.TableRowNr = rowsCount;
|
||||
|
||||
for (int i = 0; i < selectedItems.Count; i++)
|
||||
{
|
||||
@ -404,50 +409,67 @@ namespace Results.Output.Printers.Zapiska
|
||||
/// TODO: How to print colors?
|
||||
}
|
||||
|
||||
PrintAt(e, (int)columnPos[i], top + 2 * SpacingOne4Header + SpacingOne * rowsCount, itemText);
|
||||
PrintAt(e, (int)columnPos[i], horY + (3 * SpacingOne4Header / 10) + SpacingOne * (rowsCount - 1), columnWidth[i], itemText, this.font, selectedItems[i].Alignment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Horizontal line
|
||||
horY = top + 2 * SpacingOneAndHalf4Header + SpacingOne * rowsCount;
|
||||
horY = horY + SpacingOne * rowsCount + (3 * SpacingOne4Header / 10);
|
||||
e.Graphics.DrawLine(new Pen(Color.Black, 2), new Point(tableLeftX, horY), new Point(tableRightX, horY));
|
||||
|
||||
return (rowsCount + 1) * SpacingOne + 3 * SpacingOne4Header;
|
||||
return horY - top + SpacingOne;
|
||||
}
|
||||
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string paragraph)
|
||||
{
|
||||
PrintAt(e, p.X, p.Y, paragraph);
|
||||
}
|
||||
static Font lastFont = null;
|
||||
static int lastSpacing = 0;
|
||||
|
||||
Size Measure(string paragraph, Font font)
|
||||
{
|
||||
if (font != lastFont)
|
||||
{
|
||||
lastFont = font;
|
||||
lastSpacing = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height;
|
||||
}
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string paragraph)
|
||||
{
|
||||
string[] lines = paragraph.Split(new char[] { '~' });
|
||||
int width = 0;
|
||||
foreach (var line in lines)
|
||||
{
|
||||
RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne);
|
||||
e.Graphics.DrawString(line, this.font, Brushes.Black, printArea);
|
||||
y += 8 * SpacingOne / 10;
|
||||
int lineWid = System.Windows.Forms.TextRenderer.MeasureText(line, font).Width;
|
||||
if (lineWid > width) width = lineWid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, Point p, string paragraph)
|
||||
{
|
||||
PrintHeaderAt(e, p.X, p.Y, paragraph);
|
||||
}
|
||||
|
||||
void PrintHeaderAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, string paragraph)
|
||||
{
|
||||
string[] lines = paragraph.Split(new char[] { '~' });
|
||||
foreach (var line in lines)
|
||||
{
|
||||
RectangleF printArea = new RectangleF(x, y, 2000, SpacingOne4Header);
|
||||
e.Graphics.DrawString(paragraph, this.headerFont, Brushes.Black, printArea);
|
||||
y += 8 * SpacingOne4Header / 10;
|
||||
}
|
||||
return new Size(width, (8 * lines.Length * lastSpacing + 2) / 10);
|
||||
}
|
||||
|
||||
|
||||
void PrintAt(System.Drawing.Printing.PrintPageEventArgs e, int x, int y, int width, string paragraph, Font font, Alignment alignment)
|
||||
{
|
||||
Size size = Measure(paragraph, font);
|
||||
|
||||
if (font != lastFont)
|
||||
{
|
||||
lastFont = font;
|
||||
lastSpacing = System.Windows.Forms.TextRenderer.MeasureText("Abcgq", font).Height;
|
||||
}
|
||||
|
||||
string[] lines = paragraph.Split(new char[] { '~' });
|
||||
foreach (var line in lines)
|
||||
{
|
||||
int xx;
|
||||
switch (alignment)
|
||||
{
|
||||
default:
|
||||
case Alignment.Left: xx = x; break;
|
||||
case Alignment.Center: xx = x + (width - System.Windows.Forms.TextRenderer.MeasureText(line, font).Width) / 2; break;
|
||||
case Alignment.Right: xx = x + width - System.Windows.Forms.TextRenderer.MeasureText(line, font).Width; break;
|
||||
}
|
||||
RectangleF printArea = new RectangleF(xx, y, 2000, lastSpacing);
|
||||
e.Graphics.DrawString(line, font, Brushes.Black, printArea);
|
||||
y += 8 * lastSpacing / 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("2.17.730.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.730.0")]
|
||||
[assembly: AssemblyVersion("2.17.731.0")]
|
||||
[assembly: AssemblyFileVersion("2.17.731.0")]
|
||||
|
||||
@ -472,10 +472,10 @@ namespace Results
|
||||
{
|
||||
result[i] = string.Format("{0}~{1}~{2}~{3}~{4}~{5}~{6}~{7}",
|
||||
items[i].Uid,
|
||||
items[i].Caption,
|
||||
items[i].Caption.Replace("~", "\n"),
|
||||
items[i].TestID,
|
||||
items[i].Units,
|
||||
items[i].Format,
|
||||
items[i].Format.Replace("~", "\n"),
|
||||
items[i].Precision,
|
||||
items[i].Width,
|
||||
items[i].Alignment);
|
||||
@ -536,14 +536,14 @@ namespace Results
|
||||
///
|
||||
/// Load the new style results item specification
|
||||
///
|
||||
item.Caption = field[1];
|
||||
item.Caption = field[1].Replace("\n", "~");
|
||||
item.TestID = field[2];
|
||||
item.Units = 0;
|
||||
for (Config.Unit u = 0; u < Config.Unit.Count; u++)
|
||||
{
|
||||
if (u.ToString().Equals(field[3])) { item.Units = u; break; }
|
||||
}
|
||||
item.Format = field[4];
|
||||
item.Format = field[4].Replace("\n", "~");
|
||||
item.Precision = field[5];
|
||||
item.Width = int.Parse(field[6]);
|
||||
item.Alignment = 0;
|
||||
|
||||
@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("2.17.730.1")]
|
||||
[assembly: AssemblyFileVersion("2.17.730.1")]
|
||||
[assembly: AssemblyVersion("2.17.731.1")]
|
||||
[assembly: AssemblyFileVersion("2.17.731.1")]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user