コード例 #1
0
        /// <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");
        }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
        /// <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();
        }
コード例 #4
0
        /// <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");
        }