/* ----------------------------------------------------------------- */ /// /// ResetSearch /// /// <summary> /// MEMO: ライブラリが,検索結果を描画する状態を解除する方法を /// 持っていないため,空の文字列で検索してリセットする. /// </summary> /// /* ----------------------------------------------------------------- */ private void ResetSearch(TabPage tab) { var canvas = CanvasPolicy.Get(tab); try { var dummy = new SearchArgs(); CanvasPolicy.Search(canvas, dummy); } catch (Exception /* err */) { } finally { begin_ = true; this.Refresh(canvas); } }
/* ----------------------------------------------------------------- */ /// Search /* ----------------------------------------------------------------- */ private void Search(TabPage tab, string text, bool next) { var canvas = CanvasPolicy.Get(tab); if (canvas == null || text.Length <= 0) return; var message = ""; try { int previousPageNumber = CanvasPolicy.CurrentPage(canvas); var args = new SearchArgs(text); args.FromBegin = begin_; args.IgnoreCase = true; args.WholeDocument = true; args.WholeWord = false; args.FindNext = next; var result = CanvasPolicy.Search(canvas, args); // begin_ = !result; // 最後まで検索したら始めに戻る if (!result) this.SearchTextBox.BackColor = Color.FromArgb(255, 102, 102); else begin_ = false; this.RefreshThumbnail(this.NavigationSplitContainer.Panel1, CanvasPolicy.CurrentPage(canvas), previousPageNumber); this.Refresh(canvas, message); } catch (Exception err) { Utility.ErrorLog(err); message = err.Message; } }
public static bool Search(Canvas canvas, SearchArgs args) { if (canvas == null) return false; var engine = canvas.Tag as CanvasEngine; if (engine == null) return false; var core = engine.Core; if (core == null) return false; core.SearchCaseSensitive = !args.IgnoreCase; var order = args.WholeDocument ? PDFLibNet.PDFSearchOrder.PDFSearchFromdBegin : PDFLibNet.PDFSearchOrder.PDFSearchFromCurrent; int result = 0; if (args.FromBegin) { PreviousSearchResult_ = null; result = core.FindFirst(args.Text, order, false, args.WholeWord); } else if (args.FindNext) result = core.FindNext(args.Text); else result = core.FindPrevious(args.Text); //else result = core.FindText(args.Text, core.CurrentPage, order, !args.IgnoreCase, !args.FindNext, true, args.WholeWord); var prev = core.CurrentPage; if (result > 0 && (PreviousSearchResult_ == null || !Equals(PreviousSearchResult_, core.SearchResults[0]))) { core.CurrentPage = core.SearchResults[0].Page; PreviousSearchResult_ = core.SearchResults[0]; } CanvasPolicy.Render(canvas, false); if (core.CurrentPage != prev) engine.UpdateURL(); return result > 0; }