From e675a1ca4a59aba9412c771fd9097a1897a042aa Mon Sep 17 00:00:00 2001 From: Kathy Date: Wed, 29 May 2013 14:57:47 +0000 Subject: [PATCH] Add asterisk for boxes for IP2/IP3 cautions --- PROMS/Volian.Print.Library/vlnBox.cs | 124 ++++++++++++++++++--------- 1 file changed, 84 insertions(+), 40 deletions(-) diff --git a/PROMS/Volian.Print.Library/vlnBox.cs b/PROMS/Volian.Print.Library/vlnBox.cs index fff24d57..70b08afb 100644 --- a/PROMS/Volian.Print.Library/vlnBox.cs +++ b/PROMS/Volian.Print.Library/vlnBox.cs @@ -42,6 +42,8 @@ namespace Volian.Print.Library const string BoxFPLNote = "\x2557.\x2550\xad.\x2554\xad.\x2551. . .\x255d.\x255a\xad. .\x2550\xad. . "; const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . "; const string BoxAsterisk = " *.* .* . . . . *.* . .* . . "; + const string BoxAsteriskWithSides1 = " *.* .* .* . . . *.* . .* . . "; // ip2 + const string BoxAsteriskWithSides2 = "*. *.*.*. . .*.*. . *. . "; // ip3 (sub 15) public override float ToPdf(PdfContentByte cb, float yPageStart, ref float yTopMargin, ref float yBottomMargin) { @@ -102,46 +104,12 @@ namespace Volian.Print.Library cb.Rectangle(left + llxOffset, bottom - YbxAdjust + (lineThickness / 2), right - left, (Height - lineThickness + 2*YbxAdjust) * MyPageHelper.YMultiplier); break; case BoxAsterisk: - // this box is not drawn, it is a series of asterisks drawn above and below text. - // For this box, there are no vertical edges (RGE uses this box type) - top = CalculateYOffset(yPageStart, yTopMargin); - // Bug fix B2013-091 - // added YMultiplier to handle compress pages - // bottom row of asterisks was in non-compressed line location - bottom = top - (Height * MyPageHelper.YMultiplier);//Height; - VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font; - - // Top line first: - StringBuilder sb = new StringBuilder(); - sb.Append(MyBox.BXULC); - float size = (float)(MyBox.BXULC.Length * (72/vf.CPI)); - while (size < MyBox.End) - { - sb.Append(MyBox.BXHorz); - size = size + (float)(MyBox.BXHorz.Length * (72/vf.CPI)); - } - // Tack on the right upper corner. For some reason, the upper right corner in the - // formats had the first character as a space, this would put two spaces in a row - // at the end of the string, so remove the space before tacking on the upper right - // corner: - string bxstr = sb.ToString().TrimEnd() + MyBox.BXURC; - size = size + (float)((MyBox.BXURC.Length) * (72/vf.CPI)); - Rtf = GetRtf(bxstr, vf); - Rtf2Pdf.TextAt(cb, IParagraph, left, top, size, 100, "", yBottomMargin); - - // Bottom line now - sb.Remove(0, sb.Length); - sb.Append(MyBox.BXLLC); - size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI)); - while (size < MyBox.End) - { - sb.Append(MyBox.BXHorz); - size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI)); - } - bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; - size = size + (float)((MyBox.BXLRC.Length) * (72/vf.CPI)); - Rtf = GetRtf(bxstr, vf); - Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size, 100, "", yBottomMargin); + DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left); + break; + case BoxAsteriskWithSides1: + case BoxAsteriskWithSides2: + DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left); + DrawAsteriskSide(cb, yPageStart, yTopMargin, yBottomMargin, top, bottom, left, right); break; default: // For other than thick, thin and double. @@ -161,6 +129,82 @@ namespace Volian.Print.Library return yPageStart; } + private void DrawAsteriskTopBottom(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, ref float top, ref float bottom, float left) + { + // this box is not drawn, it is a series of asterisks drawn above and below text. + // For this box, there are no vertical edges (RGE uses this box type) + top = CalculateYOffset(yPageStart, yTopMargin); + // Bug fix B2013-091 + // added YMultiplier to handle compress pages + // bottom row of asterisks was in non-compressed line location + bottom = top - (Height * MyPageHelper.YMultiplier);//Height; + + // create a new font without any styles such as underline. + VE_Font vf = new VE_Font(MyParent.MyItemInfo.FormatStepData.Font.Family, (int)MyParent.MyItemInfo.FormatStepData.Font.Size, E_Style.None, (float)MyParent.MyItemInfo.FormatStepData.Font.CPI); + + // Top line first: + StringBuilder sb = new StringBuilder(); + sb.Append(MyBox.BXULC); + float size = (float)(MyBox.BXULC.Length * (72 / vf.CPI)); + while (size < (MyBox.End - MyBox.Start)) + { + sb.Append(MyBox.BXHorz); + size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + } + // Tack on the right upper corner. For some reason, the upper right corner in the + // formats had the first character as a space, this would put two spaces in a row + // at the end of the string, so remove the space before tacking on the upper right + // corner: + string bxstr = sb.ToString().TrimEnd() + MyBox.BXURC; + size = size + (float)((MyBox.BXURC.Length) * (72 / vf.CPI)); + Rtf = GetRtf(bxstr, vf); + IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. + Rtf2Pdf.TextAt(cb, IParagraph, left, top, size, 100, "", yBottomMargin); + + // Bottom line now + sb.Remove(0, sb.Length); + sb.Append(MyBox.BXLLC); + size = (float)(MyBox.BXLLC.Length * (72 / vf.CPI)); + while (size < (MyBox.End-MyBox.Start)) + { + sb.Append(MyBox.BXHorz); + size = size + (float)(MyBox.BXHorz.Length * (72 / vf.CPI)); + } + bxstr = sb.ToString().TrimEnd() + MyBox.BXLRC; + size = size + (float)((MyBox.BXLRC.Length) * (72 / vf.CPI)); + Rtf = GetRtf(bxstr, vf); + IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. + Rtf2Pdf.TextAt(cb, IParagraph, left, bottom, size, 100, "", yBottomMargin); + } + private void DrawAsteriskSide(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin, float top, float bottom, float left, float right) + { + top = CalculateYOffset(yPageStart, yTopMargin); + bottom = top - (Height * MyPageHelper.YMultiplier); + float height = (SixLinesPerInch * MyPageHelper.YMultiplier) + 4; // just add a little on so that height is a little bigger than character + VE_Font vf = MyParent.MyItemInfo.FormatStepData.Font; + + // Left side first: + Rtf = GetRtf(MyBox.BXVert, vf); + IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. + // start down one line because the top/bottom code draws the corner + float vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier); + float width = (float)(MyBox.BXVert.Length * (72 / vf.CPI)); + while (vertDiff > bottom) + { + Rtf2Pdf.TextAt(cb, IParagraph, left, vertDiff, width, height, "", yBottomMargin); + vertDiff -= (SixLinesPerInch * MyPageHelper.YMultiplier); + } + + // right side: + vertDiff = top - (SixLinesPerInch * MyPageHelper.YMultiplier); + Rtf = GetRtf(MyBox.BXVert.TrimEnd(), vf); + IParagraph = null; // set to null so that next access of IParagraph sets the Rtf. + while (vertDiff > bottom) + { + Rtf2Pdf.TextAt(cb, IParagraph, right, vertDiff, width, height, "", yBottomMargin); + vertDiff -= (SixLinesPerInch * MyPageHelper.YMultiplier); + } + } private string ShowBoxStyle(string str) { StringBuilder sb = new StringBuilder();