Added methods to use common dictionary of fonts part of B2017-117 Out of Window Handles fix
Use method from VE_Font to get a font reference (uses dictionary so redundant Window Handles are not created) B2017-117 Add a Using statement when we temporarily create a RichTextBox to ensure the Window Handle is free’d. Also use method from VE_Font to get a font reference (uses dictionary so redundant Window Handles are not created) B2017-117
This commit is contained in:
@@ -566,7 +566,8 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// if there was no text following the hypen, then use the font defined for tables in the plant's format
|
||||
VEPROMS.CSLA.Library.VE_Font vfnt = myTable.MyFlexGrid.GetMyItemInfo().FormatStepData.Font;
|
||||
System.Drawing.Font ffont = new System.Drawing.Font(vfnt.Family, (float)vfnt.Size);
|
||||
//System.Drawing.Font ffont = new System.Drawing.Font(vfnt.Family, (float)vfnt.Size);
|
||||
System.Drawing.Font ffont = VE_Font.GetWinSysFont(vfnt.Family, (float)vfnt.Size);
|
||||
fnt = Volian.Svg.Library.VolianPdf.GetFont(ffont);
|
||||
fnt.SetStyle(myPara.Font.Style);
|
||||
fnt.SetColor(myPara.Font.Color.R,myPara.Font.Color.G,myPara.Font.Color.B);
|
||||
@@ -630,7 +631,8 @@ namespace Volian.Print.Library
|
||||
{
|
||||
// if there was no text following the hypen, then use the font defined for tables in the plant's format
|
||||
VEPROMS.CSLA.Library.VE_Font vfnt = myTable.MyFlexGrid.GetMyItemInfo().FormatStepData.Font;
|
||||
System.Drawing.Font ffont = new System.Drawing.Font(vfnt.Family, (float)vfnt.Size);
|
||||
//System.Drawing.Font ffont = new System.Drawing.Font(vfnt.Family, (float)vfnt.Size);
|
||||
System.Drawing.Font ffont = VE_Font.GetWinSysFont(vfnt.Family, (float)vfnt.Size);
|
||||
fnt = Volian.Svg.Library.VolianPdf.GetFont(ffont);
|
||||
fnt.SetStyle(myPara.Font.Style);
|
||||
fnt.SetColor(myPara.Font.Color.R, myPara.Font.Color.G, myPara.Font.Color.B);
|
||||
@@ -782,78 +784,85 @@ namespace Volian.Print.Library
|
||||
// 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(@"\u9586?", "<dblbs>");// rename backslash character to avoid RTF confusion
|
||||
string strRTF = 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 = (MyFlexGrid.GetMyItemInfo().ActiveFormat != null) ? MyFlexGrid.GetMyItemInfo().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++)
|
||||
// bug fix: B2017-117 was getting an out of window handles error when doing a print all for Bryon
|
||||
// add the using statment to free up window handle that is created doing a New RichTextBox()
|
||||
using (System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox())
|
||||
{
|
||||
rtb.Select(i, 1);
|
||||
// If the character is a printable character set the font to the text font
|
||||
if (rtb.SelectionLength == 0 && strRTF != null && rtb.SelectionFont.FontFamily.Name == "VESymbFix")
|
||||
rtb.Rtf = rtf.Replace(@"\u9586?", "<dblbs>");// rename backslash character to avoid RTF confusion
|
||||
string strRTF = 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 Index="#" Unicode=[decimal char #] Replace=[optional char #] Family=[option font family name] Style=[optional font style] Size=[optional font size]>
|
||||
//</ReplaceSymbolChars-->
|
||||
//
|
||||
// get the list of symbol replacements
|
||||
FormatData fmtdata = (MyFlexGrid.GetMyItemInfo().ActiveFormat != null) ? MyFlexGrid.GetMyItemInfo().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++)
|
||||
{
|
||||
// Add debug information to the error log if the selection length is zero
|
||||
_MyLog.WarnFormat("Font Issues in Table Cell rtf= {0}, \nI= {1}, TXT = {2}", strRTF,i,rtb.Text.Substring(0,i));
|
||||
strRTF = null;
|
||||
}
|
||||
// bug fix: B2017-046 - check for selection length of zero to fix index out of bounds error
|
||||
// System.Windows.Forms.RichTextBox is having issues selection text in some cases (ex. Symbol char followed by a RO reference - without a space between them)
|
||||
if (rtb.SelectionLength > 0 && rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText[0] > ' ' && rtb.SelectedText[0] <= '\xFF')
|
||||
{
|
||||
//use bolding underline italics from local font
|
||||
System.Drawing.Font fnt = rtb.SelectionFont;
|
||||
rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style);
|
||||
changed = true;
|
||||
}
|
||||
if ((rtb.SelectionFont.FontFamily.Name == "VESymbFix" || rtb.SelectionFont.FontFamily.Name.StartsWith("Arial Unicode")) && rtb.SelectedText.Length > 0)
|
||||
{
|
||||
for (int j=0; j<SymReplaceList.MaxIndex;j++)
|
||||
rtb.Select(i, 1);
|
||||
// If the character is a printable character set the font to the text font
|
||||
if (rtb.SelectionLength == 0 && strRTF != null && rtb.SelectionFont.FontFamily.Name == "VESymbFix")
|
||||
{
|
||||
ReplaceChar rc = SymReplaceList[j];
|
||||
if (rc.Unicode != null)
|
||||
// Add debug information to the error log if the selection length is zero
|
||||
_MyLog.WarnFormat("Font Issues in Table Cell rtf= {0}, \nI= {1}, TXT = {2}", strRTF, i, rtb.Text.Substring(0, i));
|
||||
strRTF = null;
|
||||
}
|
||||
// bug fix: B2017-046 - check for selection length of zero to fix index out of bounds error
|
||||
// System.Windows.Forms.RichTextBox is having issues selection text in some cases (ex. Symbol char followed by a RO reference - without a space between them)
|
||||
if (rtb.SelectionLength > 0 && rtb.SelectionFont.FontFamily.Name == "VESymbFix" && rtb.SelectedText[0] > ' ' && rtb.SelectedText[0] <= '\xFF')
|
||||
{
|
||||
//use bolding underline italics from local font
|
||||
System.Drawing.Font fnt = rtb.SelectionFont;
|
||||
// follow through in fixing an Out of Window Handles bug, use new function to see if
|
||||
// we can retrieve the font from a dictionary instead a doing a New and using another
|
||||
// window handle B2017-117
|
||||
//rtb.SelectionFont = new System.Drawing.Font(DefaultFont, fnt.Style);
|
||||
rtb.SelectionFont = VE_Font.GetWinSysFont(DefaultFont, fnt.Style);
|
||||
changed = true;
|
||||
}
|
||||
if ((rtb.SelectionFont.FontFamily.Name == "VESymbFix" || rtb.SelectionFont.FontFamily.Name.StartsWith("Arial Unicode")) && rtb.SelectedText.Length > 0)
|
||||
{
|
||||
for (int j = 0; j < SymReplaceList.MaxIndex; j++)
|
||||
{
|
||||
char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode));
|
||||
if (rc_uchar == rtb.SelectedText[0])
|
||||
ReplaceChar rc = SymReplaceList[j];
|
||||
if (rc.Unicode != null && (rc.Family != null || rc.Size != null || rc.Style != null))
|
||||
{
|
||||
//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;
|
||||
if (rc.Replace != null)
|
||||
char rc_uchar = Convert.ToChar(Convert.ToInt32(rc.Unicode));
|
||||
if (rc_uchar == rtb.SelectedText[0])
|
||||
{
|
||||
char rc_RplChar = Convert.ToChar(Convert.ToInt32(rc.Replace));
|
||||
rtb.SelectedText = rc_RplChar.ToString();
|
||||
//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);
|
||||
System.Drawing.Font fntw = VE_Font.GetWinSysFont((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;
|
||||
if (rc.Replace != null)
|
||||
{
|
||||
char rc_RplChar = Convert.ToChar(Convert.ToInt32(rc.Replace));
|
||||
rtb.SelectedText = rc_RplChar.ToString();
|
||||
}
|
||||
changed = true;
|
||||
break; // break out of foreach loop since we changed the character
|
||||
}
|
||||
changed = true;
|
||||
break; // break out of foreach loop since we changed the character
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) return rtb.Rtf.Replace("<dblbs>", @"\u9586?");
|
||||
}
|
||||
if (changed) return rtb.Rtf.Replace("<dblbs>", @"\u9586?");
|
||||
}
|
||||
return rtf;
|
||||
}
|
||||
|
Reference in New Issue
Block a user