From 1a3ef465bfbf6533313c880b300cc18d5efc769c Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 5 Jun 2014 18:46:51 +0000 Subject: [PATCH] Added logic to ReplaceWord logic so that if the ReplaceWord inserts a hard return the hard return will not be added at the beginning of a step. The includes RTF formatting of underline and bold and also an asterisk at the beginning of a step. --- PROMS/Volian.Controls.Library/DisplayText.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/PROMS/Volian.Controls.Library/DisplayText.cs b/PROMS/Volian.Controls.Library/DisplayText.cs index 6e92e882..39c736c7 100644 --- a/PROMS/Volian.Controls.Library/DisplayText.cs +++ b/PROMS/Volian.Controls.Library/DisplayText.cs @@ -1836,6 +1836,12 @@ namespace Volian.Controls.Library while (index < Count - 1 && Values[index + 1].MyMatch.Index < (myMatch.Index + myMatch.Length)) Remove(Values[index + 1].MyMatch.Index); } + public bool StartsWith(string text, int index, params string[] examples) + { + foreach (string str in examples) + if (str.Length == index && str == text.Substring(0, str.Length)) return true; + return false; + } public string ReplaceMatches() { int offset = 0; @@ -1849,7 +1855,9 @@ namespace Volian.Controls.Library //if(offset != 0 || foundMatch.MyMatch.Index != 0 || !foundMatch.MyWord.ReplaceWith.StartsWith(@"{\par}")) //{ string with = foundMatch.MyWord.ReplaceWith; - if (offset == 0 && foundMatch.MyMatch.Index == 0 && with.StartsWith(@"{\par}")) with = with.Replace(@"{\par}", ""); + if (offset == 0 && with.StartsWith(@"{\par}")) + if(StartsWith(text,foundMatch.MyMatch.Index,"",@"\ul ",@"\b ",@"* ",@"* \ul ",@"* \b ",@"*",@"*\ul ",@"*\b ")) + with = with.Replace(@"{\par}", ""); bool IsBold = ((_Font.Style & E_Style.Bold) == E_Style.Bold) || (_MyItemInfo.FormatStepData != null && _MyItemInfo.FormatStepData.BoldHighLevel && _MyItemInfo.IsRNOPart && _MyItemInfo.MyParent.IsHigh ); if (IsBold && with.Contains(@"\b "))