returnArgs = e;
this.Dispatcher.BeginInvoke((System.Action)delegate()
{
this.ListSearchResults.Items.Clear();
});
SearchResults.Clear();
hlt_list.Clear();
if (_viewer.GetDoc() != null)
textSearch = new pdftron.PDF.TextSearch();
else
throw new Exception("WholeDocumentSearchControl Document property cannot be null.");
pdftron.PDF.TextSearch.SearchMode mode = (e.Argument as InformationForSearch).Mode;
textSearch.Begin(_document, SearchTerm, (Int32)mode, 1, _viewer.GetPageCount());
FoundCount = 0;
CurrentPage = 0;
int page_num = 0;
String result_str = string.Empty;
String ambient_str = string.Empty;
Highlights hlts = new Highlights();
try
{
while (true)
{
System.Threading.Thread.Sleep(1);
_document.Lock();
if (bw.CancellationPending)
{
_document.Unlock();
returnArgs.Cancel = true;
return;
}
hlts = new Highlights();
resultCode = textSearch.Run(ref page_num, ref result_str, ref ambient_str, hlts);
CurrentPage = textSearch.GetCurrentPage();
bw.ReportProgress(CurrentPage);
if (resultCode == pdftron.PDF.TextSearch.ResultCode.e_found)
{
SearchResult result = new SearchResult(page_num, result_str, ambient_str, hlts);
SearchResults.Add(result);
hlt_list.Add(hlts);
FoundCount++;
this.Dispatcher.BeginInvoke((System.Action)delegate()
{
TextBlock b = new TextBlock();
TextBlock t = new TextBlock();
b.Text = result.AmbientString;
t.Text = result.ToolTipString;
FormatText(ref b, result.ResultString, FontWeights.Bold);
FormatText(ref t, result.ResultString, FontWeights.Bold);
ToolTipService.SetToolTip(b, t);
ListSearchResults.Items.Add(b);
});
_document.Unlock();
}
else if (resultCode == pdftron.PDF.TextSearch.ResultCode.e_page)
{
_document.Unlock();
}
else
{
_document.Unlock();
return;
}
}
}
catch (pdftron.Common.PDFNetException ex)
{
_document.Unlock();
System.Diagnostics.Debug.WriteLine(ex.ToString());
}