Beispiel #1
0
        public static async void AddToFavorite(double rate, FavoriteKeyModel favorite)
        {
            List <FavoriteKeyModel> favorites = new List <FavoriteKeyModel>();

            if (File.Exists(Constants.FavoritePath))
            {
                var json = await File.ReadAllTextAsync(Constants.FavoritePath);

                favorites = JsonConvert.DeserializeObject <List <FavoriteKeyModel> >(json);
            }

            var currentItem = favorites.Where(item => item.Key.Equals(favorite.Key));

            if (rate == 1)
            {
                if (!currentItem.Any())
                {
                    favorites.Add(favorite);
                }
            }
            else
            {
                if (currentItem.Any())
                {
                    favorites.Remove(currentItem.SingleOrDefault());
                }
            }

            string serialize = JsonConvert.SerializeObject(favorites, Formatting.Indented);
            await File.WriteAllTextAsync(Constants.FavoritePath, serialize);
        }
Beispiel #2
0
        public void GoToDownloadPage(FavoriteKeyModel favoriteKey = null)
        {
            FavoriteKeyModel item;

            if (favoriteKey != null)
            {
                item = favoriteKey;
            }
            else
            {
                item = SubListView.SelectedItem as FavoriteKeyModel;
            }

            Type   _page = null;
            string _link = string.Empty;

            if (item != null)
            {
                _link = item.Value;
                switch (item.Server)
                {
                case Server.ESubtitle:
                    _page = typeof(ESubtitleDownloadPage);
                    break;

                case Server.ISubtitle:
                    _page = typeof(ISubtitleDownloadPage);
                    break;

                case Server.WorldSubtitle:
                    _page = typeof(WorldSubtitleDownloadPage);
                    break;

                case Server.Subscene:
                    _page = typeof(SubsceneDownloadPage);
                    _link = Helper.Settings.SubsceneServer.Url + item.Value;
                    break;
                }
                Frame.Navigate(_page, new NavigationParamModel {
                    Key = (int)item.Server + item.Title, Title = item.Title, Link = _link
                }, new DrillInNavigationTransitionInfo());
            }
        }