Exemplo n.º 1
0
        private void UpdateGenreOrderText(GenreOrder genreOrder)
        {
            switch (genreOrder)
            {
            case GenreOrder.Alphabetical:
                this.genreOrderText = ResourceUtils.GetString("Language_A_Z");
                break;

            case GenreOrder.ReverseAlphabetical:
                this.genreOrderText = ResourceUtils.GetString("Language_Z_A");
                break;

            default:
                // Cannot happen, but just in case.
                this.genreOrderText = ResourceUtils.GetString("Language_A_Z");
                break;
            }

            RaisePropertyChanged(nameof(this.GenreOrderText));
        }
Exemplo n.º 2
0
        protected void UpdateGenreOrderText(GenreOrder genreOrder)
        {
            switch (genreOrder)
            {
            case GenreOrder.Alphabetical:
                this.genreOrderText = ResourceUtils.GetStringResource("Language_A_Z");
                break;

            case GenreOrder.ReverseAlphabetical:
                this.genreOrderText = ResourceUtils.GetStringResource("Language_Z_A");
                break;

            default:
                // Cannot happen, but just in case.
                this.genreOrderText = ResourceUtils.GetStringResource("Language_A_Z");
                break;
            }

            OnPropertyChanged(() => this.GenreOrderText);
        }
Exemplo n.º 3
0
        private async Task GetGenresCommonAsync(IList <Genre> genres, GenreOrder genreOrder)
        {
            try
            {
                // Order the incoming Genres
                List <Genre> orderedGenres = await Common.Database.Utils.OrderGenresAsync(genres, genreOrder);

                // Create new ObservableCollection
                ObservableCollection <GenreViewModel> genreViewModels = new ObservableCollection <GenreViewModel>();

                await Task.Run(() =>
                {
                    var tempGenreViewModels = new List <GenreViewModel>();

                    // Workaround to make sure the "#" GroupHeader is shown at the top of the list
                    if (genreOrder == GenreOrder.Alphabetical)
                    {
                        tempGenreViewModels.AddRange(orderedGenres.Select((gen) => new GenreViewModel {
                            Genre = gen, IsHeader = false
                        }).Where((gvm) => gvm.Header.Equals("#")));
                    }
                    tempGenreViewModels.AddRange(orderedGenres.Select((gen) => new GenreViewModel {
                        Genre = gen, IsHeader = false
                    }).Where((gvm) => !gvm.Header.Equals("#")));
                    if (genreOrder == GenreOrder.ReverseAlphabetical)
                    {
                        tempGenreViewModels.AddRange(orderedGenres.Select((gen) => new GenreViewModel {
                            Genre = gen, IsHeader = false
                        }).Where((gvm) => gvm.Header.Equals("#")));
                    }

                    foreach (GenreViewModel gvm in tempGenreViewModels)
                    {
                        genreViewModels.Add(gvm);
                    }
                });

                // Unbind to improve UI performance
                if (this.GenresCvs != null)
                {
                    this.GenresCvs.Filter -= new FilterEventHandler(GenresCvs_Filter);
                }
                this.Genres    = null;
                this.GenresCvs = null;

                // Populate ObservableCollection
                this.Genres = new ObservableCollection <ISemanticZoomable>(genreViewModels);
            }
            catch (Exception ex)
            {
                LogClient.Error("An error occurred while getting Genres. Exception: {0}", ex.Message);

                // Failed getting Genres. Create empty ObservableCollection.
                this.Genres = new ObservableCollection <ISemanticZoomable>();
            }

            // Populate CollectionViewSource
            this.GenresCvs = new CollectionViewSource {
                Source = this.Genres
            };
            this.GenresCvs.Filter += new FilterEventHandler(GenresCvs_Filter);

            // Update count
            this.GenresCount = this.GenresCvs.View.Cast <ISemanticZoomable>().Count();

            // Update Semantic Zoom Headers
            this.UpdateSemanticZoomHeaders();
        }
Exemplo n.º 4
0
 private async Task GetGenresAsync(GenreOrder genreOrder)
 {
     await this.GetGenresCommonAsync(await this.genreRepository.GetGenresAsync(), genreOrder);
 }
Exemplo n.º 5
0
        public static async Task <List <Genre> > OrderGenresAsync(IList <Genre> genres, GenreOrder genreOrder)
        {
            var orderedGenres = new List <Genre>();

            await Task.Run(() =>
            {
                switch (genreOrder)
                {
                case GenreOrder.Alphabetical:
                    orderedGenres = genres.OrderBy((g) => GetSortableString(g.GenreName, true)).ToList();
                    break;

                case GenreOrder.ReverseAlphabetical:
                    orderedGenres = genres.OrderByDescending((g) => GetSortableString(g.GenreName, true)).ToList();
                    break;

                default:
                    // Alphabetical
                    orderedGenres = genres.OrderBy((g) => GetSortableString(g.GenreName, true)).ToList();
                    break;
                }
            });

            return(orderedGenres);
        }