/* ----------------------------------------------------------------- */ /// /// FitToWidth /// /// <summary> /// ウィンドウ(描画領域)の幅に合わせて拡大/縮小を行う. /// </summary> /// /* ----------------------------------------------------------------- */ public static double FitToWidth(Canvas canvas) { if (canvas == null) { return(0.0); } var engine = canvas.Tag as CanvasEngine; if (engine == null) { return(0.0); } var core = engine.Core; if (core == null) { return(0.0); } core.FitToWidth(canvas.Parent.Handle); core.Zoom = core.Zoom - 1; // 暫定 #if CUBE_ASYNC CanvasPolicy.AsyncRender(canvas, true); #else CanvasPolicy.Render(canvas, true); #endif return(core.Zoom); }
/* ----------------------------------------------------------------- */ /// /// ZoomOut /// /// <summary> /// 現在のページを縮小して再描画する.縮小率はライブラリ依存. /// </summary> /// /* ----------------------------------------------------------------- */ public static double ZoomOut(Canvas canvas) { if (canvas == null) { return(0.0); } var engine = canvas.Tag as CanvasEngine; if (engine == null) { return(0.0); } var core = engine.Core; if (core == null) { return(0.0); } var prev = canvas.Size; core.ZoomOut(); #if CUBE_ASYNC CanvasPolicy.AsyncRender(canvas, true); #else CanvasPolicy.Render(canvas, true); #endif return(core.Zoom); }
/* ----------------------------------------------------------------- */ /// /// Zoom /// /// <summary> /// 指定した倍率で現在のページを再描画する. /// </summary> /// /* ----------------------------------------------------------------- */ public static double Zoom(Canvas canvas, double percent) { if (canvas == null) { return(0.0); } var engine = canvas.Tag as CanvasEngine; if (engine == null) { return(0.0); } var core = engine.Core; if (core == null) { return(0.0); } var prev = canvas.Size; if (percent < core.Zoom || core.Zoom < 400) { core.Zoom = Math.Min(percent, 400); #if CUBE_ASYNC CanvasPolicy.AsyncRender(canvas, true); #else CanvasPolicy.Render(canvas, true); #endif } return(core.Zoom); }
/* ----------------------------------------------------------------- */ /// /// LastPage /// /// <summary> /// 最後のページを描画する. /// </summary> /// /* ----------------------------------------------------------------- */ public static int LastPage(Canvas canvas) { if (canvas == null) { return(0); } var engine = canvas.Tag as CanvasEngine; if (engine == null) { return(0); } var core = engine.Core; if (core == null) { return(0); } core.CurrentPage = core.PageCount; #if CUBE_ASYNC CanvasPolicy.AsyncRender(canvas, false); var control = (ScrollableControl)canvas.Parent; control.AutoScrollPosition = new Point(0, 0); #else if (CanvasPolicy.Render(canvas, false)) { engine.UpdateURL(); var control = (ScrollableControl)canvas.Parent; control.AutoScrollPosition = new Point(0, 0); } #endif return(core.CurrentPage); }
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); }
/* ----------------------------------------------------------------- */ /// /// FitToPage /// /// <summary> /// ウィンドウ(描画領域)に合わせて拡大/縮小を行う. /// </summary> /// /* ----------------------------------------------------------------- */ public static double FitToPage(Canvas canvas) { if (canvas == null) { return(0.0); } var engine = canvas.Tag as CanvasEngine; if (engine == null) { return(0.0); } var core = engine.Core; if (core == null) { return(0.0); } // 横長ならばFitToWidthを、縦長ならばFitToHeightを呼ぶ if (GetOrientation(canvas) == Orientation.portratit) { core.FitToHeight(canvas.Parent.Handle); } else { core.FitToWidth(canvas.Parent.Handle); } core.Zoom = core.Zoom - 1; // 暫定 #if CUBE_ASYNC CanvasPolicy.AsyncRender(canvas, true); #else CanvasPolicy.Render(canvas, true); #endif return(core.Zoom); }