private void DoJumpToPageNumber(int offset)
        {
            try
            {
                int page_number = Int32.Parse(JumpToPageNumber.Text) + offset;

                PDFDocument pdf_document = GetPDFDocument();
                ASSERT.Test(pdf_document != null);

                if (pdf_document != null)
                {
                    // cycle around when jumping to page #N:
                    int modulo = Math.Max(1, pdf_document.PageCount);
                    page_number  = (page_number - 1) + 2 * modulo; // guaranteed to end up with a positive number here...
                    page_number %= modulo;
                    page_number++;                                 // and make it 1-based again after the MODULO math.

                    pdf_renderer_control.MoveSelectedPageAbsolute(page_number);

                    JumpToPageNumber.Text    = "" + page_number;
                    JumpToPageNumberMax.Text = $" of {pdf_document.PageCountAsString}";
                    JumpToPageNumber.SelectAll();
                }
            }
            catch (Exception ex)
            {
                Logging.Error(ex, "Error jumping to manual page number '{0}'.", JumpToPageNumber.Text);
            }
        }
Exemple #2
0
        void DoJumpToPageNumber(int offset)
        {
            try
            {
                int page_number = Int32.Parse(JumpToPageNumber.Text) + offset;
                if (page_number < 1)
                {
                    page_number = pdf_renderer_control_stats.pdf_document.PDFRenderer.PageCount;
                }
                if (page_number > pdf_renderer_control_stats.pdf_document.PDFRenderer.PageCount)
                {
                    page_number = 1;
                }

                pdf_renderer_control.MoveSelectedPageAbsolute(page_number);

                JumpToPageNumber.Text = "" + page_number;
                JumpToPageNumber.SelectAll();
            }

            catch (Exception ex)
            {
                Logging.Error(ex, "Error jumping to manual page number '{0}'.", JumpToPageNumber.Text);
            }
        }
 private void JumpToPageNumber_GotFocus(object sender, RoutedEventArgs e)
 {
     JumpToPageNumber.SelectAll();
 }