Exemple #1
0
        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);
        }
Exemple #2
0
        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" }
                    });
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected async override void OnLaunched(LaunchActivatedEventArgs e)
        {
//#if DEBUG
//            if (System.Diagnostics.Debugger.IsAttached)
//            {
//                this.DebugSettings.EnableFrameRateCounter = true;
//            }
//#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Create NativeProvider
            if (QuranApp.NativeProvider == null)
            {
                QuranApp.NativeProvider = new UniversalNativeProvider();
            }
            await QuranApp.Initialize();

            // Restore settings
            RestoreSettings();

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;
                rootFrame.Navigated        += OnNavigated;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;

                // Register a handler for BackRequested events and set the
                // visibility of the Back button
                SystemNavigationManager.GetForCurrentView().BackRequested += OnBackRequested;

                SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility =
                    rootFrame.CanGoBack ?
                    AppViewBackButtonVisibility.Visible :
                    AppViewBackButtonVisibility.Collapsed;
            }

            if (!e.PrelaunchActivated)
            {
                if (rootFrame.Content == null)
                {
                    // When the navigation stack isn't restored navigate to the first page,
                    // configuring the new page by passing required information as a navigation
                    // parameter
                    rootFrame.Navigate(typeof(MainView), e.Arguments);
                }
                // Ensure the current window is active
                Window.Current.Activate();
            }
        }
Exemple #4
0
 protected BaseTest()
 {
     QuranApp.NativeProvider = new TestNativeProvider();
     QuranApp.Initialize();
 }