Example #1
0
 private void UpdatePages(ObservableCollection <LoadChunk> pages)
 {
     if (pages == null || pages.Count == 1)
     {
         this.Visibility = Visibility.Collapsed;
     }
     else
     {
         this.Visibility        = Visibility.Visible;
         VisiblePages           = new ObservableCollection <LoadChunk>(pages.Take(Math.Min(pages.Count, MaxPages)).ToList());
         CurrentPage            = VisiblePages[0];
         CurrentPage.IsSelected = true;
         RaisePropertyChanged(() => CurrentPageNo);
     }
 }
Example #2
0
        private void UpdateCurrentPage(LoadChunk currentPage)
        {
            if (Pages == null)
            {
                return;
            }
            var currentPageIndex = Pages.IndexOf(currentPage);

            if (!VisiblePages.Contains(currentPage))
            {
                var lastPageIndex = Pages.Count() - 1;
                if (Pages.Count <= MaxPages)
                {
                    VisiblePages = new ObservableCollection <LoadChunk>(Pages.ToList());
                }
                if ((lastPageIndex - currentPageIndex) < MaxPages)
                {
                    var firstindex = Pages.Count - MaxPages;
                    VisiblePages = new ObservableCollection <LoadChunk>(Pages.Skip(firstindex).Take(MaxPages).ToList());
                }
                else
                {
                    VisiblePages = new ObservableCollection <LoadChunk>(Pages.Skip(currentPageIndex).Take(MaxPages).ToList());
                }
            }

            foreach (var visiblePage in VisiblePages)
            {
                visiblePage.IsSelected = (visiblePage == currentPage);
            }

            if (currentPage != null && currentPage != CurrentPage)
            {
                CurrentPage = currentPage;
                RaisePropertyChanged(() => CurrentPageNo);
            }
            UpdateButtons();
        }