Changed logic to properly output checkoff header "INITIALS"

This commit is contained in:
Rich 2014-11-12 06:41:47 +00:00
parent 10673521e5
commit 9eed40353e
2 changed files with 102 additions and 9 deletions

View File

@ -200,6 +200,7 @@ namespace Volian.Print.Library
//} //}
public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document) public override void OnEndPage(PdfWriter writer, iTextSharp.text.Document document)
{ {
InitialsPrinted = false;
MyPromsPrinter.OnStatusChanged(string.Format("Page {0}", CurrentPageNumber+1)); MyPromsPrinter.OnStatusChanged(string.Format("Page {0}", CurrentPageNumber+1));
bool onBlankPage = OnBlankPage; bool onBlankPage = OnBlankPage;
if (OnBlankPage) if (OnBlankPage)
@ -886,6 +887,8 @@ namespace Volian.Print.Library
mySvg.LeftMargin = (float)docStyle.Layout.LeftMargin; mySvg.LeftMargin = (float)docStyle.Layout.LeftMargin;
mySvg.TopMargin = 9.6F; mySvg.TopMargin = 9.6F;
VEPROMS.CSLA.Library.PageStyle pageStyle = docStyle.pagestyle; VEPROMS.CSLA.Library.PageStyle pageStyle = docStyle.pagestyle;
HasInitials = false;
PIInitials = null;
AddPageListItems(mySvg, pageStyle, mySection, forceLoad); AddPageListItems(mySvg, pageStyle, mySection, forceLoad);
mySvg.ProcessText += new SvgProcessTextEvent(mySvg_ProcessText); mySvg.ProcessText += new SvgProcessTextEvent(mySvg_ProcessText);
// if this section had a previous section and this is continuous, don't generate the svg for // if this section had a previous section and this is continuous, don't generate the svg for
@ -1693,11 +1696,24 @@ namespace Volian.Print.Library
// For Calvert: if this section has checkoffs turned on, put out this pagelist item: // For Calvert: if this section has checkoffs turned on, put out this pagelist item:
// Get SectionInfos to access specific section config items... // Get SectionInfos to access specific section config items...
//SectionInfo si = SectionInfo.Get(MySection.ItemID); //SectionInfo si = SectionInfo.Get(MySection.ItemID);
SectionInfo si = MySection.GetSectionInfo(); //SectionInfo si = MySection.GetSectionInfo();
SectionConfig sectCfg = si.MyConfig as SectionConfig; //SectionConfig sectCfg = si.MyConfig as SectionConfig;
int sc = sectCfg.Section_CheckoffListSelection; //int sc = sectCfg.Section_CheckoffListSelection;
if (sc < 2 && !si.HasStepCheckOffs) plstr = plstr.Replace(token, ""); if (!MySection.HasInitials)
else plstr = plstr.Replace(token, "INITIALS"); {
plstr = plstr.Replace(token, "");
//PIInitials = pageItem;
}
else
{
if (pageItem.Row == -MySection.MyDocStyle.Layout.TopMargin)
{
plstr = plstr.Replace(token, "");
PIInitials = pageItem;
}
else
plstr = plstr.Replace(token, "INITIALS");
}
break; break;
case "{REVUNIT}": case "{REVUNIT}":
// copied from 16bit's pagelist.cs for BGE: // copied from 16bit's pagelist.cs for BGE:
@ -1860,7 +1876,42 @@ namespace Volian.Print.Library
} }
return plstr; return plstr;
} }
private PageItem _PIInitials = null;
public PageItem PIInitials
{
get { return _PIInitials; }
set
{
if (_PIInitials != null && value == null)
_LastPIInitials = _PIInitials;
_PIInitials = value;
}
}
private PageItem _LastPIInitials = null;
public PageItem LastPIInitials
{
get { return _LastPIInitials; }
set { _LastPIInitials = value; }
}
private bool _HasInitials = false;
public bool HasInitials
{
get { return _HasInitials; }
set { _HasInitials = value; }
}
private bool _InitialsPrinted = false;
public bool InitialsPrinted
{
get { return _InitialsPrinted; }
set { _InitialsPrinted = value; }
}
public bool PrintInitials(PdfContentByte cb,float yLocation, float leftMargin)
{
if (InitialsPrinted) return false;
InitialsPrinted = true;
vlnParagraph.TextAt(cb,this, PIInitials ?? LastPIInitials, yLocation, leftMargin);
return true;
}
private void DoSpecialSectNumTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr) private void DoSpecialSectNumTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr)
{ {
// first add anything up to the "@@" to the svgGroup: // first add anything up to the "@@" to the svgGroup:

View File

@ -818,8 +818,52 @@ namespace Volian.Print.Library
{ // pagination logic needs to be fixed. { // pagination logic needs to be fixed.
ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval); ForcePagination(cb, ref yPageStart, yTopMargin, yBottomMargin, ref yLocation, ref retval);
} }
else
{
if (MyItemInfo.IsStepSection && MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseCalvert && (MyItemInfo.ActiveSection as SectionInfo).HasInitials)
{
if (MyPageHelper.PrintInitials(cb,yLocation,(float) MyItemInfo.MyDocStyle.Layout.LeftMargin))
{
//if(yLocation != yTopMargin)
// Console.WriteLine("'{0}',{1},'{2}',{3},{4},{5},{6}", MyItemInfo.MyProcedure.DisplayNumber, MyItemInfo.ItemID
// , MyItemInfo.DisplayNumber, yLocation,yTopMargin,MyItemInfo.HasCautionOrNote,MyPageHelper.CurrentPageNumber+1);
}
}
}
return retval; return retval;
} }
public static void TextAt(PdfContentByte cb,VlnSvgPageHelper myPageHelper,PageItem pi,float yloc, float leftMargin)
{
System.Drawing.Color sysColor = PrintOverride.OverrideSvgColor(System.Drawing.Color.Black);
cb.SaveState();
if (myPageHelper.PageListLayer != null) cb.BeginLayer(myPageHelper.PageListLayer);
ColumnText ct = new ColumnText(cb);
iTextSharp.text.Font font;
int fontStyle = 0;
bool underline = false;
if (pi == null)
{
_MyLog.WarnFormat("Error in Initials");
ct.SetSimpleColumn(450 + leftMargin, yloc + 6.9F, 550 + leftMargin, yloc - 50);
font = FontFactory.GetFont("Arial", BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 10F);
}
else
{
ct.SetSimpleColumn((float)pi.Col + leftMargin, yloc + 6.9F, (float)pi.Col + 100 + leftMargin, yloc - 50);
fontStyle = (pi.Font.WindowsFont.Bold ? iTextSharp.text.Font.BOLD : 0) + (pi.Font.WindowsFont.Italic ? iTextSharp.text.Font.ITALIC : 0);
font = FontFactory.GetFont(pi.Font.Family, BaseFont.IDENTITY_H, BaseFont.EMBEDDED,(float) pi.Font.Size,fontStyle);
underline = pi.Font.WindowsFont.Underline;
}
Chunk chk = new Chunk("INITIALS", font);
if(underline)
chk.SetUnderline(new iTextSharp.text.Color(sysColor), 0, 0.05F, 0, -.131F, PdfContentByte.LINE_CAP_ROUND); // Relative Based upon font size
Phrase ph = new Phrase(chk);
ct.AddElement(ph);
cb.SetColorFill(new iTextSharp.text.Color(sysColor));
ct.Go();
if (myPageHelper.PageListLayer != null) cb.EndLayer();
cb.RestoreState();
}
private bool _PrintHeader = false; private bool _PrintHeader = false;
public bool PrintHeader public bool PrintHeader
{ {
@ -4270,9 +4314,7 @@ namespace Volian.Print.Library
// For Calvert STP/OP: see if this section has checkoffs by looking in the section config: // For Calvert STP/OP: see if this section has checkoffs by looking in the section config:
//SectionInfo si= SectionInfo.Get(itemInfo.ActiveSection.ItemID); //SectionInfo si= SectionInfo.Get(itemInfo.ActiveSection.ItemID);
SectionInfo si = itemInfo.ActiveSection.GetSectionInfo(); SectionInfo si = itemInfo.ActiveSection.GetSectionInfo();
SectionConfig sectCfg = si.MyConfig as SectionConfig; ChkOff = si.HasInitials;
int sc = sectCfg.Section_CheckoffListSelection;
ChkOff = (sc >= 2) || si.HasStepCheckOffs;
} }
if (ChkOff) if (ChkOff)
{ {