B2017-085 Added hard returns back into the template

B2017-085 Added logic to handle hard returns in the templates.  Fix logic that grabs template titles that contain spaces.
This commit is contained in:
John Jenko 2017-05-23 18:02:46 +00:00
parent 4020477158
commit 6e94a74803
2 changed files with 20 additions and 8 deletions

Binary file not shown.

View File

@ -79,6 +79,15 @@ namespace VEPROMS.CSLA.Library
_CPI = new LazyLoad<float?>(CPI);
}
private LazyLoad<string> _Family;
private static Dictionary<string, Font> _WinFontLookup = new Dictionary<string, Font>();
// put the fonts in a dictionary so that we don't call new Font each time we reference it
private static Font GetFont(string family, float size, FontStyle style)
{
string key = string.Format("{0}_{1}_{2}", family, size, style);
if (!_WinFontLookup.ContainsKey(key))
_WinFontLookup.Add(key, new Font(family, size, style));
return _WinFontLookup[key];
}
private Font _WindowsFont;
public Font WindowsFont
{
@ -99,9 +108,9 @@ namespace VEPROMS.CSLA.Library
}
// for now - check size to be 0 and set to 10 if so, error in fmtxml?
if (Family == null) // Need to get inherited font
_WindowsFont = new Font("Arial", 10, FontStyle.Regular);
_WindowsFont = GetFont("Arial", 10, FontStyle.Regular);
else
_WindowsFont = new Font(Family, Size == 0 ? 10 : (float)Size, style);
_WindowsFont = GetFont(Family, Size == 0 ? 10 : (float)Size, style);
}
return _WindowsFont;
}
@ -291,7 +300,7 @@ namespace VEPROMS.CSLA.Library
short nocol = 0;
int row = 0;
string stmp = null;
if (!NewTemplateFormat)
if (!NewTemplateFormat) // not the smart template
{
string[] tmpOld = tpl.Split(" ".ToCharArray());
level = Convert.ToInt32(tmpOld[0]);
@ -300,14 +309,14 @@ namespace VEPROMS.CSLA.Library
stmp = null;
else if (tmpOld.Length > 3)
{
// Braidwood has spaces as part of the text in the 3rd field, i.e. (See Deviation Document)
// Wolf Creek and Turkey Point Background formats have spaces as part of the text in the 3rd field,
// handle this special case
int indxx = tpl.IndexOf(" ");
if (indxx < 0) stmp = null;
int indxx = tpl.IndexOf(" "); //skip past "level"
if (indxx < 0) stmp = null; // template incomplete set text to a null
else
{
indxx = tpl.IndexOf(" ", indxx+1);
stmp = (indxx > -1) ? tpl.Substring(indxx) : null;
indxx = tpl.IndexOf(" ", indxx + 1); //skip past "type"
stmp = (indxx > -1) ? tpl.Substring(indxx+1) : null; //if valid index grab text after "type" (+1 skips past the space char after the "type" number)
}
}
else
@ -329,6 +338,9 @@ namespace VEPROMS.CSLA.Library
nocol = Convert.ToInt16(tmpNew[5]);
stmp = tmpNew.Length <= 6 ? null : tmpNew[6];
}
// some plants (Wolf Creek, Turkey Point) have two line titles in their templates with "[(0014])" representing the hard return in the title
if (stmp != null)
stmp = stmp.Replace("[(0014])", "\\line "); // Hard Return
TPlate tp = new TPlate(level, type, start, width, row, nocol, stmp);
_Templates.Add(tp);
cnt++;