public static async Task <QuranAyah> GetAyahFromGesture(Point p, int pageNumber, double width) { try { var position = adjustPoint(p, width); var ayahDb = await QuranApp.GetAyahInfoDatabase(); if (ayahDb != null) { return(ayahDb.GetVerseAtPoint(pageNumber, position.X, position.Y)); } } catch (Exception ex) { telemetry.TrackException(ex, new Dictionary <string, string> { { "Scenario", "OpeningAyahInfoDatabase" } }); // Ignore } return(null); }
private async Task UpdateSelectedAyah(QuranAyah ayahInfo) { if (ayahInfo == null) { canvas.Children.Clear(); } else { try { if (PageNumber != QuranUtils.GetPageFromAyah(ayahInfo)) { return; } var ayahDb = await QuranApp.GetAyahInfoDatabase(); if (ayahDb != null) { int offsetToScrollTo = 0; var bounds = ayahDb.GetVerseBoundsCombined(ayahInfo.Surah, ayahInfo.Ayah); if (bounds == null) { return; } // Wait for image to load await _imageLoaded.WaitAsync(); // Reset any overlays canvas.Children.Clear(); canvas.Opacity = 1.0; foreach (var bound in bounds) { drawAyahBound(bound); if (offsetToScrollTo == 0) { offsetToScrollTo = bound.MinY; } } var adjustedScrollPoint = adjustPointRevert(new Point(1, offsetToScrollTo), LayoutRoot.ActualWidth); LayoutRoot.ScrollToVerticalOffset(adjustedScrollPoint.Y); //Adjusting for ViewBox offset if (QuranApp.DetailsViewModel.AudioPlayerState == AudioState.Playing) { canvasStoryboard.Seek(new TimeSpan(1)); canvasStoryboard.Stop(); } else { canvasStoryboard.Begin(); } } } catch (Exception ex) { telemetry.TrackException(ex, new Dictionary <string, string> { { "Scenario", "UpdateSelectedAyahInImage" } }); } } }