in Tools/UIRecorder/UIRecorder/MainWindow.xaml.cs [491:541]
private string HighlightPath(int nNodeCount, bool bHighlight)
{
var tr = new TextRange(rtbXPath.Document.ContentStart, rtbXPath.Document.ContentEnd);
string pathText = tr.Text;
if (string.IsNullOrEmpty(pathText))
{
return null;
}
string xpath = pathText;
int nIndex1 = 0;
int nIndex2 = 0;
for (int node = 0; node < nNodeCount; node++)
{
int Len1 = xpath.Length;
xpath = RemoveFirstNode(xpath);
nIndex1 = nIndex2 + 1;
nIndex2 += (Len1 - xpath.Length);
}
if (nIndex2 < nIndex1)
{
return null;
}
if (bHighlight == true)
{
tr.ClearAllProperties();
if (RootSessionPath != null && pathText.Contains(RootSessionPath) == true)
{
var posRoot1 = rtbXPath.Document.ContentStart.GetPositionAtOffset(1, LogicalDirection.Forward);
var posRoot2 = rtbXPath.Document.ContentStart.GetPositionAtOffset(RootSessionPath.Length + 2, LogicalDirection.Forward);
var trRoot = new TextRange(posRoot1, posRoot2);
trRoot.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.LightGray);
}
if (nNodeCount > 0)
{
var pos1 = rtbXPath.Document.ContentStart.GetPositionAtOffset(nIndex1 + 1, LogicalDirection.Forward);
var pos2 = rtbXPath.Document.ContentStart.GetPositionAtOffset(nIndex2 + 2, LogicalDirection.Forward);
tr = new TextRange(pos1, pos2);
tr.ApplyPropertyValue(TextElement.BackgroundProperty, Brushes.LightBlue);
}
}
return pathText.Substring(nIndex1, nIndex2 - nIndex1); //excluding leading quote
}