Add asterisk for boxes for IP2/IP3 cautions

This commit is contained in:
Kathy Ruffing 2013-05-29 14:57:47 +00:00
parent 7427c75caa
commit e675a1ca4a

View File

@ -42,6 +42,8 @@ namespace Volian.Print.Library
const string BoxFPLNote = "\x2557.\x2550\xad.\x2554\xad.\x2551. . .\x255d.\x255a\xad. .\x2550\xad. . "; 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 BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . ";
const string BoxAsterisk = " *.* .* . . . . *.* . .* . . "; 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) 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); cb.Rectangle(left + llxOffset, bottom - YbxAdjust + (lineThickness / 2), right - left, (Height - lineThickness + 2*YbxAdjust) * MyPageHelper.YMultiplier);
break; break;
case BoxAsterisk: case BoxAsterisk:
// this box is not drawn, it is a series of asterisks drawn above and below text. DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
// For this box, there are no vertical edges (RGE uses this box type) break;
top = CalculateYOffset(yPageStart, yTopMargin); case BoxAsteriskWithSides1:
// Bug fix B2013-091 case BoxAsteriskWithSides2:
// added YMultiplier to handle compress pages DrawAsteriskTopBottom(cb, yPageStart, yTopMargin, yBottomMargin, ref top, ref bottom, left);
// bottom row of asterisks was in non-compressed line location DrawAsteriskSide(cb, yPageStart, yTopMargin, yBottomMargin, top, bottom, left, right);
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);
break; break;
default: default:
// For other than thick, thin and double. // For other than thick, thin and double.
@ -161,6 +129,82 @@ namespace Volian.Print.Library
return yPageStart; 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) private string ShowBoxStyle(string str)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();