void HandleAnnotationPressedEvent(String pageID)
 {
     if (String.IsNullOrEmpty(pageID))
     {
         AlertView.Show(StringRef.alert, "The book does not contain this page.", StringRef.ok);
     }
     else
     {
         LoadPageViewController(pageID);
     }
 }
示例#2
0
 async void HandleSyncButtonTouchEvent()
 {
     HidePopover();
     if (Reachability.IsDefaultNetworkAvailable())
     {
         await OpenSyncView();
     }
     else
     {
         AlertView.Show(StringRef.connectionFailure, StringRef.connectionRequired, StringRef.ok);
     }
 }
        async private void Connect()
        {
            if (!Reachability.IsDefaultNetworkAvailable())
            {
                AlertView.Show(StringRef.connectionFailure, StringRef.connectionRequired, StringRef.ok);
            }
            else
            {
                try
                {
                    bool notCompatible             = false;
                    WebExceptionStatus errorStatus = WebExceptionStatus.ConnectFailure;
                    cts = new CancellationTokenSource();

                    Settings.WriteUseFormsAuth(false);

                    LoadingView.Show("Connecting", "Please wait while we're connecting to Demo Library...");
                    await eBriefingService.Run(() => StartAuthenticate(out errorStatus, out notCompatible), cts.Token);

                    LoadingView.Hide();
                    cts.Token.ThrowIfCancellationRequested();

                    if (errorStatus == WebExceptionStatus.Success)
                    {
                        Settings.Authenticated      = true;
                        Settings.AvailableCheckTime = DateTime.MinValue;
                        Settings.WriteSyncOn(false);

                        CancelAllDownloads();

                        // Success
                        Dismiss(false);
                    }
                    else
                    {
                        Settings.Authenticated = false;

                        if (notCompatible)
                        {
                            AlertView.Show(StringRef.alert, StringRef.notCompatible, StringRef.ok);
                        }
                        else
                        {
                            WebExceptionAlertView.ShowAlert(errorStatus);
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                    KeychainAccessor.ClearCredential();
                }
            }
        }
        void HandleNotePressedEvent(String pageID, Note note)
        {
            if (String.IsNullOrEmpty(pageID))
            {
                AlertView.Show(StringRef.alert, "The book does not contain this page.", StringRef.ok);
            }
            else
            {
                Settings.OpenNotePanel = true;

                LoadPageViewController(pageID);
            }
        }
        async private void LoadPageViewController(String pageID)
        {
            try
            {
                LoadingView.Show("Loading", "Please wait while we're loading " + book.Title + "...", false);

                int           pageNumber = BooksOnDeviceAccessor.GetPage(book.ID, pageID).PageNumber;
                PSPDFDocument document   = await eBriefingService.Run(() => GenerateDocument());

                if (document == null)
                {
                    LoadingView.Hide();

                    AlertView.Show(StringRef.alert, "We're sorry, but we could not open the document.", StringRef.ok);
                }
                else
                {
                    PSPDFConfiguration configuration = PSPDFConfiguration.FromConfigurationBuilder(delegate(PSPDFConfigurationBuilder builder)
                    {
                        builder.CreateAnnotationMenuEnabled = builder.ShouldHideStatusBar = builder.ShouldCacheThumbnails = false;
                        builder.ShouldHideStatusBarWithHUD  = builder.AlwaysBouncePages = builder.SmartZoomEnabled = builder.DoublePageModeOnFirstPage
                                                                                                                         = builder.ShouldHideHUDOnPageChange = builder.ShouldHideNavigationBarWithHUD = true;
                        builder.HUDViewMode      = PSPDFHUDViewMode.Automatic;
                        builder.HUDViewAnimation = PSPDFHUDViewAnimation.Fade;
                        builder.ThumbnailBarMode = PSPDFThumbnailBarMode.None;
                        builder.RenderingMode    = PSPDFPageRenderingMode.Render;
                        builder.PageTransition   = PSPDFPageTransition.Curl;
                        builder.ShouldAskForAnnotationUsername = false;
                        builder.AllowBackgroundSaving          = false;
                        builder.OverrideClass(new Class(typeof(PSPDFHUDView)), new Class(typeof(CustomPSPDFHUDView)));
                        builder.OverrideClass(new Class(typeof(PSPDFViewControllerDelegate)), new Class(typeof(CustomPSPDFViewControllerDelegate)));
                        builder.OverrideClass(new Class(typeof(PSPDFBarButtonItem)), new Class(typeof(CustomPSPDFBarButtonItem)));
                    });

                    PageViewController pvc = new PageViewController(book, document, configuration);
                    pvc.Delegate = new CustomPSPDFViewControllerDelegate();
                    pvc.Page     = (nuint)pageNumber - 1;

                    pvc.AddAnnotations();

                    LoadingView.Hide();
                    this.NavigationController.PushViewController(pvc, true);
                }
            }
            catch (Exception ex)
            {
                LoadingView.Hide();

                Logger.WriteLineDebugging("DashboardViewController - LoadPageViewController: {0}", ex.ToString());
            }
        }