diff --git a/PROMS/VEPROMS User Interface/frmPSI.cs b/PROMS/VEPROMS User Interface/frmPSI.cs index fb5de576..e397dcbe 100644 --- a/PROMS/VEPROMS User Interface/frmPSI.cs +++ b/PROMS/VEPROMS User Interface/frmPSI.cs @@ -84,7 +84,7 @@ namespace VEPROMS this.Controls.Add(cb); } } - if (psiDialogDef.ButtonsOnBottom.ToUpper() == "NO") + if (psiDialogDef.ButtonsOnBottom == null || psiDialogDef.ButtonsOnBottom.ToUpper() == "NO") { btnOk.Location = new Point(maxx+20, 30); btnCancel.Location = new Point(maxx + 20, 60); diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index e0438569..5c2c0926 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -465,6 +465,7 @@ namespace Volian.Print.Library public PageCounts MyTOCPageCounts = null; public Dictionary MyTOCPageNums = null; private static Regex regexFindToken = new Regex("{[^{}]*}"); + private static Regex regexFindSubToken = new Regex(@"\[[^{}]*\]"); private string mySvg_ProcessText(object sender, SvgProcessTextArgs args) { if (args.MyText == null) return string.Empty; // Needed for empty genmac text (was space in 16bit files) @@ -652,180 +653,46 @@ namespace Volian.Print.Library { string token = match.Value; //token = Regex.Replace(token, @"[\xB3-\xDF]", " "); - switch (match.Value) + + // handle any conditional PS tokens + if (plstr.Contains(@"PS=")) { - case "{!atom}": - // Add an Atom Figure to the SVG - plstr = plstr.Replace(token, ""); - AddImage(svgGroup, 160.5f, 170.5f, 288f, 323f, "atom.bmp"); - break; - case "{!cpllogo}": - plstr = plstr.Replace(token, ""); - AddImage(svgGroup, 10f, 10f, 78.7f, 29.8f, "cpllogo.bmp"); - break; - //case "{!domlogo}": - // AddImage(svgGroup, 10f, 70f, 123f, 40.1f, "domlogo.bmp"); - // break; - //case "{!gpclogo}": - // AddImage(svgGroup, 10f, 150f, 35.2f, 35.8f, "gpclogo.bmp"); - // break; - case "{HEADER1}": - case "{HEADER2}": - case "{HEADER3}": - case "{HEADER4}": - case "{HEADER5}": - case "{BOX1}": - case "{BOX2}": - case "{BOX3}": - case "{BOX4}": - case "{BOX5}": - case "{BOX6}": - case "{BOX7}": - case "{BOX8}": - case "{BOX9}": - plstr = plstr.Replace(token, ""); - svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(token))); - break; - case "{PMODEBOX}": // need to set either 1 or 2 depending on number of columns - string box = "1"; - if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Four) - box = "4"; - else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Three) - box = "3"; - else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Two) - box = "2"; - box = "{BOX" + box + "}"; - plstr = plstr.Replace(token, ""); - svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(box))); - break; - case "{DRAFTPAGE}": - if (!AllowedWatermarks.Contains("Draft")) AllowedWatermarks.Add("Draft"); - plstr = plstr.Replace(token, "");// Remove token since it is handled now - break; - case "{REFERENCEPAGE}": - if (!AllowedWatermarks.Contains("Reference")) AllowedWatermarks.Add("Reference"); - plstr = plstr.Replace(token, "");// Remove token since it is handled now - break; - case "{MASTERPAGE}": - if (!AllowedWatermarks.Contains("Master")) AllowedWatermarks.Add("Master"); - plstr = plstr.Replace(token, "");// Remove token since it is handled now - break; - case "{SAMPLEPAGE}": - if (!AllowedWatermarks.Contains("Sample")) AllowedWatermarks.Add("Sample"); - plstr = plstr.Replace(token, "");// Remove token since it is handled now - break; - case "{INFORMATIONPAGE}": - if (!AllowedWatermarks.Contains("Information Only")) AllowedWatermarks.Add("Information Only"); - break; - case "{PROCTITLE}": - case "{PROCTITLE1}": - case "{PROCTITLE2}": - case "{COVERPROCTITLE}": - float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12; - plstr = SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text.ToUpper(), (int)linelen, token, plstr); //,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; - plstr = SplitCoverTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)coverlinelen, token, plstr);//, rowAdj); - //SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token); - break; - case "{EOPNUM}": - case "{PREDELIMEOPNUM}": - string eopnum = section.MyProcedure.MyContent.Number; - string unitnum = MySection.MyDocVersion.DocVersionConfig.Unit_ProcedureNumber; - if (unitnum.Length > 0) - eopnum = unitnum.Replace("#", eopnum); - if (match.Value.Equals("{PREDELIMEOPNUM}")) - { - // only use up to the first non-alphanumeric character of the procedur number - // Prairie Island (NSP) Alarms use this token - int idx = 0; - while (idx < eopnum.Length && char.IsLetterOrDigit(eopnum[idx])) idx++; - if (idx < eopnum.Length) - eopnum = eopnum.Substring(0, idx); - } - plstr = plstr.Replace(token, 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}": - plstr = SplitTitle(svgGroup, pageItem, section.DisplayText, section.ActiveFormat.PlantFormat.FormatData.SectData.SectionTitleLength, token, plstr); - //svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText)); - break; - case "{SECTIONLEVELNUMBER}": - plstr = plstr.Replace(token, section.DisplayNumber); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.DisplayNumber))); - break; - case "{UNITTEXT}": - plstr = plstr.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text))); - break; - case "{CHKOFFHEADING}": - // unfortunately, the font is not stored on the page list item if there is an active - // check off header. It is stored with the checkoff data as defined by user selection - // of the selected header (selection stored in section config). - int sindx = section.CheckOffHeadingIndex(); - VE_Font vf = sindx <= 0 ?pageItem.Font: - section.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font; - useFontForCheckOffHeader = vf; - PageListCheckOffHeader = PageItemToSvgText(pageItem, pageItem.Token, vf, section); - break; - default: - // see if it's a PSI token: - if (token.Contains(@"PS-")) - { - ProcedureConfig procConfig = section.MyProcedure.MyConfig as ProcedureConfig; - if (procConfig != null) - { - int indx = token.IndexOf("-"); - string val = procConfig.GetValue("PSI", token.Substring(4, token.Length - 5)); - plstr = plstr.Replace(token, val); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, val))); - } - } - else if (token.Contains(@"PS=")) - { - ProcedureConfig procConfig = section.MyProcedure.MyConfig as ProcedureConfig; - if (procConfig != null) - { - int indx = token.IndexOf("="); - int qindx = token.IndexOf("?", indx); - string pstok = token.Substring(indx + 1, qindx - indx - 1); - string val = procConfig.GetValue("PSI", pstok); - int bindx = token.IndexOf("|", indx); - if (val == "Y") - val = token.Substring(qindx + 1, bindx - qindx - 1); - else - { - int eindx = token.IndexOf("}", bindx); - val = token.Substring(bindx + 1, eindx - bindx - 1); - } - if (val != null && val != "") - plstr = plstr.Replace(token, val); - //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; - //} + ProcedureConfig procConfig = section.MyProcedure.MyConfig as ProcedureConfig; + if (procConfig != null) + { + int indx = token.IndexOf("="); + int qindx = token.IndexOf("?", indx); + string pstok = token.Substring(indx + 1, qindx - indx - 1); + string val = procConfig.GetValue("PSI", pstok); + int bindx = token.IndexOf("|", indx); + if (val == "Y") + val = token.Substring(qindx + 1, bindx - qindx - 1); else { - if (plstr != "") - svgGroup.Add(PageItemToSvgText(pageItem, plstr, MySection)); - //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token)); + int eindx = token.IndexOf("}", bindx); + val = token.Substring(bindx + 1, eindx - bindx - 1); } - //_MyLog.InfoFormat("Token not processed {0}", token); - break; + //if (val == null || val == "") + //val = " "; + if (val == null) + val = ""; + plstr = plstr.Replace(token, val); + // Get a list of Pagelist token that are inside the PS= conditional result + // Paglist tokens inside a PS= conditional are surrounded by square brackets instead of curley + // ex. [BOX3] instead of {BOX3} + MatchCollection subMatches = regexFindSubToken.Matches(plstr); + if (subMatches.Count > 0) + { + foreach (Match subMatch in subMatches) + { + string subToken = subMatch.Value; + ProcessPaglistToken(section, svgGroup, pageItem, ref useFontForCheckOffHeader, ref plstr, subToken); + } + } + } } + else + ProcessPaglistToken(section, svgGroup, pageItem, ref useFontForCheckOffHeader, ref plstr, token); } // end foreach matches if (plstr != "") @@ -850,18 +717,203 @@ namespace Volian.Print.Library if (svgGroup.Count>0) mySvg.Add(svgGroup); } + private void ProcessPaglistToken(VEPROMS.CSLA.Library.SectionInfo section, SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, ref VE_Font useFontForCheckOffHeader, ref string plstr, string token) + { + // Paglist token inside a PS= conditional are surrounded by square brackets instead of curley + // ex. [BOX3] instead of {BOX3}, thus the redunant looking cases + switch (token) + { + case "{!atom}": + // Add an Atom Figure to the SVG + plstr = plstr.Replace(token, ""); + AddImage(svgGroup, 160.5f, 170.5f, 288f, 323f, "atom.bmp"); + break; + case "{!cpllogo}": + plstr = plstr.Replace(token, ""); + AddImage(svgGroup, 10f, 10f, 78.7f, 29.8f, "cpllogo.bmp"); + break; + //case "{!domlogo}": + // AddImage(svgGroup, 10f, 70f, 123f, 40.1f, "domlogo.bmp"); + // break; + //case "{!gpclogo}": + // AddImage(svgGroup, 10f, 150f, 35.2f, 35.8f, "gpclogo.bmp"); + // break; + case "{HEADER1}": + case "[HEADER1]": + case "{HEADER2}": + case "[HEADER2]": + case "{HEADER3}": + case "[HEADER3]": + case "{HEADER4}": + case "[HEADER4]": + case "{HEADER5}": + case "[HEADER5]": + case "{BOX1}": + case "[BOX1]": + case "{BOX2}": + case "[BOX2]": + case "{BOX3}": + case "[BOX3]": + case "{BOX4}": + case "[BOX4]": + case "{BOX5}": + case "[BOX5]": + case "{BOX6}": + case "[BOX6]": + case "{BOX7}": + case "[BOX7]": + case "{BOX8}": + case "[BOX8]": + case "{BOX9}": + case "[BOX9]": + plstr = plstr.Replace(token, ""); + svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(token))); + break; + case "{PMODEBOX}": // need to set either 1 or 2 depending on number of columns + case "[PMODEBOX]": + string box = "1"; + if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Four) + box = "4"; + else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Three) + box = "3"; + else if (_MySection.SectionConfig.Section_ColumnMode == SectionConfig.SectionColumnMode.Two) + box = "2"; + box = "{BOX" + box + "}"; + plstr = plstr.Replace(token, ""); + svgGroup.Add(PageItemToSvgUse(pageItem, FirstAndLast(box))); + break; + case "{DRAFTPAGE}": + if (!AllowedWatermarks.Contains("Draft")) AllowedWatermarks.Add("Draft"); + plstr = plstr.Replace(token, "");// Remove token since it is handled now + break; + case "{REFERENCEPAGE}": + if (!AllowedWatermarks.Contains("Reference")) AllowedWatermarks.Add("Reference"); + plstr = plstr.Replace(token, "");// Remove token since it is handled now + break; + case "{MASTERPAGE}": + if (!AllowedWatermarks.Contains("Master")) AllowedWatermarks.Add("Master"); + plstr = plstr.Replace(token, "");// Remove token since it is handled now + break; + case "{SAMPLEPAGE}": + if (!AllowedWatermarks.Contains("Sample")) AllowedWatermarks.Add("Sample"); + plstr = plstr.Replace(token, "");// Remove token since it is handled now + break; + case "{INFORMATIONPAGE}": + if (!AllowedWatermarks.Contains("Information Only")) AllowedWatermarks.Add("Information Only"); + break; + case "{PROCTITLE}": + case "[PROCTITLE]": + case "{PROCTITLE1}": + case "[PROCTITLE1]": + case "{PROCTITLE2}": + case "[PROCTITLE2]": + case "{COVERPROCTITLE}": + case "[COVERPROCTITLE]": + float linelen = (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength * (float)pageItem.Font.CPI / 12; + plstr = SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text.ToUpper(), (int)linelen, token, plstr); //,rowAdj); + //SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token); + break; + case "{COVERTITLE1}": + case "[COVERTITLE1]": + case "{COVERTITLE2}": + 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; + plstr = SplitCoverTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)coverlinelen, token, plstr);//, rowAdj); + //SplitTitle(svgGroup, pageItem, section.MyProcedure.MyContent.Text, (int)section.ActiveFormat.PlantFormat.FormatData.ProcData.TitleLength, token); + break; + case "{EOPNUM}": + case "[EOPNUM]": + case "{PREDELIMEOPNUM}": + case "[PREDELIMEOPNUM]": + string eopnum = section.MyProcedure.MyContent.Number; + string unitnum = MySection.MyDocVersion.DocVersionConfig.Unit_ProcedureNumber; + if (unitnum.Length > 0) + eopnum = unitnum.Replace("#", eopnum); + if (token.Equals("{PREDELIMEOPNUM}")) + { + // only use up to the first non-alphanumeric character of the procedur number + // Prairie Island (NSP) Alarms use this token + int idx = 0; + while (idx < eopnum.Length && char.IsLetterOrDigit(eopnum[idx])) idx++; + if (idx < eopnum.Length) + eopnum = eopnum.Substring(0, idx); + } + plstr = plstr.Replace(token, 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}": + case "[SECTIONLEVELTITLE]": + plstr = SplitTitle(svgGroup, pageItem, section.DisplayText, section.ActiveFormat.PlantFormat.FormatData.SectData.SectionTitleLength, token, plstr); + //svgGroup.Add(PageItemToSvgText(pageItem, section.DisplayText)); + break; + case "{SECTIONLEVELNUMBER}": + case "[SECTIONLEVELNUMBER]": + plstr = plstr.Replace(token, section.DisplayNumber); + //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, section.DisplayNumber))); + break; + case "{UNITTEXT}": + case "[UNITTEXT]": + plstr = plstr.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text); + //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, MySection.MyDocVersion.DocVersionConfig.Unit_Text))); + break; + case "{CHKOFFHEADING}": + case "[CHKOFFHEADING]": + // unfortunately, the font is not stored on the page list item if there is an active + // check off header. It is stored with the checkoff data as defined by user selection + // of the selected header (selection stored in section config). + int sindx = section.CheckOffHeadingIndex(); + VE_Font vf = sindx <= 0 ? pageItem.Font : + section.ActiveFormat.PlantFormat.FormatData.ProcData.CheckOffData.CheckOffHeaderList[sindx].Font; + useFontForCheckOffHeader = vf; + PageListCheckOffHeader = PageItemToSvgText(pageItem, pageItem.Token, vf, section); + break; + default: + + if (token.Contains(@"PS-")) + { + ProcedureConfig procConfig = section.MyProcedure.MyConfig as ProcedureConfig; + if (procConfig != null) + { + int indx = token.IndexOf("-"); + string val = procConfig.GetValue("PSI", token.Substring(4, token.Length - 5)); + plstr = plstr.Replace(token, val); + //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token.Replace(token, 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 + { + if (plstr != "") + svgGroup.Add(PageItemToSvgText(pageItem, plstr, MySection)); + //svgGroup.Add(PageItemToSvgText(pageItem, pageItem.Token)); + } + //_MyLog.InfoFormat("Token not processed {0}", token); + break; + } + } + private static void AddImage(SvgGroup svgGroup, float x, float y, float w, float h, string figure) { svgGroup.Add(new SvgImage(new System.Drawing.PointF(x, y), new System.Drawing.SizeF(w, h), System.Windows.Forms.Application.StartupPath + @"\Resources\" + figure)); } + private string SplitTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr) - //private void SplitTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match) { - if (match == "{PROCTITLE2}") return plstr.Replace(match,""); + if (match == "{PROCTITLE2}" || match == "[PROCTITLE2]") return plstr.Replace(match, ""); if (len == null || len == 0 || ItemInfo.StripRtfFormatting(title).Length < len) { - if (match == "{PROCTITLE2}") return plstr.Replace(match, ""); // this would have been done in proctitle1 + if (match == "{PROCTITLE2}" || match == "[PROCTITLE2]") return plstr.Replace(match, ""); // this would have been done in proctitle1 plstr = plstr.Replace(match, title); //svgGroup.Add(PageItemToSvgText(pageItem, title)); return plstr; @@ -888,19 +940,19 @@ namespace Volian.Print.Library } return plstr; } + private string SplitCoverTitle(SvgGroup svgGroup, VEPROMS.CSLA.Library.PageItem pageItem, string title, int? len, string match, string plstr) - //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 plstr; // this would have been done in COVERTITLE1 + if (match == "{COVERTITLE2}" || match == "[COVERTITLE2]") return plstr; // this would have been done in COVERTITLE1 plstr = plstr.Replace(match, title); //svgGroup.Add(PageItemToSvgText(pageItem, title)); return plstr; } // Otherwise determine how many line to split the text into List titleLines = SplitText(title, (int)len); - if (match == "{COVERTITLE1}") + if (match == "{COVERTITLE1}" || match == "[COVERTITLE1]") { plstr = plstr.Replace(match, titleLines[0]); //svgGroup.Add(PageItemToSvgText(pageItem, titleLines[0]));