C2017-008 Formats now have a grouping allowing us to change a symbol character’s font family, size, style, and/or the actual character

This commit is contained in:
2017-05-26 15:13:19 +00:00
parent cc175768c6
commit 9b881f551e
3 changed files with 195 additions and 4 deletions

View File

@@ -4323,8 +4323,67 @@ namespace Volian.Print.Library
Rtf = Rtf.Replace("{Backspace}", "");
}
}
Rtf = FixRTFToPrint(Rtf);
ProfileTimer.Pop(profileDepth);
}
private string FixRTFToPrint(string rtf)
{
// Only do this if the text contains symbols.
if (rtf.Contains("VESymbFix"))
{
System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
rtb.Rtf = rtf.Replace(@"\\","<dblbs>"); // rename backslash character to avoid RTF confusion
//string showRTF = rtf;
bool changed = false;
// C2017-008 - WCN wants the box symbol to look like their checkoff/signoff box
// Check for a list of replacement character for symbols in the format file
// ReplaceSymbolChars lets you do one or more of the following with a symbol character:
// - change the point size
// - change the style
// - change the font family
// - change the symbol character
//
// below is taken from the BaseAll format file - is currently commentout and there for reference
// Wolf Creek (WCN) currently uses this to increase the size of the box symbol
//
//<!--example of replacing a symbol character (VESymbFix)-->
//<!--ReplaceSymbolChars>
// <ReplaceChar Unicode=[decimal char #] Replace=[optional char #] Family=[option font family name] Style=[optional font style] Size=[optional font size]>
// <ReplaceChar Unicode="9633" Size="20"/> < this will resize the VESYMBFix box character to 20 point>
// <ReplaceChar Unicode="9633" Replace="0163" Family ="WingDings 2" Size="16"/> <this will replace the VESYMBFix box char with a 16 point "WingDing 2" char>
//</ReplaceSymbolChars-->
//
// get the list of symbol replacements
FormatData fmtdata = (MyItemInfo.MyDocVersion != null) ? MyItemInfo.MyDocVersion.ActiveFormat.PlantFormat.FormatData : FormatInfo.PROMSBaseFormat.FormatData;
ReplaceSymbolCharList SymReplaceList = (fmtdata != null && fmtdata.SectData.ReplaceSymbolCharList != null) ? fmtdata.SectData.ReplaceSymbolCharList : null;
// Look at one character at a time
for (int i = 0; i < rtb.TextLength; i++)
{
rtb.Select(i, 1);
if (rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText.Length > 0)
{
foreach (ReplaceChar rc in SymReplaceList)
{
if (rc.Unicode != null)
{
char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode));
if (rc_uchar == rtb.SelectedText[0])
{
//use bolding underline italics from local font
System.Drawing.Font fnt = rtb.SelectionFont;
System.Drawing.Font fntw = new System.Drawing.Font((rc.Family != null)?rc.Family:fnt.FontFamily.Name, (rc.Size != null)?(float)rc.Size:fnt.Size, (rc.Style != null)?(System.Drawing.FontStyle)rc.Style:fnt.Style);
rtb.SelectionFont = fntw;
changed = true;
}
}
}
}
}
if (changed) return rtb.Rtf.Replace("<dblbs>",@"\\"); // put back the backslash character
}
return rtf;
}
// for Calvert (BGE) alarms, some step text is kept on the same line as its parent. This
// is flagged by the -1 row in the template definition.
private bool KeepOnParentLine(ItemInfo itemInfo)