示例#1
0
        public async Task JumpToPage(int page)
        {
            Log.Update();
            CurrentPage = page > NumPages ? NumPages : page;

            OnPageUpdate.Invoke();
            ExecutePending();
            await SavePageNumber();
        }
示例#2
0
        public async Task LastPage()
        {
            Log.Update();
            CurrentPage = NumPages - 1;

            OnPageUpdate.Invoke();
            ExecutePending();
            await SavePageNumber();
        }
示例#3
0
        public async Task PreviousPage()
        {
            Log.Update();
            CurrentPage--;

            OnPageUpdate.Invoke();
            ExecutePending();
            await SavePageNumber();
        }
示例#4
0
        public async Task NextPage()
        {
            Log.Update();
            CurrentPage++;

            OnPageUpdate.Invoke();
            ExecutePending();
            await SavePageNumber();
        }
示例#5
0
        private async Task ResetCurrentPage()
        {
            Log.Update();
            if (PageSize == 0 || CurrentPage < NumPages || NumPages == 0)
            {
                return;
            }
            CurrentPage = NumPages - 1;

            OnPageUpdate.Invoke();
            ExecutePending();
            await SavePageNumber();
        }
示例#6
0
        public IEnumerable <T> AllRows()
        {
            bool dataChange = _matchedRowCache == null || _sortedRowCache == null;

            Log.Update("[Data] AllRows");
            // _data ??= _dataGetter.Invoke().ToList();

            lock (_dataLock)
            {
                _data ??= new LinkedList <T>(_dataGetter.Invoke());

                if (_matchedRowCache == null)
                {
                    Log.Update("[Data] Re-matching rows");
                    List <T> result         = new List <T>();
                    var      numRows        = 0;
                    var      numRowsMatched = 0;

                    foreach (T row in _data)
                    {
                        numRows++;

                        var matched = true;
                        foreach (Column?column in _columns.Values)
                        {
                            if (column?.ID == null)
                            {
                                continue;
                            }

                            if (column.Shown != true)
                            {
                                continue;
                            }
                            if (string.IsNullOrEmpty(column.FilterValue))
                            {
                                continue;
                            }

                            if (!RegexMode)
                            {
                                if (!Match(RowValue(row, column.ID), column.FilterValue))
                                {
                                    matched = false;
                                    break;
                                }
                            }
                            else
                            {
                                if (!column.CompiledFilterValue?.IsMatch(RowValue(row, column.ID) ?? "") ?? false)
                                {
                                    matched = false;
                                    break;
                                }
                            }
                        }

                        if (matched)
                        {
                            result.Add(row);
                            numRowsMatched++;
                        }
                    }

                    RowCount = numRowsMatched;
                    ResetCurrentPage();

                    _matchedRowCache = result;
                }

                if (_sortedRowCache == null)
                {
                    Log.Update("[Data] Re-sorting rows");
                    _sortedRowCache = Sort(ref _matchedRowCache);
                }

                if (dataChange)
                {
                    OnPageUpdate.Invoke();
                    ExecutePending();
                }

                return(_sortedRowCache ?? new List <T>());
            }
        }