public static void Show(UIView view, CloudSync.SyncType syncType) { if (Reachability.IsDefaultNetworkAvailable()) { LoadingView.CancelEvent += HandleCancelEvent; LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes..."); // Pull sync if (syncType == CloudSync.SyncType.PULL) { CloudSync.ReceiveDoneEvent += HandleReceiveDoneEvent; CloudSync.Pull(); } // Push and Pull sync else if (syncType == CloudSync.SyncType.PUSH_AND_PULL) { PushNPullInProgress = true; CloudSync.SyncDoneEvent += HandleSyncDoneEvent; CloudSync.PushAndPull(); } } else { StartTimer(); } }
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(); } } }
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()); } }
async private void LoadData() { if (isFirst) { LoadingView.Show("Loading", "Please wait while we're loading the book information...", false); await eBriefingService.Run(() => RetrieveData()); } else { LoadingView.Show("Loading", "Please wait while we're updating the book information...", false); await eBriefingService.Run(() => RetrieveData()); } LoadingView.Hide(); // Update number of bookmarks int count = 0; if (bookmarkList != null && bookmarkList.Count > 0) { count = bookmarkList.Count; } segmentedControl.SetTitle("Bookmarks (" + count.ToString() + ")", 1); // Update number of notes count = 0; if (noteList != null && noteList.Count > 0) { count = noteList.Count; } segmentedControl.SetTitle("Notes (" + count.ToString() + ")", 2); // Update number of annotations count = 0; if (annList != null && annList.Count > 0) { count = annList.Count; } segmentedControl.SetTitle("Annotations (" + count.ToString() + ")", 3); // Load collectionView LoadCollectionView(); // Update overview pane info if (dashboardView != null) { dashboardView.UpdateBookInfo(); } }
async private Task OpenSyncView() { LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false); // Start Push and Pull if (!CloudSync.SyncingInProgress) { CloudSync.SyncingInProgress = true; await eBriefingService.Run(() => CloudSync.PushAndPull()); CloudSync.SyncingInProgress = false; } LoadingView.Hide(); // Once syncing is finished, check books to download BookUpdater.CheckBooks2Download(); }
async public void LoadBooks() { TimeSpan diff = DateTime.UtcNow.Subtract(Settings.AvailableCheckTime); if (TimeSettings.LibraryRefreshRequired(diff)) { if (Reachability.IsDefaultNetworkAvailable()) { LoadingView.Show("Loading", "Please wait while we're checking Available Books...", false); List <Book> bookList = await eBriefingService.Run(() => eBriefingService.StartDownloadBooks()); if (bookList != null) { Settings.AvailableCheckTime = DateTime.UtcNow; // Save in the cache BooksOnServerAccessor.SaveBooks(bookList); // Load books RetrieveBooks(); // Update available badge UpdateAvailableBadge(); } else { LoadingView.Hide(); } } else { UpdateStatusLabel(StringRef.connectionRequired); } } else { RetrieveBooks(); } }
async private Task OpenSyncView(bool bfromSyncButton = false) { LoadingView.Show("Syncing", "Please wait while" + '\n' + "eBriefing is syncing." + '\n' + "This may take a few minutes...", false); // Start Push and Pull if (!CloudSync.SyncingInProgress) { CloudSync.SyncingInProgress = true; await eBriefingService.Run(() => CloudSync.PushAndPull()); CloudSync.SyncingInProgress = false; } LoadingView.Hide(); // Once syncing is finished, check books to download BookUpdater.CheckBooks2Download(); // Refresh HandleRefreshEvent1(this, EventArgs.Empty); if (tabBarController.SelectedIndex == 1) { HandleRefreshEvent2(this, EventArgs.Empty); } else if (tabBarController.SelectedIndex == 2) { HandleRefreshEvent3(this, EventArgs.Empty); } else if (tabBarController.SelectedIndex == 3) { vc4.LoadBooks(); } if (!bfromSyncButton) { // Start the PUSH timer in the background SyncPushTimer.Start(); } }
async private void PrintSetup(bool bGeneratePdfFile) { List <Page> pageList = new List <Page>(); if (Range == PrintHelper.RANGE.ALL) { pageList = BooksOnDeviceAccessor.GetPages(bookID); } else if (Range == PrintHelper.RANGE.CURRENT) { pageList.Add(BooksOnDeviceAccessor.GetPage(bookID, pageID)); } else { if (StartPage == 0 && EndPage == 0) { new UIAlertView(StringRef.alert, "Please enter Start page number & End page number.", null, StringRef.ok, null).Show(); return; } else if (StartPage > EndPage) { new UIAlertView(StringRef.alert, "Start page number must be less than the End page number.", null, StringRef.ok, null).Show(); return; } else { for (int i = (int)StartPage; i <= (int)EndPage; i++) { Page page = BooksOnDeviceAccessor.GetPage(bookID, i); if (page == null) { new UIAlertView(StringRef.alert, "Page number " + i.ToString() + " is not available. Please check page range. Print operation aborted.", null, StringRef.ok, null).Show(); return; } else { pageList.Add(BooksOnDeviceAccessor.GetPage(bookID, i)); } } } } printHelper = new PrintHelper(bookID, pageList); printHelper.Orientation = Orientation; printHelper.Range = Range; printHelper.Annotation = Annotation; printHelper.Note = Note; LoadingView.Show("Loading", "Getting ready to print...", false); string data = null; // Generate pdf images var isSuccessful = await eBriefingService.Run(() => printHelper.Generate()); if (isSuccessful) { this.InvokeOnMainThread(delegate { data = printHelper.GeneratePageRender(bGeneratePdfFile); if (data != null) { if (EmailEvent != null) { EmailEvent(data); } } }); LoadingView.Hide(); // Close panel ClosePanel(); if (data == null) { printHelper.Print(barButton); } } else { LoadingView.Hide(); MessageBox alert = new MessageBox(); if (printHelper.PagesNum != null && printHelper.PagesNum > 0) { alert.ShowAlert("Error", string.Format("eBriefing is reaching its memory limit. At this level, you can print {0} number of pages. Please reduce your print range.", printHelper.PagesNum), "Ok"); } else { alert.ShowAlert("Error", "Please try again", "Ok"); // Close panel ClosePanel(); } } }