Example #1
0
        /* ----------------------------------------------------------------- */
        /// Destroy
        /* ----------------------------------------------------------------- */
        public static void Destroy(Canvas canvas)
        {
            if (canvas == null)
            {
                return;
            }

            var parent = (ScrollableControl)canvas.Parent;

            foreach (var child in parent.Controls.Find("Canvas", false))
            {
                CanvasPolicy.Close((Canvas)child);
                parent.Controls.Remove(child);
                child.Dispose();
            }
        }
Example #2
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);
            }
        }