Ejemplo n.º 1
0
 public static void Generate()
 {
     using (var adapter = new BookmarksDatabaseHandler())
     {
         var tagId = adapter.AddTag(Resources.dua);
         foreach (int[] dua in quran_dua)
         {
             var p = QuranUtils.GetPageFromAyah(dua[0], dua[1]);
             var id = adapter.AddBookmarkIfNotExists(dua[0], dua[1], p);
             if (!adapter.IsTagged(id))
                 adapter.TagBookmark(id, tagId);
         }
     }
 }
Ejemplo n.º 2
0
 public static void Generate()
 {
     using (var adapter = new BookmarksDatabaseHandler())
     {
         var tagId = adapter.AddTag(Resources.dua);
         foreach (int[] dua in quran_dua)
         {
             var p  = QuranUtils.GetPageFromAyah(dua[0], dua[1]);
             var id = adapter.AddBookmarkIfNotExists(dua[0], dua[1], p);
             if (!adapter.IsTagged(id))
             {
                 adapter.TagBookmark(id, tagId);
             }
         }
     }
 }
Ejemplo n.º 3
0
 private bool AddBookmark(QuranAyah ayah)
 {
     try
     {
         using (var adapter = new BookmarksDatabaseHandler())
         {
             if (ayah == null)
                 adapter.AddBookmarkIfNotExists(null, null, CurrentPageNumber);
             else
                 adapter.AddBookmarkIfNotExists(ayah.Surah, ayah.Ayah, CurrentPageNumber);
         }
         return true;
     }
     catch (Exception)
     {
         QuranApp.NativeProvider.Log("error creating bookmark");
         return false;
     }
 }
Ejemplo n.º 4
0
        private async Task LoadBookmarkList()
        {
            Bookmarks.Clear();
            var lastPage = SettingsUtils.Get<int>(Constants.PREF_LAST_PAGE);
            if (lastPage > 0)
            {
                var lastPageItem = new ItemViewModel();
                lastPageItem.Title = QuranUtils.GetSurahNameFromPage(lastPage, true);
                lastPageItem.Details = string.Format("{0} {1}, {2} {3}", Resources.quran_page, lastPage,
                                                 QuranUtils.GetJuzTitle(),
                                                 QuranUtils.GetJuzFromPage(lastPage));
                lastPageItem.PageNumber = lastPage;
                lastPageItem.Image = new BitmapImage(new Uri("ms-appx:///Assets/Images/favorite.png"));
                lastPageItem.ItemType = ItemViewModelType.Bookmark;
                lastPageItem.Group = Resources.bookmarks_current_page;
                lastPageItem.Id = lastPageItem.Group;
                Bookmarks.Add(lastPageItem);
            }

            using (var bookmarksAdapter = new BookmarksDatabaseHandler())
            {
                try
                {
                    var bookmarks = bookmarksAdapter.GetBookmarks(true, BoomarkSortOrder.Location);
                    if (bookmarks.Count > 0)
                    {
                        //Load untagged first
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags == null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }

                        //Load tagged
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags != null)
                            {
                                Bookmarks.Add(await CreateBookmarkModel(bookmark));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    telemetry.TrackException(ex, new Dictionary<string, string> { { "Scenario", "LoadingBookmarks" } });
                    QuranApp.NativeProvider.Log("failed to load bookmarks: " + ex.Message);
                }
            }
        }
Ejemplo n.º 5
0
 public void DeleteBookmark(ItemViewModel item)
 {
     int id = 0;
     if (item != null && item.Id != null && int.TryParse(item.Id, NumberStyles.None, CultureInfo.InvariantCulture, out id))
     {
         Bookmarks.Remove(item);
         using (var bookmarksAdapter = new BookmarksDatabaseHandler())
         {
             bookmarksAdapter.RemoveBookmark(id);
         }
     }
 }
Ejemplo n.º 6
0
 public bool AddAyahBookmark(QuranAyah ayah)
 {
     try
     {
         using (var adapter = new BookmarksDatabaseHandler())
         {
             if (ayah == null)
                 adapter.AddBookmarkIfNotExists(null, null, CurrentPageNumber);
             else
                 adapter.AddBookmarkIfNotExists(ayah.Surah, ayah.Ayah, CurrentPageNumber);
         }
         CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);
         return true;
     }
     catch (Exception e)
     {
         QuranApp.NativeProvider.Log("error creating bookmark");
         telemetry.TrackException(e, new Dictionary<string, string> { { "Scenario", "AddBookmark" } });
         return false;
     }
 }
Ejemplo n.º 7
0
 public bool TogglePageBookmark()
 {
     try
     {
         using (var adapter = new BookmarksDatabaseHandler())
         {
             adapter.TogglePageBookmark(CurrentPageNumber);
         }
         CurrentPageBookmarked = BookmarksDatabaseHandler.IsPageBookmarked(CurrentPageNumber);
         return true;
     }
     catch (Exception e)
     {
         QuranApp.NativeProvider.Log("error creating bookmark");
         telemetry.TrackException(e, new Dictionary<string, string> { { "Scenario", "TogglePageBookmark" } });
         return false;
     }
 }
Ejemplo n.º 8
0
        private async void loadBookmarkList()
        {
            var lastPage = SettingsUtils.Get<int>(Constants.PREF_LAST_PAGE);
            if (lastPage > 0)
            {
                var lastPageItem = new ItemViewModel();
                lastPageItem.Title = QuranUtils.GetSurahNameFromPage(lastPage, true);
                lastPageItem.Details = string.Format("{0} {1}, {2} {3}", AppResources.quran_page, lastPage,
                                                 QuranUtils.GetJuzTitle(),
                                                 QuranUtils.GetJuzFromPage(lastPage));
                lastPageItem.PageNumber = lastPage;
                lastPageItem.Image = new Uri("/Assets/Images/favorite.png", UriKind.Relative);
                lastPageItem.ItemType = ItemViewModelType.Bookmark;
                lastPageItem.Group = AppResources.bookmarks_current_page;
                Bookmarks.Add(lastPageItem);
            }

            using (var bookmarksAdapter = new BookmarksDatabaseHandler())
            {
                try
                {
                    var bookmarks = bookmarksAdapter.GetBookmarks(true, BoomarkSortOrder.Location);
                    if (bookmarks.Count > 0)
                    {
                        //Load untagged first
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags == null)
                            {
                                Bookmarks.Add(await createBookmarkModel(bookmark));
                            }
                        }

                        //Load tagged
                        foreach (var bookmark in bookmarks)
                        {
                            if (bookmark.Tags != null)
                            {
                                Bookmarks.Add(await createBookmarkModel(bookmark));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    QuranApp.NativeProvider.Log("failed to load bookmarks: " + ex.Message);
                }
            }
        }