This commit is contained in:
parent
7108411a49
commit
edfc3d71b0
@ -19,23 +19,23 @@ namespace VEPROMS.CSLA.Library
|
||||
public void FixTransitionText(TransitionInfo tran)
|
||||
{
|
||||
string transText = tran.ResolvePathTo();
|
||||
string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* ([^#]*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:Transition[^:]*?:{0} {1}( [0-9]*){{1,2}}\[END>", tran.TranType, tran.TransitionID);
|
||||
//string lookFor = string.Format(@"<START\]\\v0 ([^#]*?)\\v #Link:Transition[^:]*?:{0} {1} [0-9]*\[END>", tran.TranType, tran.TransitionID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[1];
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != transText)
|
||||
Text = Text.Substring(0, g.Index) + transText + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
public void FixContentText(RoUsageInfo rousg, string newvalue)
|
||||
{
|
||||
string lookFor = string.Format(@"<START\]\\v0 (.*?)\\v #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:ReferencedObject:{0} .*?\[END>", rousg.ROUsageID);
|
||||
Match m = Regex.Match(Text, lookFor);
|
||||
if (m != null && m.Groups.Count > 1)
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[1];
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
if (g.ToString() != newvalue)
|
||||
Text = Text.Substring(0, g.Index) + newvalue + Text.Substring(g.Index + g.Length);
|
||||
}
|
||||
|
@ -1039,9 +1039,11 @@ namespace VEPROMS.CSLA.Library
|
||||
retval = Regex.Replace(retval, @"\\ul ?", "");
|
||||
retval = Regex.Replace(retval, @"\\i0 ?", "");
|
||||
retval = Regex.Replace(retval, @"\\i ?", "");
|
||||
retval = Regex.Replace(retval, @"\\super ?", "");
|
||||
retval = Regex.Replace(retval, @"\\sub ?", "");
|
||||
retval = Regex.Replace(retval, @"\\nosupersub ?", "");
|
||||
//retval = Regex.Replace(retval, @"\\super ?", "");
|
||||
//retval = Regex.Replace(retval, @"\\sub ?", "");
|
||||
//retval = Regex.Replace(retval, @"\\nosupersub ?", "");
|
||||
retval = Regex.Replace(retval, @"\\up[30] ?", "");
|
||||
retval = Regex.Replace(retval, @"\\dn[30] ?", "");
|
||||
return retval;
|
||||
}
|
||||
private static string StripLinks(string rtf)
|
||||
|
@ -4670,6 +4670,14 @@ namespace VEPROMS.CSLA.Library
|
||||
return LazyLoad(ref _UnderlineRo, "@UnderlineRo");
|
||||
}
|
||||
}
|
||||
private LazyLoad<bool> _CapFirstLetterInHighRO;
|
||||
public bool CapFirstLetterInHighRO
|
||||
{
|
||||
get
|
||||
{
|
||||
return LazyLoad(ref _CapFirstLetterInHighRO, "@CapFirstLetterInHighRO");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
@ -827,18 +827,21 @@ namespace PrintMSWord
|
||||
|
||||
string tmp = DisplayRO.ConvertFortranFormatToScienctificNotation(roValue);
|
||||
// Look for superscript or subscript and insert the appropriate commands
|
||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||
//Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) ");
|
||||
if (roMatch.Groups.Count == 4)// Superscript or subscript found
|
||||
{
|
||||
sel.Font.Color = LBWdColor.wdColorRed;
|
||||
while (roMatch.Groups.Count == 4)
|
||||
{
|
||||
sel.TypeText(roMatch.Groups[1].Value); // output the text preceeding the super or sub command
|
||||
sel.Font.Position = roMatch.Groups[2].Value=="super" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
sel.Font.Position = roMatch.Groups[2].Value == "up3" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
//sel.Font.Position = roMatch.Groups[2].Value == "super" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
sel.TypeText(roMatch.Groups[3].Value); // output the superscript or subscript
|
||||
sel.Font.Position = 0; // restore the vertical position
|
||||
tmp = tmp.Substring(roMatch.Length); // remove the processed text
|
||||
roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub "); // check to see if the text contain another super or sub
|
||||
//roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub "); // check to see if the text contain another super or sub
|
||||
roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) "); // check to see if the text contain another super or sub
|
||||
}
|
||||
if(tmp != "")// Add any remaining text
|
||||
sel.TypeText(tmp);
|
||||
|
@ -446,18 +446,21 @@ namespace PrintMSWord
|
||||
|
||||
string tmp = DisplayRO.ConvertFortranFormatToScienctificNotation(roValue);
|
||||
// Look for superscript or subscript and insert the appropriate commands
|
||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||
//Match roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub ");
|
||||
Match roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) ");
|
||||
if (roMatch.Groups.Count == 4)// Superscript or subscript found
|
||||
{
|
||||
sel.Font.Color = LBWdColor.wdColorRed;
|
||||
while (roMatch.Groups.Count == 4)
|
||||
{
|
||||
sel.TypeText(roMatch.Groups[1].Value); // output the text preceeding the super or sub command
|
||||
sel.Font.Position = roMatch.Groups[2].Value=="super" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
//sel.Font.Position = roMatch.Groups[2].Value=="super" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
sel.Font.Position = roMatch.Groups[2].Value == "up3" ? 2 : -2; // Shift the vertical position for super or sub
|
||||
sel.TypeText(roMatch.Groups[3].Value); // output the superscript or subscript
|
||||
sel.Font.Position = 0; // restore the vertical position
|
||||
tmp = tmp.Substring(roMatch.Length); // remove the processed text
|
||||
roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub "); // check to see if the text contain another super or sub
|
||||
//roMatch = Regex.Match(tmp, @"(.*?)\\(super|sub) (.*?)\\nosupersub "); // check to see if the text contain another super or sub
|
||||
roMatch = Regex.Match(tmp, @"(.*?)\\(up3|dn3) (.*?)\\(up0|dn0) "); // check to see if the text contain another super or sub
|
||||
}
|
||||
if(tmp != "")// Add any remaining text
|
||||
sel.TypeText(tmp);
|
||||
@ -540,7 +543,7 @@ namespace PrintMSWord
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AddInfo("Error==={0:s.ffff}==========>{1} - {2}", DateTime.Now, ex.GetType().Name, ex.Message);
|
||||
AddInfo("RemovePDFFiles Error==={0:s.ffff}==========>{1} - {2}", DateTime.Now, ex.GetType().Name, ex.Message);
|
||||
Application.DoEvents();
|
||||
}
|
||||
}
|
||||
|
@ -783,8 +783,10 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
// Convert E style numbers to RTF with \super and \nosupersub
|
||||
string retval = Regex.Replace(str, "([+-]?)([0-9]+)[.]([0-9]*?)0*E([+-]?[0-9]+)", new MatchEvaluator(FixFortranNumber));
|
||||
retval = Regex.Replace(retval, "[#](.*?)[#]", "\\super $1\\nosupersub ");// DOS Superscript
|
||||
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\sub $1\\nosupersub ");// DOS Subscript
|
||||
//retval = Regex.Replace(retval, "[#](.*?)[#]", "\\super $1\\nosupersub ");// DOS Superscript
|
||||
//retval = Regex.Replace(retval, "[~](.*?)[~]", "\\sub $1\\nosupersub ");// DOS Subscript
|
||||
retval = Regex.Replace(retval, "[#](.*?)[#]", "\\up3 $1\\up0 ");// DOS Superscript
|
||||
retval = Regex.Replace(retval, "[~](.*?)[~]", "\\dn3 $1\\dn0 ");// DOS Subscript
|
||||
return retval;
|
||||
}
|
||||
private static string FixFortranNumber(Match match)
|
||||
@ -798,7 +800,7 @@ namespace Volian.Controls.Library
|
||||
else // A number with a decimal point
|
||||
sb.Append(match.Groups[2].Value + "." + match.Groups[3].Value + "x10");
|
||||
// Add the exponent as superscript
|
||||
return sb.ToString() + "\\super " + match.Groups[4].Value + "\\nosupersub ";
|
||||
return sb.ToString() + "\\up3 " + match.Groups[4].Value + "\\up0 ";
|
||||
}
|
||||
|
||||
//private string ConvertDOSSuperAndSubScripts(string instr)
|
||||
|
@ -124,33 +124,37 @@ namespace Volian.Controls.Library
|
||||
(_FieldToEdit == E_FieldToEdit.StepText || _FieldToEdit == E_FieldToEdit.Text) &&
|
||||
(!itemInfo.IsSection && !itemInfo.IsProcedure) && (itemInfo.IsTable || itemInfo.IsFigure);
|
||||
bool wordsShouldBeReplaced = epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit;
|
||||
if (_MyFormat == null)
|
||||
Console.WriteLine(this._MyItemInfo.MyItemInfoUnique);
|
||||
bool numbersShouldBeFormated = (!_MyFormat.PlantFormat.FormatData.SectData.StepSectionData.FortranFormatNumbers && (epMode == E_EditPrintMode.Print || vwMode == E_ViewMode.View || noEdit));
|
||||
int typ = ((int)itemInfo.MyContent.Type) % 10000;
|
||||
bool tableHasBorder = tableShouldBeOutlined ? itemInfo.ActiveFormat.PlantFormat.FormatData.StepDataList[typ].Type.IndexOf(@"Borderless") < 0 : false;
|
||||
bool ROsShouldBeAdjusted = wordsShouldBeReplaced; // same logical value
|
||||
|
||||
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder);
|
||||
text = CreateRtf(colorLinks, text, tableShouldBeOutlined, wordsShouldBeReplaced, numbersShouldBeFormated, tableHasBorder, ROsShouldBeAdjusted);
|
||||
StartText = text;
|
||||
}
|
||||
public DisplayText(string text, VE_Font vFont, bool colorLinks)
|
||||
{
|
||||
TextFont = vFont;
|
||||
StartText = CreateRtf(colorLinks, text, false, false, false, false);
|
||||
StartText = CreateRtf(colorLinks, text, false, false, false, false, false);
|
||||
}
|
||||
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder)
|
||||
private string CreateRtf(bool colorLinks, string text, bool tableShouldBeOutlined, bool wordsShouldBeReplaced, bool numbersShouldBeFormated, bool tableHasBorder, bool ROsShouldBeAdjusted)
|
||||
{
|
||||
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
|
||||
// actual edit mode are replace words left as is.
|
||||
if (wordsShouldBeReplaced)
|
||||
text = DoReplaceWords(text);
|
||||
// Adjust RO display
|
||||
if (ROsShouldBeAdjusted)
|
||||
text = DoROAdjustments(text);
|
||||
// add colors around links:
|
||||
if (colorLinks)
|
||||
{
|
||||
text = Regex.Replace(text, @"(<START\].*?\\v0) ", @"$1\cf1 ");
|
||||
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
|
||||
int indxcf = text.IndexOf("cf1");
|
||||
while (indxcf != -1)
|
||||
{
|
||||
int indxend = text.IndexOf(@"\v", indxcf);
|
||||
text = text.Insert(indxend, @"\cf0");
|
||||
indxcf = text.IndexOf(@"cf1", indxend);
|
||||
}
|
||||
}
|
||||
text = DoColorLinks(text);
|
||||
//Console.WriteLine(text);
|
||||
// adjust formatting of exponents
|
||||
if (numbersShouldBeFormated)
|
||||
text = DoFortranFormat(text);
|
||||
// determine whether the table/figure should be outlined:
|
||||
if (tableShouldBeOutlined)
|
||||
{
|
||||
@ -159,13 +163,6 @@ namespace Volian.Controls.Library
|
||||
text = myTable.Lines.ToString();
|
||||
}
|
||||
|
||||
// if in print mode, view mode, or non-active richtextbox do replace words. Only if in
|
||||
// actual edit mode are replace words left as is.
|
||||
|
||||
if (wordsShouldBeReplaced) text = DoReplaceWords(text);
|
||||
|
||||
// adjust formatting of exponents
|
||||
if (numbersShouldBeFormated) text = DoFortranFormat(text);
|
||||
|
||||
// as a precaution, convert any \~ to \u160?. This is for Hard spaces. see the commentary in the
|
||||
// save portion of this code for an explanation.
|
||||
@ -178,7 +175,7 @@ namespace Volian.Controls.Library
|
||||
// Now put symbol (for fixed fonts) or unicode font (proportional) around symbols
|
||||
// These fonts are VESymbFix & Arial Unicode MS respectively, and the font table
|
||||
// is actually defined in the StepRTB code.
|
||||
int indxsym = text.IndexOf(@"\u");
|
||||
int indxsym = NextUnicode(text,0);//text.IndexOf(@"\u");
|
||||
while (indxsym != -1)
|
||||
{
|
||||
int incrindx = 3;
|
||||
@ -195,7 +192,48 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
incrindx = 5;
|
||||
}
|
||||
indxsym = text.IndexOf(@"\u", indxsym + incrindx);
|
||||
indxsym = NextUnicode(text, indxsym + incrindx);//text.IndexOf(@"\u", indxsym + incrindx);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static string DoColorLinks(string text)
|
||||
{
|
||||
text = Regex.Replace(text, @"(<START\](\\[^v \\]+)*\\v0)((?= |\\))", @"$1\cf1");
|
||||
//text = Regex.Replace(text, @"<START]\b0\v0 ", @"<START]\b0\v0\cf1 ");
|
||||
int indxcf = text.IndexOf("cf1");
|
||||
while (indxcf != -1)
|
||||
{
|
||||
int indxend = text.IndexOf(@"\v", indxcf);
|
||||
text = text.Insert(indxend, @"\cf0");
|
||||
indxcf = text.IndexOf(@"cf1", indxend);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
private int NextUnicode(string text, int offset)
|
||||
{
|
||||
Match m = Regex.Match(text.Substring(offset), @"\\u[0-9a-fA-F]");
|
||||
if (m.Success)
|
||||
return m.Index + offset;
|
||||
return -1;
|
||||
}
|
||||
private string DoROAdjustments(string text)
|
||||
{
|
||||
string strippedText = StaticStripRtfCommands(text);
|
||||
string lookFor = string.Format(@"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(ReferencedObject|Transition[^:]*?):.*?\[END>");
|
||||
MatchCollection matches = Regex.Matches(text, lookFor);
|
||||
for (int i = matches.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Match m = matches[i];
|
||||
if (m != null && m.Groups.Count > 6 && m.Groups[6].ToString() == "ReferencedObject")
|
||||
{
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
string beforeRO = StaticStripRtfCommands(text.Substring(0, g.Index));
|
||||
string afterRO = StaticStripRtfCommands(text.Substring(g.Index + g.Length));
|
||||
string newvalue = DoROFormatFlags(g.ToString(), beforeRO, afterRO);
|
||||
if (g.ToString() != newvalue)
|
||||
text = text.Substring(0, g.Index) + newvalue + text.Substring(g.Index + g.Length);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
}
|
||||
@ -214,7 +252,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
string fnum = m.Groups[1].Value;
|
||||
string supnum = m.Groups[2].Value;
|
||||
string newstr = string.Format(@"{0}x10\super {1}\nosupersub ", fnum, supnum);
|
||||
//string newstr = string.Format(@"{0}x10\super {1}\nosupersub ", fnum, supnum);
|
||||
string newstr = string.Format(@"{0}x10\up3 {1}\up0 ", fnum, supnum);
|
||||
retstr = retstr.Replace(m.Value, newstr);
|
||||
}
|
||||
return retstr;
|
||||
@ -294,7 +333,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Save Failed with error: {0}", ex.Message);
|
||||
Console.WriteLine("DisplayText Save Failed with error: {0} - {1}\r\n{2}", ex.GetType().Name, ex.Message, ex.StackTrace);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -667,18 +706,24 @@ namespace Volian.Controls.Library
|
||||
return token;
|
||||
if (Regex.IsMatch(token, @"^\\ul.*$"))
|
||||
return token; // Underline
|
||||
if (Regex.IsMatch(token, @"^\\up[0-9] ?$"))
|
||||
return token; // shift up (superscript)
|
||||
break;
|
||||
case 'd':
|
||||
if (Regex.IsMatch(token, @"^\\dn[0-9] ?$"))
|
||||
return token; // shift down (subscript)
|
||||
break;
|
||||
case '\'': // Special Character
|
||||
return token;
|
||||
case 'b': // Bold
|
||||
return token;
|
||||
case 's': // sub or super....
|
||||
if (Regex.IsMatch(token, @"^\\sub ?$")) return token;
|
||||
if (Regex.IsMatch(token, @"^\\super ?$")) return token;
|
||||
break;
|
||||
case 'n': // nosubsuper...
|
||||
if (Regex.IsMatch(token, @"^\\nosupersub ?$")) return token;
|
||||
break;
|
||||
//case 's': // sub or super....
|
||||
// if (Regex.IsMatch(token, @"^\\sub ?$")) return token;
|
||||
// if (Regex.IsMatch(token, @"^\\super ?$")) return token;
|
||||
// break;
|
||||
//case 'n': // nosubsuper...
|
||||
// if (Regex.IsMatch(token, @"^\\nosupersub ?$")) return token;
|
||||
// break;
|
||||
case 'i': // Italics
|
||||
return token;
|
||||
case '{': // look for escape for curly braces:
|
||||
@ -713,7 +758,7 @@ namespace Volian.Controls.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("{0}-{1}",ex.GetType().Name, ex.Message);
|
||||
Console.WriteLine("StaticReplaceRTFClause {0} - {1}", ex.GetType().Name, ex.Message);
|
||||
}
|
||||
return "";//Strip All
|
||||
}
|
||||
@ -776,7 +821,7 @@ namespace Volian.Controls.Library
|
||||
retval = retval.TrimEnd(' ');
|
||||
return retval;
|
||||
}
|
||||
//public static string StaticStripRtfCommands(string rtf, ItemInfo itmInfo)
|
||||
// This is used in the DataLoader
|
||||
public static string StaticStripRtfCommands(string rtf)
|
||||
{
|
||||
// replace \{ & \} with (![ & (!] respectively and then redo at end. The curly braces
|
||||
@ -939,6 +984,131 @@ namespace Volian.Controls.Library
|
||||
vte.Type = (text[linkindx+16]=='R')?E_TextElementType.TransitionRange:E_TextElementType.Transition;
|
||||
return DoLinkElements(text, index, vte);
|
||||
}
|
||||
|
||||
//private int GetLastLower(string stepText)
|
||||
//{
|
||||
// // TO DO: need to check AlwaysUpperCase format setting - this was not yet converted as of 17Jun2010
|
||||
// // if (AlwaysUpperCase[steptype]) return (stepText.Length-1);
|
||||
|
||||
// int idx = stepText.Length - 1;
|
||||
// while (idx >= 0 && !(char.IsLower(stepText[idx]) && stepText[idx] != 's')) idx--;
|
||||
// if (idx < 0) idx = stepText.Length - 1; // entire string is uppercased set return value to end of string
|
||||
// return idx;
|
||||
//}
|
||||
|
||||
//private bool IsSpaceOrHardSpace(char ch)
|
||||
//{
|
||||
// string spaces = @" \u160?";
|
||||
// return (spaces.IndexOf(ch) >= 0);
|
||||
//}
|
||||
private string DoROFormatFlags(string roText, string beforeRO, string afterRO)
|
||||
{
|
||||
string rtnstr = roText;
|
||||
beforeRO = Regex.Replace(beforeRO, @"(\\[^v \\]+)*\\v(\\[^v \\]+)* .*?\\v0(\\[^v \\]+)*( |$)", "");
|
||||
afterRO = Regex.Replace(afterRO, @"(\\[^v \\]+)*\\v(\\[^v \\]+)* .*?\\v0(\\[^v \\]+)*( |$)", "");
|
||||
|
||||
// Underline all ROs, values and Units
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UnderlineRo)
|
||||
{
|
||||
// TO DO: Need to check if step text is already underlined
|
||||
rtnstr = @"\ul " + rtnstr + @"\ulnone ";
|
||||
}
|
||||
|
||||
// UpcaseAllRoUnits - Uppercases ALL ROs units everywhere.
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UpcaseAllRoUnits)
|
||||
return UpperCaseUnits(rtnstr);
|
||||
|
||||
//Forces the units for a RO to be uppercased for high level steps
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.CapHighRo &&_MyItemInfo.IsHigh)
|
||||
return UpperCaseUnits(rtnstr);
|
||||
|
||||
// Caps ROs anywhere if no lower case text follows
|
||||
// and an upper case letter immediately precedes the RO.
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.CapRoIfLastLower && Regex.IsMatch(afterRO,".*[a-z].*") && char.IsUpper(LastAlpha(beforeRO)))
|
||||
{
|
||||
//int indx = startLinkText - 1;
|
||||
//int indx2 = endLinkText + 1;
|
||||
//while (indx > 0 && !IsSpaceOrHardSpace(stepText[indx])) indx--; // find character before RO
|
||||
//while (indx2 <= stepText.Length && !IsSpaceOrHardSpace(stepText[indx2])) indx2++; // find character after RO
|
||||
|
||||
//if (indx >= 0 && char.IsUpper(stepText[indx]) && indx2 > GetLastLower(stepText))
|
||||
// doUpCase = true;
|
||||
return UpperCaseUnits(rtnstr);
|
||||
}
|
||||
|
||||
// If a RO follows a "- " then it will be uppercased
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UpRoAftrDash && Regex.IsMatch(beforeRO, @".*\\u8209\?( |\\u160\?)$"))
|
||||
{
|
||||
//int indx = startLinkText - 1;
|
||||
//while (indx > 0 && !IsSpaceOrHardSpace(stepText[indx])) indx--; // find character before RO
|
||||
//string prefix = indx >= 7?stepText.Substring(indx-7,8):"";
|
||||
//doUpCase = (prefix == @"\u8209? "); // Dash character before RO
|
||||
return UpperCaseUnits(rtnstr);
|
||||
}
|
||||
|
||||
// Uppercase the RO Unit if the previous letter is uppercase
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.UpRoIfPrevUpper && char.IsUpper(LastAlpha(beforeRO)))
|
||||
{
|
||||
//doUpCase = (char.IsUpper(stepText[startLinkText - 1]));
|
||||
return UpperCaseUnits(rtnstr);
|
||||
|
||||
}
|
||||
|
||||
//CapFirstLetterInHighRO - Cap only the first letters of the units in a high level RO
|
||||
// note: used in FLP (Turkey Point) format
|
||||
if (_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.CapFirstLetterInHighRO && _MyItemInfo.IsHigh)
|
||||
{
|
||||
int idx = 0;
|
||||
string tstr = "";
|
||||
while (idx < rtnstr.Length && !char.IsLetter(rtnstr[idx])) tstr += rtnstr[idx++].ToString();
|
||||
if (idx < rtnstr.Length)
|
||||
{
|
||||
tstr += char.ToUpper(rtnstr[idx]).ToString();
|
||||
if (idx + 1 < rtnstr.Length)
|
||||
tstr += rtnstr.Substring(idx + 1);
|
||||
}
|
||||
rtnstr = tstr;
|
||||
}
|
||||
|
||||
//In a sequence of RO values, the unit appears with every value
|
||||
//(e.g., "25 gpm and 30 gpm" vs. "25 and 30 gpm")
|
||||
//if (!_MyItemInfo.ActiveFormat.PlantFormat.FormatData.ROData.AllUnits)
|
||||
//{
|
||||
// int idx = rtnstr.LastIndexOf(' ');
|
||||
// if (idx > 0)
|
||||
// {
|
||||
// StringBuilder sb = new StringBuilder();
|
||||
// string lastunit = rtnstr.Substring(idx); // RO unit including preceeding space
|
||||
// int idx2 = rtnstr.IndexOf(lastunit);
|
||||
// int si = 0;
|
||||
// while (idx2 < idx)
|
||||
// {
|
||||
// sb.Append(rtnstr.Substring(si, idx2 - si));
|
||||
// si = idx2 + lastunit.Length;
|
||||
// idx2 = rtnstr.IndexOf(lastunit, si);
|
||||
// }
|
||||
// sb.Append(rtnstr.Substring(si));
|
||||
// rtnstr = sb.ToString();
|
||||
// }
|
||||
//}
|
||||
|
||||
return rtnstr;
|
||||
}
|
||||
|
||||
private string UpperCaseUnits(string rtnstr)
|
||||
{
|
||||
// After converting the value to uppercase, change X10 to x10 to handle Fortran Formatted numbers
|
||||
return rtnstr.ToUpper().Replace("X10", "x10");
|
||||
}
|
||||
|
||||
// Find the last Alphabetical character
|
||||
private char LastAlpha(string beforeRO)
|
||||
{
|
||||
Match m = Regex.Match(beforeRO, ".*([a-zA-Z])[^a-zA-Z]*");
|
||||
if (m.Success) return m.Groups[1].ToString()[0];
|
||||
return '\0';
|
||||
}
|
||||
|
||||
private int DoLinkElements(string text, int index, displayLinkElement vte)
|
||||
{
|
||||
// Find the 'end comment' for the <START], can't count characters
|
||||
@ -947,6 +1117,9 @@ namespace Volian.Controls.Library
|
||||
int linkIndx = text.IndexOf(@"#Link", index);
|
||||
int endStartTknIndx = text.IndexOf(@"\v0 ", index);
|
||||
int endTextIndx = text.IndexOf(@"\v ", endStartTknIndx); // find end of text
|
||||
int endTextIndx2 = text.IndexOf(@"\v\up0 ", endStartTknIndx); // find end of text
|
||||
if(endTextIndx2 > 0 && (endTextIndx < 0 || endTextIndx > endTextIndx2))
|
||||
endTextIndx = endTextIndx2;
|
||||
vte.Text = text.Substring(endStartTknIndx + 4, endTextIndx - endStartTknIndx - 4); // 4 for \v0
|
||||
|
||||
// Now get the link part. It can be terminated by a '\v0' or an [END>
|
||||
@ -962,7 +1135,12 @@ namespace Volian.Controls.Library
|
||||
tmptxt = FixTransition(vte.Link, vte.Text);
|
||||
vte.Text = tmptxt;
|
||||
}
|
||||
|
||||
//else
|
||||
//{
|
||||
// tmptxt = DoROFormatFlags(vte.Text, text, index, endLinkIndx);
|
||||
// vte.Text = tmptxt;
|
||||
//}
|
||||
|
||||
// Now get the entire text & link. Account for various ending possibilities:
|
||||
// ends with '\v0\'; ends with '\v0 '; ends with '\v0' (end of string);
|
||||
// ends with '[END>' if two in a row - will have <START]
|
||||
@ -1144,8 +1322,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_TextAndLink != null)
|
||||
{
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\]\\v0 (.*?)\\v #Link:(.*?)\[END>");
|
||||
return m.Groups[1].ToString();
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>");
|
||||
return m.Groups[3].ToString();
|
||||
}
|
||||
return _Text;
|
||||
}
|
||||
@ -1153,8 +1331,8 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_TextAndLink != null)
|
||||
{
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\]\\v0 (.*?)\\v #Link:(.*?)\[END>");
|
||||
System.Text.RegularExpressions.Group g = m.Groups[1];
|
||||
Match m = Regex.Match(_TextAndLink, @"<START\](\\[^v \\]+)*\\v0(\\[^v \\]+)* (.*?)(\\[^v \\]+)*\\v(\\[^v \\]+)* #Link:(.*?)\[END>");
|
||||
System.Text.RegularExpressions.Group g = m.Groups[3];
|
||||
_TextAndLink = _TextAndLink.Substring(0, g.Index) + value + _TextAndLink.Substring(g.Index + g.Length);
|
||||
}
|
||||
_Text = value;
|
||||
|
@ -17,7 +17,9 @@ namespace Volian.Controls.Library
|
||||
{
|
||||
if (_LinkInfoText == null) return;
|
||||
// First parse the string
|
||||
_LinkInfoText = _LinkInfoText.Replace(@"\v ", "");
|
||||
if (_LinkInfoText.Contains(@"\v"))
|
||||
throw new Exception("LinkText.ParseLink found RTF token");
|
||||
//_LinkInfoText = _LinkInfoText.Replace(@"\v ", ""); // this is not needed because this is selected Text does not contain RTF tokens
|
||||
// for tran : "2, #, #, # and 4#Link:TransitionRange:2 10 173 166"
|
||||
Match m = Regex.Match(_LinkInfoText, @"(.*)[#]Link:([A-Za-z]*):(.*)");
|
||||
_MyValue = m.Groups[1].Value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user