private PageChanges IncrementPageRotation(PageChanges currentRotation)
        {
            switch (currentRotation)
            {
            case PageChanges.Rotate90:
                return(PageChanges.Rotate180);

            case PageChanges.Rotate180:
                return(PageChanges.Rotate270);

            case PageChanges.Rotate270:
                return(PageChanges.None);

            case PageChanges.Remove:
                return(PageChanges.Remove);

            case PageChanges.None:
                return(PageChanges.Rotate90);

            default:
                return(currentRotation);
            }
        }
Exemple #2
0
        private void Navigate(PageChanges change)
        {
            uint totalRecords;
            uint newPageSize;

            if (PageContract == null)
            {
                return;
            }

            totalRecords = PageContract.GetTotalCount();
            newPageSize  = (uint)cmbPageSizes.SelectedItem;

            if (totalRecords == 0)
            {
                ItemsSource.Clear();
                TotalPages = 1;
                Page       = 1;
            }
            else
            {
                TotalPages = (totalRecords / newPageSize) + (uint)((totalRecords % newPageSize == 0) ? 0 : 1);
            }

            uint newPage = 1;

            switch (change)
            {
            case PageChanges.First:
                if (Page == 1)
                {
                    return;
                }
                break;

            case PageChanges.Previous:
                newPage = (Page - 1 > TotalPages) ? TotalPages : (Page - 1 < 1) ? 1 : Page - 1;
                break;

            case PageChanges.Current:
                newPage = (Page > TotalPages) ? TotalPages : (Page < 1) ? 1 : Page;
                break;

            case PageChanges.Next:
                newPage = (Page + 1 > TotalPages) ? TotalPages : Page + 1;
                //(Page + 1) < 1 ? 1 :
                break;

            case PageChanges.Last:
                if (Page == TotalPages)
                {
                    return;
                }
                newPage = TotalPages;
                break;

            default:
                break;
            }

            uint StartingIndex = (newPage - 1) * newPageSize;

            uint oldPage = Page;

            RaisePreviewPageChange(Page, newPage);

            Page = newPage;
            ItemsSource.Clear();

            ICollection <object> fetchData = PageContract.GetRecordsBy(StartingIndex, newPageSize, FilterTag);

            foreach (object row in fetchData)
            {
                ItemsSource.Add(row);
            }

            RaisePageChanged(oldPage, Page);
        }
Exemple #3
0
        public void Navigate(PageChanges change)
        {
            uint totalRecords;
            uint newPageSize;

            if (this.MyQuery == null || this.cmbPageSizes.ItemsSource == null)
            {
                return;
            }

            totalRecords = (uint)MyQuery.Count();
            newPageSize  = (uint)cmbPageSizes.SelectedItem;
            if (totalRecords == 0)
            {
                ItemsSource.Clear();
                TotalPages  = 1;
                Page        = 1;
                StartRecord = 0;
                EndRecord   = 0;
            }
            else
            {
                TotalPages = (totalRecords / newPageSize) + (uint)((totalRecords % newPageSize == 0) ? 0 : 1);
            }

            uint newPage = 1;

            switch (change)
            {
            case PageChanges.First:
                if (Page == 1)
                {
                    return;
                }
                break;

            case PageChanges.Previous:
                newPage = (Page - 1 > TotalPages) ? TotalPages : (Page - 1 < 1) ? 1 : Page - 1;
                break;

            case PageChanges.Current:
                newPage = (Page > TotalPages) ? TotalPages : (Page < 1) ? 1 : Page;
                break;

            case PageChanges.Next:
                newPage = (Page + 1 > TotalPages) ? TotalPages : Page + 1;
                //(Page + 1) < 1 ? 1 :
                break;

            case PageChanges.Last:
                if (Page == TotalPages)
                {
                    return;
                }
                newPage = TotalPages;
                break;

            default:
                break;
            }

            uint StartingIndex = (newPage - 1) * newPageSize;

            StartRecord = StartingIndex + 1;

            uint oldPage = Page;

            RaisePreviewPageChange(Page, newPage);

            Page         = newPage;
            TotalRecords = totalRecords;
            ItemsSource.Clear();

            IQueryable fetchData  = MyQuery.Skip(Convert.ToInt32(StartingIndex)).Take(Convert.ToInt32(newPageSize));
            var        enumerator = fetchData.GetEnumerator();

            while (enumerator.MoveNext())
            {
                ItemsSource.Add(enumerator.Current);
            }
            EndRecord = StartingIndex + Convert.ToUInt32(ItemsSource.Count);
            RaisePageChanged(oldPage, Page);
        }
        private void Navigate(PageChanges change)
        {
            int totalRecords;
            int newPageSize;

            if (PageContract == null)
            {
                return;
            }

            totalRecords = PageContract.GetTotalCount();
            newPageSize = (int)cmbPageSizes.SelectedItem;

            if (totalRecords == 0)
            {
                ItemsSource.Clear();
                TotalPages = 1;
                Page = 1;
            }
            else
            {
                TotalPages = (totalRecords / newPageSize) + (int)((totalRecords % newPageSize == 0) ? 0 : 1);
            }

            int newPage = 1;

            switch (change)
            {
                case PageChanges.First:
                    if (Page == 1)
                    {
                        return;
                    }
                    break;
                case PageChanges.Previous:
                    newPage = (Page - 1 > TotalPages) ? TotalPages : (Page - 1 < 1) ? 1 : Page - 1;
                    break;
                case PageChanges.Current:
                    newPage = (Page > TotalPages) ? TotalPages : (Page < 1) ? 1 : Page;
                    break;
                case PageChanges.Next:
                    newPage = (Page + 1 > TotalPages) ? TotalPages : Page + 1;
                    //(Page + 1) < 1 ? 1 :
                    break;
                case PageChanges.Last:
                    if (Page == TotalPages)
                    {
                        return;
                    }
                    newPage = TotalPages;
                    break;
                default:
                    break;
            }

            var startingIndex = (newPage - 1) * newPageSize;

            var oldPage = Page;
            RaisePreviewPageChange(Page, newPage);

            Page = newPage;
            ItemsSource.Clear();

            ICollection<object> fetchData = PageContract.GetRecordsBy(startingIndex, newPageSize, Filter);
            foreach (object row in fetchData)
            {
                ItemsSource.Add(row);
            }

            RaisePageChanged(oldPage, Page);
        }
Exemple #5
0
        private async Task NavigateAsync(PageChanges change)
        {
            if (this.PageContract == null)
            {
                return;
            }

            this.IsLoading = true;

            var totalRecords = await this.PageContract.GetTotalCountAsync(this.Filter);

            var newPageSize = (int)(this.CmbPageSizes.SelectedItem ?? 1);

            this.PageSize = newPageSize;

            if (totalRecords == 0)
            {
                this.ItemsSource.Clear();
                this.TotalPages = 1;
                this.Page       = 1;
            }
            else
            {
                this.TotalPages = (totalRecords / newPageSize) + ((totalRecords % newPageSize == 0) ? 0 : 1);
            }

            int newPage = 1;

            switch (change)
            {
            case PageChanges.First:
                if (this.Page == 1)
                {
                    this.IsLoading = false;
                    return;
                }

                break;

            case PageChanges.Previous:
                if (this.Page == 1)
                {
                    this.IsLoading = false;
                    return;
                }

                newPage = (this.Page - 1 > this.TotalPages) ? this.TotalPages : (this.Page - 1 < 1) ? 1 : this.Page - 1;
                break;

            case PageChanges.Current:
                newPage = (this.Page > this.TotalPages) ? this.TotalPages : (this.Page < 1) ? 1 : this.Page;
                break;

            case PageChanges.Next:
                if (this.Page == this.TotalPages)
                {
                    this.IsLoading = false;
                    return;
                }

                newPage = (this.Page + 1 > this.TotalPages) ? this.TotalPages : this.Page + 1;
                break;

            case PageChanges.Last:
                if (this.Page == this.TotalPages)
                {
                    this.IsLoading = false;
                    return;
                }

                newPage = this.TotalPages;
                break;
            }

            var startingIndex = (newPage - 1) * newPageSize;

            var oldPage = this.Page;

            this.RaisePreviewPageChange(this.Page, newPage);

            this.Page = newPage;

            var pageControlContract = this.PageContract;

            if (pageControlContract != null)
            {
                IEnumerable fetchData =
                    await pageControlContract.GetRecordsAsync(startingIndex, newPageSize, this.Filter);

                this.ItemsSource.Clear();

                foreach (object row in fetchData)
                {
                    this.ItemsSource.Add(row);
                }
            }

            this.RaisePageChanged(oldPage, this.Page);
            this.IsLoading = false;
        }
Exemple #6
0
        private void Navigate(PageChanges change)
        {
            if (PageContract == null)
            {
                return;
            }

            var totalRecords = PageContract.GetTotalCount();
            var newPageSize = (uint) CmbPageSizes.SelectedItem;

            if (totalRecords == 0)
            {
                ItemsSource.Clear();
                TotalPages = 1;
                Page = 1;
            }
            else
            {
                TotalPages = (totalRecords/newPageSize) + (uint) ((totalRecords%newPageSize == 0) ? 0 : 1);
            }

            uint newPage = 1;

            switch (change)
            {
                case PageChanges.First:
                    if (Page == 1)
                    {
                        return;
                    }
                    break;
                case PageChanges.Previous:
                    newPage = (Page - 1 > TotalPages) ? TotalPages : (Page - 1 < 1) ? 1 : Page - 1;
                    break;
                case PageChanges.Current:
                    newPage = (Page > TotalPages) ? TotalPages : (Page < 1) ? 1 : Page;
                    break;
                case PageChanges.Next:
                    newPage = (Page + 1 > TotalPages) ? TotalPages : Page + 1;
                    break;
                case PageChanges.Last:
                    if (Page == TotalPages)
                    {
                        return;
                    }
                    newPage = TotalPages;
                    break;
                default:
                    break;
            }

            var startingIndex = (newPage - 1)*newPageSize;

            var oldPage = Page;
            RaisePreviewPageChange(Page, newPage);

            Page = newPage;
            ItemsSource.Clear();

            var fetchData = PageContract.FetchRange(startingIndex, newPageSize, FilterTag);
            if (fetchData != null)
                foreach (var row in fetchData)
                {
                    ItemsSource.Add(row);
                }

            RaisePageChanged(oldPage, Page);
        }