/// <summary> /// Sorts the dependencies list. /// </summary> /// <param name="order">Order to sort the dependencies list by.</param> /// <param name="bAscending">Ascending or descending order.</param> public void Sort(SearchResultSortOrder order, bool bAscending) { IOrderedEnumerable <SearchResultItemViewModel> items = null; switch (order) { case SearchResultSortOrder.Name: if (bAscending) { items = this.SearchResults.OrderBy <SearchResultItemViewModel, string>((x) => (x.DomainElementFullName)); } else { items = this.SearchResults.OrderByDescending <SearchResultItemViewModel, string>((x) => (x.DomainElementFullName)); } break; case SearchResultSortOrder.Reason: if (bAscending) { items = this.SearchResults.OrderBy <SearchResultItemViewModel, string>((x) => (x.Reason)); } else { items = this.SearchResults.OrderByDescending <SearchResultItemViewModel, string>((x) => (x.Reason)); } break; case SearchResultSortOrder.Path: if (bAscending) { items = this.SearchResults.OrderBy <SearchResultItemViewModel, string>((x) => (x.DomainElementParentFullPath)); } else { items = this.SearchResults.OrderByDescending <SearchResultItemViewModel, string>((x) => (x.DomainElementParentFullPath)); } break; default: throw new NotSupportedException(); } ObservableCollection <SearchResultItemViewModel> temp = new ObservableCollection <SearchResultItemViewModel>(); foreach (SearchResultItemViewModel item in items) { temp.Add(item); } this.searchResultViewModels = temp; OnPropertyChanged("SearchResults"); }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> public SearchResultViewModel(ViewModelStore viewModelStore) : base(viewModelStore, false) { searchResultViewModels = new ObservableCollection<SearchResultItemViewModel>(); this.sortOrder = Search.SearchResultSortOrder.Name; this.isAscending = true; navigateCommand = new DelegateCommand(NavigateCommand_Executed); sortByNameCommand = new DelegateCommand(SortByNameCommand_Executed); sortByReasonCommand = new DelegateCommand(SortByReasonCommand_Executed); sortByPathCommand = new DelegateCommand(SortByPathCommand_Executed); this.PreInitialize(); }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> public SearchResultViewModel(ViewModelStore viewModelStore) : base(viewModelStore, false) { searchResultViewModels = new ObservableCollection <SearchResultItemViewModel>(); this.sortOrder = Search.SearchResultSortOrder.Name; this.isAscending = true; navigateCommand = new DelegateCommand(NavigateCommand_Executed); sortByNameCommand = new DelegateCommand(SortByNameCommand_Executed); sortByReasonCommand = new DelegateCommand(SortByReasonCommand_Executed); sortByPathCommand = new DelegateCommand(SortByPathCommand_Executed); this.PreInitialize(); }
/// <summary> /// Sorts the dependencies list. /// </summary> /// <param name="order">Order to sort the dependencies list by.</param> /// <param name="bAscending">Ascending or descending order.</param> public void Sort(SearchResultSortOrder order, bool bAscending) { IOrderedEnumerable<SearchResultItemViewModel> items = null; switch (order) { case SearchResultSortOrder.Name: if (bAscending) items = this.SearchResults.OrderBy<SearchResultItemViewModel, string>((x) => (x.DomainElementFullName)); else items = this.SearchResults.OrderByDescending<SearchResultItemViewModel, string>((x) => (x.DomainElementFullName)); break; case SearchResultSortOrder.Reason: if (bAscending) items = this.SearchResults.OrderBy<SearchResultItemViewModel, string>((x) => (x.Reason)); else items = this.SearchResults.OrderByDescending<SearchResultItemViewModel, string>((x) => (x.Reason)); break; case SearchResultSortOrder.Path: if (bAscending) items = this.SearchResults.OrderBy<SearchResultItemViewModel, string>((x) => (x.DomainElementParentFullPath)); else items = this.SearchResults.OrderByDescending<SearchResultItemViewModel, string>((x) => (x.DomainElementParentFullPath)); break; default: throw new NotSupportedException(); } ObservableCollection<SearchResultItemViewModel> temp = new ObservableCollection<SearchResultItemViewModel>(); foreach (SearchResultItemViewModel item in items) temp.Add(item); this.searchResultViewModels = temp; OnPropertyChanged("SearchResults"); }