Exemplo n.º 1
0
        /*
         *  <ComboBoxItem Content="登録が新しい順" />
         *  <ComboBoxItem Content="登録が古い順" />
         *  <ComboBoxItem Content="タイトル昇順" />
         *  <ComboBoxItem Content="タイトル降順" />
         *  <ComboBoxItem Content="マイリストコメント昇順" />
         *  <ComboBoxItem Content="マイリストコメント降順" />
         *  <ComboBoxItem Content="投稿が新しい順" />
         *  <ComboBoxItem Content="投稿が古い順" />
         *  <ComboBoxItem Content="再生数が多い順" />
         *  <ComboBoxItem Content="再生数が少ない順" />
         *  <ComboBoxItem Content="コメントが新しい順" />
         *  <ComboBoxItem Content="コメントが古い順" />
         *  <ComboBoxItem Content="コメントが多い順" />
         *  <ComboBoxItem Content="コメントが少ない順" />
         *  <ComboBoxItem Content="マイリスト登録が多い順" />
         *  <ComboBoxItem Content="マイリスト登録が少ない順" />
         */
        //ソート
        public void Sort(int index)
        {
            IOrderedEnumerable <MylistListEntryViewModel> sorted = null;

            if (Mylist == null)
            {
                return;
            }

            var tmp = Mylist.ToArray();

            //並び替え
            switch (index)
            {
            case 0:
                sorted = tmp.OrderByDescending(r => r.Entry.CreateTime);
                break;

            case 1:
                sorted = tmp.OrderBy(r => r.Entry.CreateTime);
                break;

            case 2:
                sorted = tmp.OrderBy(r => r.Entry.Title);
                break;

            case 3:
                sorted = tmp.OrderByDescending(r => r.Entry.Title);
                break;

            case 4:
                sorted = tmp.OrderBy(r => r.Entry.Description);
                break;

            case 5:
                sorted = tmp.OrderByDescending(r => r.Entry.Description);
                break;

            case 6:
                sorted = tmp.OrderByDescending(r => r.Entry.FirstRetrieve);
                break;

            case 7:
                sorted = tmp.OrderBy(r => r.Entry.FirstRetrieve);
                break;

            case 8:
                sorted = tmp.OrderByDescending(r => r.Entry.ViewCounter);
                break;

            case 9:
                sorted = tmp.OrderBy(r => r.Entry.ViewCounter);
                break;

            case 10:
                sorted = tmp.OrderByDescending(r => r.Entry.UpdateTime);
                break;

            case 11:
                sorted = tmp.OrderBy(r => r.Entry.UpdateTime);
                break;

            case 12:
                sorted = tmp.OrderByDescending(r => r.Entry.CommentCounter);
                break;

            case 13:
                sorted = tmp.OrderBy(r => r.Entry.CommentCounter);
                break;

            case 14:
                sorted = tmp.OrderByDescending(r => r.Entry.MylistCounter);
                break;

            case 15:
                sorted = tmp.OrderBy(r => r.Entry.MylistCounter);
                break;
            }

            //一度空にする
            Mylist.Clear();

            //ソートしたマイリストを再度追加
            foreach (var entry in sorted)
            {
                Mylist.Add(entry);
            }
        }