/// <summary> /// Gets the specified sorting strategy instance. /// </summary> /// <param name="sortItem">The sort item.</param> /// <returns></returns> /// <exception cref="ArgumentException"></exception> public ISortingStrategy Get(SortingItems sortItem) { switch (sortItem) { case SortingItems.Classification: return(new ClassificationSortingStrategy()); case SortingItems.Genre: return(new GenreSortingStrategy()); case SortingItems.Rating: return(new RatingSortingStrategy()); case SortingItems.ReleaseDate: return(new ReleaseDateSortingStrategy()); case SortingItems.Title: return(new TitleSortingStrategy()); case SortingItems.MovieId: return(new MovieIdSortingStrategy()); default: throw new ArgumentException($"A sorting strategy is not implemented for {sortItem.ToString()}."); } }
private void SwapCallback(int i, int j) { if (SwapTimeout <= 0) { return; } Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (SortingItems.Count > i && SortingItems.Count > j) { SortingItems.Swap(i, j); } })); System.Threading.Thread.Sleep(SwapTimeout); }
private void FilterWords() { if (selectedBook == null) { return; } WordEntries = efContext.WordEntries.Local; var we = from w in WordEntries select w; if (SelectedBook != null) { we = from w in we where w.Book_ID == SelectedBook.Book_ID select w; } if (SelectedLanguage != null) { we = from w in we where w.Word.Language_ID == SelectedLanguage.Language_ID select w; } int orderBy = SortingItems.IndexOf(SortingItems.FirstOrDefault(z => z == SelectedSortingItem)); switch (orderBy) { case 0: BookWordEntries = we.OrderBy(z => z.Page).ToList(); break; case 1: BookWordEntries = we.OrderBy(z => z.Word.Value).ToList(); break; case 2: BookWordEntries = we.OrderByDescending(z => z.Word.Value).ToList(); break; default: BookWordEntries = we.OrderBy(z => z.Word_ID).ToList(); break; } }