コード例 #1
0
ファイル: SongsBindingModel.cs プロジェクト: anatolse/gMusicW
        public void SetCollection(IEnumerable <Song> collection)
        {
            if (collection == null)
            {
                this.Songs = null;
            }
            else
            {
                this.Songs = new ObservableCollection <SongBindingModel>(collection.Select(s => new SongBindingModel(s)));
            }

            this.CurrentSorting = SongsSorting.Unknown;
            this.ClearSelectedItems();
            this.UpdateSongStates(this.playQueueService.GetCurrentSong(), this.playQueueService.State);
        }
コード例 #2
0
ファイル: SongsBindingModel.cs プロジェクト: anatolse/gMusicW
        private void SortSongs(object obj)
        {
            if (obj != null && this.Songs != null)
            {
                IEnumerable <SongBindingModel> enumerable;

                SongsSorting songsSorting = (SongsSorting)Enum.ToObject(typeof(SongsSorting), obj);
                switch (songsSorting)
                {
                case SongsSorting.Unknown:
                    enumerable = this.Songs;
                    break;

                case SongsSorting.Track:
                    enumerable = this.Songs.OrderBy(s => s.Track);
                    break;

                case SongsSorting.TrackDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Track);
                    break;

                case SongsSorting.Title:
                    enumerable = this.Songs.OrderBy(s => s.Title, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.TitleDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Title, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.Artist:
                    enumerable = this.Songs.OrderBy(s => s.Artist, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.ArtistDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Artist, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.Album:
                    enumerable = this.Songs.OrderBy(s => s.Album, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.AlbumDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Album, StringComparer.CurrentCultureIgnoreCase);
                    break;

                case SongsSorting.Duration:
                    enumerable = this.Songs.OrderBy(s => s.Duration);
                    break;

                case SongsSorting.DurationDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Duration);
                    break;

                case SongsSorting.Rating:
                    enumerable = this.Songs.OrderBy(s => s.Rating);
                    break;

                case SongsSorting.RatingDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.Rating);
                    break;

                case SongsSorting.PlaysCount:
                    enumerable = this.Songs.OrderBy(s => s.PlayCount);
                    break;

                case SongsSorting.PlaysCountDescending:
                    enumerable = this.Songs.OrderByDescending(s => s.PlayCount);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                this.ClearSelectedItems();
                this.Songs          = new ObservableCollection <SongBindingModel>(enumerable);
                this.CurrentSorting = songsSorting;
            }
        }