Exemplo n.º 1
0
        void HookManager_MouseDown(object sender, MouseEventArgs e)
        {
            Point pos = pageViewControl1.PointToClient(e.Location);

            if (_pdfDoc != null && MouseInPage(pos) && e.Button == MouseButtons.Left)
            {
                PDFLibNet.PageLink link = SearchLink(e.Location);
                if (link != null)
                {
                    switch (link.Action.Kind)
                    {
                    case LinkActionKind.actionGoTo:

                        PDFLibNet.PageLinkGoTo plgo = (link.Action as PDFLibNet.PageLinkGoTo);
                        if (plgo.Destination != null)
                        {
                            _pdfDoc.CurrentPage = plgo.Destination.Page;
                            PointF loc = _pdfDoc.PointUserToDev(new PointF((float)plgo.Destination.Left, (float)plgo.Destination.Top));
                            if (plgo.Destination.ChangeTop)
                            {
                                ScrolltoTop((int)loc.Y);
                            }
                            else
                            {
                                ScrolltoTop(0);
                            }
                            _pdfDoc.RenderPage(pageViewControl1.Handle);
                            Render();
                        }
                        else if (plgo.DestinationName != null)
                        {
                        }
                        break;

                    case LinkActionKind.actionURI:
                        PDFLibNet.PageLinkURI uri = (link.Action as PDFLibNet.PageLinkURI);
                        if (MessageBox.Show("Ejecutar aplicación externa?" + Environment.NewLine + uri.URL, Text, MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            System.Diagnostics.Process p = new System.Diagnostics.Process();
                            p.StartInfo.FileName  = GetDefaultBrowserPath();
                            p.StartInfo.Arguments = uri.URL;
                            p.Start();
                        }
                        break;
                    }
                }
                else
                {
                    _pointCurrent   = e.Location;
                    _pointStart     = e.Location;
                    _bMouseCaptured = true;
                }
            }
        }
Exemplo n.º 2
0
        void HookManager_MouseMove(object sender, MouseEventArgs e)
        {
            Point pos = pageViewControl1.PointToClient(e.Location);

            if (_pdfDoc != null)
            {
                if (MouseInPage(pos) && _bMouseCaptured)
                {
                    //Handled by the control
                }
                else if (MouseInPage(pos))
                {
                    //Check if we have the pointer on a link
                    if (getCursorStatus(e) == CursorStatus.Move)
                    {
                        PDFLibNet.PageLink link = SearchLink(e.Location);
                        if (link != null)
                        {
                            pageViewControl1.Cursor = Cursors.Hand;
                        }
                        else
                        {
                            pos = pageViewControl1.PointUserToPage(pos);
                            if (!_pdfDoc.IsBusy && _pdfDoc.Pages.Count > 0 &&
                                _pdfDoc.Pages[_pdfDoc.CurrentPage].HasText(pos.X, pos.Y))
                            {
                                /*if (_pdfDoc.Pages[_pdfDoc.CurrentPage].ImagesCount > 0)
                                 * {
                                 *  Image img = _pdfDoc.Pages[_pdfDoc.CurrentPage].GetImage(0);
                                 *  img.Save("C:\\image_extracted_0.jpg");
                                 * }*/

                                /*img = _pdfDoc.Pages[_pdfDoc.CurrentPage].GetImage(1);
                                 * img.Save("C:\\image_extracted_1.jpg");
                                 * img = _pdfDoc.Pages[_pdfDoc.CurrentPage].GetImage(2);
                                 * img.Save("C:\\image_extracted_2.jpg");*/

                                pageViewControl1.Cursor = Cursors.IBeam;
                            }
                            else
                            {
                                pageViewControl1.Cursor = Cursors.Default;
                            }
                        }
                    }
                }
            }
            _pointCurrent = e.Location; //Update current Point
        }