in PsfShimMonitor/MainWindow.xaml.cs [747:858]
private void SearchForString()
{
int totalfound = 0;
int onfound = 0;
try
{
string search = SearchStringTB.Text.ToUpper();
bool newsearch = !search.Equals(LastSearchString);
int nextfound = -1;
if (!newsearch && LastSearchIndex >= 0)
{
nextfound = LastSearchIndex;
}
int index = 0;
foreach (EventItem ei in _FilteredEventItems)
{
ei.IsCurrentSearchItem = false;
if (search.Length > 0)
{
if (ei.Event != null)
{
if (ei.ProcessID.ToString().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.ProcessName.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.Event.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.Inputs.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.Result.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.Outputs.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else if (ei.Caller.ToUpper().Contains(search))
{
ei.IsHighlighted = true;
}
else
{
ei.IsHighlighted = false;
}
}
else
{
ei.IsHighlighted = false;
}
}
else
{
ei.IsHighlighted = false;
}
if (ei.IsHighlighted)
{
totalfound++;
if (!ei.IsHidden)
{
if (newsearch && nextfound == -1)
{
nextfound = index;
ei.IsCurrentSearchItem = true;
onfound = totalfound;
}
else if (!newsearch && nextfound <= LastSearchIndex)
{
nextfound = index;
ei.IsCurrentSearchItem = true;
onfound = totalfound;
}
}
}
index++;
}
EventsGrid.Items.Refresh();
if (nextfound >= 0)
{
EventsGrid.ScrollIntoView(_FilteredEventItems[nextfound]);
}
if (totalfound > 0)
{
SearchFoundCount.Text = onfound.ToString() + " of " + totalfound.ToString();
}
else
{
SearchFoundCount.Text = "0 found";
}
LastSearchIndex = nextfound;
LastSearchString = search;
}
catch (Exception ex)
{
if (MessageBox.Show(UnexpectedErrorPrompt, ProgramTitle, MessageBoxButton.OKCancel, MessageBoxImage.Error) == MessageBoxResult.Cancel)
{
throw ex;
}
}
}