/// <summary> /// Generates the neccessary search options and performs a find in the specified direction. /// </summary> public void Find(ViewerSearchDirection direction) { string searchDirection = string.Empty; string beginSearchPoint = string.Empty; string endSearchPoint = string.Empty; ViewerSearchOptions searchOptions = (ckMatchCase.Checked ? ViewerSearchOptions.MatchCase : ViewerSearchOptions.None); switch (direction) { case ViewerSearchDirection.Previous: searchDirection = "FindPrevious"; beginSearchPoint = "top"; endSearchPoint = "end"; searchOptions = ViewerSearchOptions.Backward | searchOptions; break; case ViewerSearchDirection.Next: default: searchDirection = "FindNext"; beginSearchPoint = "end"; endSearchPoint = "top"; //searchOptions Search Options already set, no change needed. break; } Find(searchOptions, searchDirection, beginSearchPoint, endSearchPoint); }
/// <summary> /// Performs a find using the specified options and direction from the public Find method. /// </summary> private void Find(ViewerSearchOptions searchOptions, string searchDirection, string beginSearchPoint, string endSearchPoint) { if (_Viewer == null) { throw new ApplicationException(string.Format("Viewer property must be set prior to issuing {0}.", searchDirection)); } if (tbFind.Text.Length == 0) // must have something to find { return; } bool begin = position == null; position = _Viewer.Find(tbFind.Text, position, searchOptions); if (position == null) { if (!begin) // if we didn't start from beginning already; try from bottom { position = _Viewer.Find(tbFind.Text, position, searchOptions); } lStatus.Text = position == null ? "Phrase not found" : string.Format("Reached {0} of report, continued from {1}", beginSearchPoint, endSearchPoint); _Viewer.HighlightPageItem = position; if (position != null) { _Viewer.ScrollToPageItem(position); } } else { lStatus.Text = ""; _Viewer.HighlightPageItem = position; _Viewer.ScrollToPageItem(position); } }