Ejemplo n.º 1
0
        public void Navigate(Type viewModelType, INavigatorViewModel containerViewModel)
        {
            Type pageType = new TypesRegistry().GetViewType(viewModelType);

            _containerPage = containerViewModel.AssociatedPage;

            _containerPage.Frame.Navigate(pageType);

            NavigatedToPage?.Invoke(null, null);
        }
Ejemplo n.º 2
0
        private void OnBackRequested(object sender, BackRequestedEventArgs e)
        {
            if (!_containerPage.Frame.CanGoBack)
            {
                return;
            }

            _containerPage.Frame.GoBack();
            NavigatedToPage?.Invoke(sender, null);
            e.Handled = true;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void NavigateToPage(int pageIndex)
        {
            if (pageIndex < 1 || pageIndex > PageCount)
            {
                return;
            }

            var previousCurrentPageIndex = CurrentPageIndex;

            SetCurrentInformation(GetPage(pageIndex - 1));
            NavigatedToPage?.Invoke(this, new NavigatedToPageEventArgs(previousCurrentPageIndex, CurrentPageIndex));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void NavigateToDestination(IPDFDestination destination)
        {
            if (destination == null)
            {
                return;
            }

            if (destination.PageIndex < 0 || destination.PageIndex >= PageCount)
            {
                return;
            }

            var previousCurrentPageIndex = CurrentPageIndex;

            SetCurrentInformation(GetPage(destination.PageIndex));
            NavigatedToPage?.Invoke(this, new NavigatedToPageEventArgs(previousCurrentPageIndex, CurrentPageIndex));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void NavigateToFindPlace(IPDFFindPosition position)
        {
            if (position == null)
            {
                return;
            }

            ClearSelectionRectangles();
            if (position is PDFFindPosition ourPosition &&
                position.Page.RelatedPage is PDFPage ourPage)
            {
                PageIndexWithSelections = ourPage.PageIndex;
                var positionX      = -1;
                var positionY      = -1;
                var pageHandle     = _mainComponent.PDFiumBridge.FPDF_LoadPage(_mainComponent.PDFiumDocument, ourPosition.Page.RelatedPage.PageIndex);
                var textPageHandle = _mainComponent.PDFiumBridge.FPDFText_LoadPage(pageHandle);

                var rectCount = _mainComponent.PDFiumBridge.FPDFText_CountRects(textPageHandle, ourPosition.Position, ourPosition.Length);
                for (int i = 0; i < rectCount; i++)
                {
                    double left, top, right, bottom;
                    left = top = right = bottom = 0;
                    if (_mainComponent.PDFiumBridge.FPDFText_GetRect(textPageHandle, i, ref left, ref top, ref right, ref bottom))
                    {
                        AddSelectionRectangle(left, top, right, bottom);
                        if (positionX == -1)
                        {
                            positionX = (int)Math.Round(left, 0);
                            positionY = (int)Math.Round(top, 0);
                        }
                    }
                }

                _mainComponent.PDFiumBridge.FPDFText_ClosePage(textPageHandle);
                _mainComponent.PDFiumBridge.FPDF_ClosePage(pageHandle);

                var previousCurrentPageIndex = CurrentPageIndex;
                var currentPageIndex         = position.Page.RelatedPage.PageIndex + 1;
                SetCurrentInformation(position.Page.RelatedPage);
                NavigatedToPage?.Invoke(this, new NavigatedToPageEventArgs(previousCurrentPageIndex, CurrentPageIndex, positionX, positionY));
            }
Ejemplo n.º 6
0
        /// <summary>
        /// <inheritdoc/>
        /// </summary>
        public void PerformAction(IPDFAction action)
        {
            if (action == null)
            {
                return;
            }

            if (action.ActionType != PDFActionType.Goto)
            {
                PerformOutsideAction?.Invoke(this, new PerformActionEventArgs(action));
                return;
            }

            if (action.Destination == null || action.Destination.PageIndex < 0 || action.Destination.PageIndex >= PageCount)
            {
                return;
            }

            var previousCurrentPageIndex = CurrentPageIndex;

            SetCurrentInformation(GetPage(action.Destination.PageIndex));
            NavigatedToPage?.Invoke(this, new NavigatedToPageEventArgs(previousCurrentPageIndex, CurrentPageIndex));
        }