Esempio n. 1
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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);
        }
Esempio n. 2
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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);
        }
Esempio n. 3
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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);
        }
Esempio n. 4
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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);
        }
Esempio n. 5
0
        /* ----------------------------------------------------------------- */
        ///
        /// Open
        ///
        /// <summary>
        /// 指定された PDF ファイルを開いて,最初のページを描画する.
        /// MEMO: パスの記憶場所を検討中.現在は,Parent.Tag を利用
        /// している.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public static void Open(Canvas canvas, string path, string password, FitCondition which)
        {
            if (canvas == null)
            {
                return;
            }
            var engine = canvas.Tag as CanvasEngine;

            if (engine != null)
            {
                CanvasPolicy.Close(canvas);
            }

            var core = new PDF();

            engine             = new CanvasEngine(core);
            canvas.Tag         = engine;
            core.UseMuPDF      = true;
            core.UserPassword  = password;
            core.OwnerPassword = password;

            if (core.LoadPDF(path))
            {
                core.CurrentPage = 1;
                if (which == FitCondition.Height)
                {
                    core.FitToHeight(canvas.Parent.Handle);
                    core.Zoom = core.Zoom - 1; // 暫定
                }
                else if (which == FitCondition.Width)
                {
                    core.FitToWidth(canvas.Parent.Handle);
                    core.Zoom = core.Zoom - 1; // 暫定
                }
                else
                {
                    core.Zoom = 100;
                }
                canvas.Parent.Text = System.IO.Path.GetFileNameWithoutExtension(path);
                canvas.Parent.Tag  = path;
                CanvasPolicy.AsyncRender(canvas, true);
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public static double ZoomIn(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;

            if (core.Zoom < 400)
            {
                core.ZoomIN();
                if (core.Zoom > 400)
                {
                    core.Zoom = 400;
                }
#if CUBE_ASYNC
                CanvasPolicy.AsyncRender(canvas, true);
#else
                CanvasPolicyA.Render(canvas, true);
#endif
            }
            return(core.Zoom);
        }