Added Unit Specif logic

Added “Final Page” logic
Added “Final Page” logic, fixed PDF compare where it wasn’t finding the file in the Compare folder
Added Caution and Note boxes for Turkey Point
Null check and logic for PosAdjust format variable
Added “Final Page” message logic
Fix to get proper with of tabs containing a solid bullet
This commit is contained in:
John Jenko 2011-09-22 19:57:32 +00:00
parent 63888a983d
commit c5dc03ee1c
7 changed files with 181 additions and 17 deletions

View File

@ -1006,6 +1006,9 @@ namespace Volian.Controls.Library
//TypesSelected = "Step Types Searched: " + ((typstr != null) ? typstr : "all step types");
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "all step types");
//TypesSelected = (typstr != null) ? "Searched Step Types: " + typstr : "Searched All Step Types";
string unitPrefix = Mydocversion.DocVersionConfig.Unit_ProcedureNumber;
if (unitPrefix.EndsWith("#"))
unitPrefix = unitPrefix.Replace("#", "");
if (tabSearchTypes.SelectedTab == tabSearchTypes.Tabs[0]) // Text Search
{
@ -1026,7 +1029,7 @@ namespace Volian.Controls.Library
ReportTitle = "Step Element Report"; //"Proms - Search by Type: " + typstr;
TypesSelected = "Filtered By: " + typstr;
SearchString = null;
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars);
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, "", cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Value, includeRTFformat, includeSpecialChars, unitPrefix);
cmbResultsStyleIndex = 1; //display step locations in results
}
}
@ -1044,7 +1047,7 @@ namespace Volian.Controls.Library
SearchString = TextSearchString;
//TypesSelected = (typstr != null) ? "Searched Step Types: " + typstr : "Searched All Step Types";
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars);
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, TextSearchString, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, cbxIncROTextSrch.Checked ? ItemSearchIncludeLinks.Value : ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix);
cmbResultsStyleIndex = 3; // display step text in results
//}
}
@ -1066,7 +1069,8 @@ namespace Volian.Controls.Library
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
//SearchResults = ItemInfoList.GetListFromAnnotationSearch(dviSearchList, typeSearchList, textSearchString, srchStr, cbxCaseSensitiveAnnoText.Checked);
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked);
SearchResults = ItemInfoList.GetListFromAnnotationSearch(DVISearchList, TypeSearchList, AnnotationSearchType, cbxTextSearchAnnotation.Text, cbxCaseSensitiveAnnoText.Checked,unitPrefix);
//UpdateAnnotationSearchResults();
cmbResultsStyleIndex = 2; // display annotation text in results
}
@ -1078,12 +1082,12 @@ namespace Volian.Controls.Library
//TypesSelected = "Searched Step Types: " + ((typstr != null) ? typstr : "All Step Types");
if (cbxFndUnLnkROVals.Enabled && cbxFndUnLnkROVals.Checked)
{
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars);
SearchResults = ItemInfoList.GetListFromTextSearch(DVISearchList, TypeSearchList, ROSearchList, cbxBooleanTxtSrch.Checked ? 2 : cbxCaseSensitive.Checked ? 1 : 0, ItemSearchIncludeLinks.Nothing, includeRTFformat, includeSpecialChars, unitPrefix);
cmbResultsStyleIndex = 3; // display step text in results
}
else
{
SearchResults = ItemInfoList.GetListFromROSearch(DVISearchList, TypeSearchList, ROSearchList);
SearchResults = ItemInfoList.GetListFromROSearch(DVISearchList, TypeSearchList, ROSearchList, unitPrefix);
cmbResultsStyleIndex = 3; // display step text in results
}
}

View File

@ -27,6 +27,13 @@ namespace Volian.Print.Library
get { return _Total; }
set { _Total = value; }
}
private string _FinalPageMessage;
public string FinalPageMessage
{
get { return _FinalPageMessage; }
set { _FinalPageMessage = value; }
}
private PageCountTemplates _MyTemplates; // (for each page that has this key)
internal PageCountTemplates MyTemplates
{
@ -42,10 +49,16 @@ namespace Volian.Print.Library
}
public void DrawTemplates()
{
int cnt = 0;
foreach (PageCountTemplate pct in MyTemplates)
{
cnt++;
string fstr = pct.Text.Replace("{OF}", _Total.ToString());
if (fstr.Contains("{FINALPAGE}"))
{
fstr = fstr.Replace("{FINALPAGE}", (cnt == MyTemplates.Count) ? FinalPageMessage : "");
}
// use font from pct
string fontFace = pct.MyFont.Name;
int fontStyle = (pct.MyFont.Bold ? iTextSharp.text.Font.BOLD : 0) + (pct.MyFont.Italic ? iTextSharp.text.Font.ITALIC : 0);
@ -102,6 +115,12 @@ namespace Volian.Print.Library
if (!this.ContainsKey(key)) this.Add(key, new PageCount());
return (this[key].AddToTemplateList(pdfWriter, text, myFont, alignment,color));
}
public PdfTemplate AddToTemplateList(string key, PdfWriter pdfWriter, string text, string finalPageMessage, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
{
if (!this.ContainsKey(key)) this.Add(key, new PageCount());
this[key].FinalPageMessage = finalPageMessage;
return (this[key].AddToTemplateList(pdfWriter, text, myFont, alignment, color));
}
public void DrawTemplates()
{
foreach (PageCount pc in this.Values)

View File

@ -282,7 +282,21 @@ namespace Volian.Print.Library
}
return PrintProcedureOrFoldout(myProcedure, false, outputFileName);
}
// Find the last section that has a Final Message defined in its format
// Return that section's itemID or a -1 if the Final Message is not defined
private int GetFinalMessageSectionID(ProcedureInfo myProcedure, bool doingFoldout)
{
int sectionID = -1;
if (!doingFoldout)
{
foreach (SectionInfo mySection in myProcedure.Sections)
{
if (mySection.MyDocStyle.Final.Message != null && mySection.MyDocStyle.Final.Message.Length > 0)
sectionID = mySection.ItemID;
}
}
return sectionID;
}
private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, bool doingFoldout, string outputFileName)
{
// Create an MSWord Pdf
@ -295,6 +309,7 @@ namespace Volian.Print.Library
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
OnStatusChanged(myProcedure.DisplayNumber, PromsPrinterStatusType.ProgressSetup, myProcedure.Sections.Count);
int progress = 0;
int finalMessageSectionID = GetFinalMessageSectionID(myProcedure, doingFoldout);
foreach (SectionInfo mySection in myProcedure.Sections)
{
@ -313,7 +328,7 @@ namespace Volian.Print.Library
if (DebugOutput)
{
// 16-bit background
string procedureFileName = BackgroundFolder + "\\" + CreateFileName(myProcedure.DisplayNumber);
string procedureFileName = BackgroundFolder + "\\" + PDFFile;//CreateFileName(myProcedure.DisplayNumber);
FileInfo VEPromsFile = new FileInfo(procedureFileName);
if (VEPromsFile.Exists && !doingFoldout)
{
@ -344,7 +359,7 @@ namespace Volian.Print.Library
}
PdfReader readerWord = null;
string myPdfFile = null;
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
if (mySection.IsStepSection)
{
if ((mySection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)

View File

@ -73,7 +73,13 @@ namespace Volian.Print.Library
get { return _MyPdfContentByte; }
set { _MyPdfContentByte = value; }
}
private int _FinalMessageSectionID;
public int FinalMessageSectionID
{
get { return _FinalMessageSectionID; }
set { _FinalMessageSectionID = value; }
}
public override void OnCloseDocument(PdfWriter writer, iTextSharp.text.Document document)
{
AddBookmarks(writer);
@ -456,6 +462,12 @@ namespace Volian.Print.Library
MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, args.MyText, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y));
return string.Empty;
}
if (args.MyText.Contains("{FINALPAGE}") && MySection.ItemID == FinalMessageSectionID)
{
string key = "FinalPage";
MyPdfContentByte.AddTemplate(MyPageCounts.AddToTemplateList(key, MyPdfWriter, args.MyText,MySection.MyDocStyle.Final.Message, args.MySvgText.Font, args.MySvgText.Align, args.MySvgText.FillColor), args.MySvgScale.X(args.MySvgText.X), args.MySvgScale.Y(MyPdfContentByte, args.MySvgText.Y));
return string.Empty;
}
return regexFindToken.Replace(args.MyText, new MatchEvaluator(ReplacePageListToken));
}
private string BuildMyText(VEPROMS.CSLA.Library.FormatInfo activeFormat)
@ -497,8 +509,25 @@ namespace Volian.Print.Library
private void AddPageListItems(Volian.Svg.Library.Svg mySvg, VEPROMS.CSLA.Library.PageStyle pageStyle, VEPROMS.CSLA.Library.SectionInfo section)
{
SvgGroup svgGroup = new SvgGroup();
//int defPtPerRow = 72 / 6;
//int curLPI = 6; // default
//int prevLPI = 6;
//float PrevRow = 0;
//float rowAdj = 0; // = 18;
foreach (VEPROMS.CSLA.Library.PageItem pageItem in pageStyle.PageItems)
{
//if (PrevRow > 0)
//{
// //float pgRow = (float)(pageItem.Row + rowAdj);
// if (curLPI != prevLPI)
// {
// int prow = (int)(PrevRow / defPtPerRow);
// int nrows = ((int)(pageItem.Row / defPtPerRow)) - prow;
// rowAdj += (float)Math.Abs(((nrows * (72 / curLPI)) - ((nrows * defPtPerRow) + rowAdj)));
// //rowAdj += (float)(((pgRow - PrevRow) / (72 * prevLPI)) * (72 / curLPI));
// prevLPI = curLPI;
// }
//}
MatchCollection matches = regexFindToken.Matches(pageItem.Token);
if (matches.Count>0)
{
@ -544,12 +573,25 @@ namespace Volian.Print.Library
case "{PROCTITLE}":
case "{PROCTITLE1}":
case "{PROCTITLE2}":
case "{COVERPROCTITLE}":
float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12;
SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)linelen, token);
SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)linelen, token); //,rowAdj);
//SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token);
break;
case "{COVERTITLE1}":
case "{COVERTITLE2}":
int ctlen = section.ActiveFormat.PlantFormat.FormatData.ProcData.CoverTitleLength??0;
float coverlinelen = ((ctlen == 0) ? (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength : ctlen) * (float)pageItem.Font.CPI / 12;
SplitCoverTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)coverlinelen, token);//, rowAdj);
//SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token);
break;
case "{EOPNUM}":
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.MyProcedure.MyContent.Number)));
string eopnum = section.MyProcedure.MyContent.Number;
string unitnum = MySection.MyDocVersion.DocVersionConfig.Unit_ProcedureNumber;
if (unitnum.Length > 0)
eopnum = unitnum.Replace("#", eopnum);
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, eopnum)));
//svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.MyProcedure.MyContent.Number)));
break;
case "{SECTIONLEVELTITLE}":
SplitTitle(svgGroup, pageItem, section.DisplayText, section.ActiveFormat.PlantFormat.FormatData.SectData.SectionTitleLength, token);
@ -558,6 +600,9 @@ namespace Volian.Print.Library
case "{SECTIONLEVELNUMBER}":
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,section.DisplayNumber)));
break;
case "{UNITTEXT}":
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token,MySection.MyDocVersion.DocVersionConfig.Unit_Text)));
break;
default:
// see if it's a PSI token:
if (token.Contains(@"PS-"))
@ -590,6 +635,15 @@ namespace Volian.Print.Library
if (val != null && val != "")svgGroup.Add(PageItemToSvgText(pageItem, val));
}
}
//else if (token.Contains(@"{DRV:Lpi "))
//{
// int indx = token.IndexOf("{DRV:Lpi ") + 9;
// int endindx = token.IndexOf("}", indx);
// string str = token.Substring(indx, endindx - indx);
// curLPI = Convert.ToInt32(str) / 2;
// //PrevRow = (float)(pageItem.Row + rowAdj);
// PrevRow = (float)pageItem.Row;
//}
else
svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token));
//_MyLog.InfoFormat("Token not processed {0}", token);
@ -626,6 +680,36 @@ namespace Volian.Print.Library
yOffset += 12;
}
}
private void SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match)
{
if (len == null || ItemInfo.StripRtfFormatting(title).Length < len)
{
if (match == "{COVERTITLE2}") return; // this would have been done in COVERTITLE1
svgGroup.Add(PageItemToSvgText(pageItem, title));
return;
}
// Otherwise determine how many line to split the text into
List<string> titleLines = SplitText(title, (int)len);
if (match == "{COVERTITLE1}")
{
svgGroup.Add(PageItemToSvgText(pageItem, titleLines[0]));
return;
}
// if the token was proctitle, dont' adjust. If the token was PROCTITLE1/2 then
// move down 6.
// int adj = pageItem.Token.Contains("1") || pageItem.Token.Contains("2") ? 0 : -6;
int adj = (titleLines.Count > 2) ? -6 : 0;
float yOffset = adj * (titleLines.Count - 2);
int lnCnt = 0;
foreach (string line in titleLines)
{
lnCnt++;
if (lnCnt == 1) continue;
svgGroup.Add(PageItemToSvgText(pageItem, line, yOffset));
yOffset += 12;
}
}
private List<string> SplitText(string text, int len)
{
List<string> results = new List<string>();

View File

@ -11,6 +11,7 @@ namespace Volian.Print.Library
{
public partial class vlnBox : vlnPrintObject
{
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _LineType; /* how to represent?? */
private System.Drawing.Color _Color;
public System.Drawing.Color Color
@ -38,6 +39,8 @@ namespace Volian.Print.Library
public const string BoxThin = "\x2510.\x2500.\x250c.\x2502. . .\x2518.\x2514. .\x2500. . ";
const string BoxThick = "\x2584.\x2584.\x2584.\x2588. . .\x2580.\x2580. .\x2580. . ";
const string BoxDouble = "\x2557.\x2550.\x2554.\x2551. . .\x255D.\x255A. .\x2550. . ";
const string BoxFPLNote = "\x2557.\x2550\xad.\x2554\xad.\x2551. . .\x255d.\x255a\xad. .\x2550\xad. . ";
const string BoxFPLCaution = "\x2588.\x2580.\x2588.\x2588. . .\x2588.\x2588. .\x2584. . ";
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)
{
cb.SaveState();
@ -81,9 +84,22 @@ namespace Volian.Print.Library
// inner rectangle
cb.Rectangle(left + llxOffset + lineThickness, bottom + lineThickness * 1.5F, right - left - lineThickness * 2, (Height - lineThickness * 3) * MyPageHelper.YMultiplier);
break;
case BoxFPLNote:
lineThickness = 2;
cb.SetLineWidth(lineThickness);
float[] linePattern = { 6, 1.75F, 2.5F, 1.75F };
cb.SetLineDash(linePattern,3);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2) -1, right - left, (2 + Height - lineThickness) * MyPageHelper.YMultiplier);
break;
case BoxFPLCaution:
lineThickness = 3;
cb.SetLineWidth(lineThickness);
cb.Rectangle(left + llxOffset, bottom + (lineThickness / 2), right - left, (Height - lineThickness) * MyPageHelper.YMultiplier);
break;
default:
// For other than thick, thin and double.
Console.WriteLine("NO BOXES");
//Console.WriteLine("NO BOXES");
_MyLog.WarnFormat("INVALID BOX SYTLE {0} \"{1}\"", MyParent.MyItemInfo.FormatStepData.Type, CharToAsc(MyBox.BoxStyle));
break;
//throw new Exception("Missing vlnBox handler");
}

View File

@ -878,7 +878,14 @@ namespace Volian.Print.Library
{
doSectTab = true;
if (itemInfo.IsStepSection && formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Just == "PSLeft")
localXOffset = (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
{
float offset = (float)itemInfo.MyDocStyle.Layout.LeftMargin;
if (formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos != null)
offset += (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos;
localXOffset = offset;
// jsj - 12Aug2011
//localXOffset = (float)formatInfo.PlantFormat.FormatData.SectData.SectionNumber.Pos + (float)itemInfo.MyDocStyle.Layout.LeftMargin;
}
}
if (!itemInfo.IsSection || doSectTab)
{
@ -1055,6 +1062,9 @@ namespace Volian.Print.Library
else // AER or RNO
XOffset = MyParent.XOffset + MyParent.Width / 2 - Width / 2;
// Set any position adjustment (defined in the format on a per type basis)
XOffset += (float)(MyItemInfo.FormatStepData.StepPrintData.PosAdjust ?? 0);
// if the XOffset < High Level Step Text's XOffset, then align with the High Level Step Text
if (XOffset < xLowerLimit)
XOffset = xLowerLimit;

View File

@ -57,7 +57,14 @@ namespace Volian.Print.Library
get { return _MyMacro; }
set { _MyMacro = value; }
}
private float GetTextWidth(VE_Font vefont, string txt)
{
System.Drawing.Font font = new System.Drawing.Font(vefont.Family, (float)vefont.Size);
iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
float w = iFont.BaseFont.GetWidthPointKerned(Text.Replace("\u25CF","@"), (float)vefont.Size);
return w;
}
public vlnTab(PdfContentByte cb, vlnParagraph myparent, string origTab, string cleanTab, float xoffset, float yoffset, VE_Font vFont, bool doSectTab)
{
MyContentByte = cb;
@ -65,7 +72,7 @@ namespace Volian.Print.Library
YOffset = yoffset;
Text = cleanTab;
MyFont = vFont;
Width = MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
Width = GetTextWidth(MyFont, (Text != null ? Text : origTab));//MyFont.CharsToTwips * (Text != null ? Text.Length : origTab.Length);
if (origTab.Contains(@"{!"))
{
int mindx = origTab.IndexOf(@"{!");
@ -77,10 +84,10 @@ namespace Volian.Print.Library
origTab = origTab.Replace(macro,"");
origTab = origTab + " ";
cleanTab = origTab;
Width = MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
Width = GetTextWidth(MyFont, (cleanTab != null ? cleanTab : origTab));//MyFont.CharsToTwips * (cleanTab != null ? cleanTab.Length : origTab.Length);
}
Rtf = GetRtf(origTab, vFont);
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF
Rtf = Rtf.Replace("\u25CF", @"\f1\u9679?\f0"); // bullet 25CF // jsj- add space after \f0
if (myparent.MyItemInfo.FormatStepData != null && !myparent.MyItemInfo.FormatStepData.AlwaysTab && myparent.MyItemInfo.MyPrevious != null)
{
Rtf = Rtf.Replace("Caution:", " ");
@ -99,7 +106,16 @@ namespace Volian.Print.Library
if (doSectTab)
XOffset = xoffset;
else
{
//if (MyFont.Family == "Arial" && MyFont.Size == 14)
//{
// System.Drawing.Font font = new System.Drawing.Font("Arial", 14);
// iTextSharp.text.Font iFont = Volian.Svg.Library.VolianPdf.GetFont(font);
// float w = iFont.BaseFont.GetWidthPointKerned(Text, 14);
// Width = w;
//}
XOffset = xoffset - Width;
}
}
public override float ToPdf(PdfContentByte cb, float yPageStart, float yTopMargin, float yBottomMargin)