예제 #1
0
        /// <summary>
        /// Asyncs the search.
        /// </summary>
        public async void AsyncSearch()
        {
            List<Issue> issues =
                await Task<List<Issue>>.Factory.StartNew(() => _board.GetIssues(Filter.ToModel()).ToList());

            List<IssueViewModel> removeAllList = AllIssues.Where(i => !issues.Contains(i.Model)).ToList();

            bool hasChanged = false;

            foreach (IssueViewModel issueViewModel in removeAllList)
            {
                AllIssues.Remove(issueViewModel);
                hasChanged = true;
            }

            foreach (Issue issue in issues)
            {
                var model = new IssueViewModel(this, issue);
                if (!AllIssues.Contains(model))
                {
                    AllIssues.Add(model);
                    hasChanged = true;
                }
            }

            SortIssues(AllIssues);

            int skip = PageNumberCorrent != null ? (PageNumberCorrent.Number - 1)*PageCount : 0;

            List<IssueViewModel> pageIssues = AllIssues.Skip(skip).Take(PageCount).ToList();

            List<IssueViewModel> removeList = Issues.Where(i => !pageIssues.Contains(i)).ToList();

            foreach (IssueViewModel issueViewModel in removeList)
            {
                Issues.Remove(issueViewModel);
            }

            foreach (IssueViewModel issue in pageIssues)
            {
                if (!Issues.Contains(issue))
                {
                    Issues.Add(issue);
                }
            }

            if (hasChanged)
            {
                SortIssues(Issues);
                PageNumbers.Clear();
                if (AllIssues.Count > PageCount)
                {
                    for (int i = 0; i <= (AllIssues.Count - 1)/PageCount; i++)
                    {
                        PageNumbers.Add(new PageNumberViewModel(this, i + 1));
                    }
                    PageNumberCorrent = new PageNumberViewModel(this, 1);
                }
                OnPropertyChanged("PagenatorVisibility");
            }
            else
            {
                foreach (IssueViewModel issueViewModel in Issues)
                {
                    issueViewModel.UpdateSource();
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns>
 protected bool Equals(PageNumberViewModel other)
 {
     return Equals(Number, other.Number);
 }
예제 #3
0
 /// <summary>
 /// Goes the page.
 /// </summary>
 /// <param name="numberModel">The number model.</param>
 public void GoPage(PageNumberViewModel numberModel)
 {
     Issues.Clear();
     int start = PageCount*(numberModel.Number - 1);
     int count = PageCount*numberModel.Number;
     for (int i = start; i < count && i < AllIssues.Count; i++)
     {
         Issues.Add(AllIssues[i]);
     }
 }