Пример #1
0
 // Build a localized ApplicationBar
 private void BuildLocalizedMenu()
 {
     NavigationLinks.Add(new NavigationLink
     {
         Label = Quran.Core.Properties.Resources.search,
         Symbol = Symbol.Find,
         Action = () => { MainPivot.SelectedItem = SearchPivotItem; }
     });
     NavigationLinks.Add(new NavigationLink
     {
         Label = Quran.Core.Properties.Resources.go_to,
         Symbol = Symbol.NewWindow,
         Action = async () => 
         {
             JumpContentDialog dialog = new JumpContentDialog();
             await dialog.ShowAsync();
             if (dialog.Page != null)
             {
                 SettingsUtils.Set<int>(Constants.PREF_LAST_PAGE, dialog.Page.Value);
                 NavigationData navData = null;
                 if (dialog.Ayah != null)
                 {
                     navData = new NavigationData
                     {
                         Surah = dialog.Ayah.Surah,
                         Ayah = dialog.Ayah.Ayah
                     };
                 }
                 Frame.Navigate(typeof(DetailsView), navData);
             }
         }
     });
     NavigationLinks.Add(new NavigationLink
     {
         Label = Quran.Core.Properties.Resources.contact_us,
         Symbol = Symbol.MailForward,
         Action = () => { QuranApp.NativeProvider.LaunchWebBrowser("https://github.com/stankovski/quran-phone/issues"); }
     });
 }
Пример #2
0
        // When page is navigated to set data context to selected item in list
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            await ViewModel.Initialize();
            BuildLocalizedMenu();
            BuildContextMenu();
            UpdateAudioControls(ViewModel.AudioPlayerState);

            // Hide status bar
            if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
            {
                var statusBar = StatusBar.GetForCurrentView();
                await statusBar.HideAsync();
            }

            NavigationData parameters = e.Parameter as NavigationData;
            if (parameters == null)
            {
                parameters = new NavigationData();
            }

            ViewModel.CurrentPageNumber = SettingsUtils.Get<int>(Constants.PREF_LAST_PAGE);

            //Monitor property changes
            ViewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "CurrentPageIndex")
                {
                    if (ViewModel.CurrentPageIndex != -1)
                    {
                        radSlideView.SelectedItem = ViewModel.Pages[ViewModel.CurrentPageIndex];                        
                    }
                }
                if (args.PropertyName == "AudioPlayerState")
                {
                    UpdateAudioControls(ViewModel.AudioPlayerState);
                }
                if (args.PropertyName == "CurrentPageBookmarked")
                {
                    SetBookmarkNavigationLink();
                }
            };

            //Try extract translation from query
            var translation = SettingsUtils.Get<string>(Constants.PREF_ACTIVE_TRANSLATION);
            if (!string.IsNullOrEmpty(translation))
            {
                if (ViewModel.TranslationFile != translation.Split('|')[0] ||
                    ViewModel.ShowTranslation != SettingsUtils.Get<bool>(Constants.PREF_SHOW_TRANSLATION) ||
                    ViewModel.ShowArabicInTranslation != SettingsUtils.Get<bool>(Constants.PREF_SHOW_ARABIC_IN_TRANSLATION))
                {
                    ViewModel.Pages.Clear();
                }
                ViewModel.TranslationFile = translation.Split('|')[0];
                if (await ViewModel.HasTranslationFile())
                {
                    ViewModel.ShowTranslation = SettingsUtils.Get<bool>(Constants.PREF_SHOW_TRANSLATION);
                }
                else
                {
                    ViewModel.ShowTranslation = false;
                }
                ViewModel.ShowArabicInTranslation = SettingsUtils.Get<bool>(Constants.PREF_SHOW_ARABIC_IN_TRANSLATION);
            }
            else
            {
                ViewModel.TranslationFile = null;
                ViewModel.ShowTranslation = false;
                ViewModel.ShowArabicInTranslation = false;
            }

            // set KeepInfoOverlay according to setting
            ViewModel.KeepInfoOverlay = SettingsUtils.Get<bool>(Constants.PREF_KEEP_INFO_OVERLAY);

            //Select ayah
            if (parameters.Surah != null && parameters.Ayah != null)
            {
                ViewModel.SelectedAyah = new QuranAyah(parameters.Surah.Value, parameters.Ayah.Value);
            }
            else
            {
                ViewModel.SelectedAyah = null;
            }

            // Listen to share requests
            _dataTransferManager = DataTransferManager.GetForCurrentView();
            _dataTransferManager.DataRequested += DataShareRequested;
        }