Beispiel #1
0
        public virtual async Task <PagedDataSet <TItem, TResult> > BuildPagedDataSource()
        {
            var pds = new PagedDataSet <TItem, TResult>();

            if (_nameSetter != null)
            {
                await pds.SetName(await _nameSetter(pds));
            }
            if (_pageSizeSetter != null)
            {
                await pds.SetPageSize(await _pageSizeSetter(pds));
            }
            if (_pageIndexSetter != null)
            {
                await pds.SetCurrentPageIndex(await _pageIndexSetter(pds));
            }
            if (_focusSetter != null)
            {
                await pds.SetFocus(await _focusSetter(pds));
            }
            if (_pageContentGenSetter != null)
            {
                pds.ContentGenerator = await _pageContentGenSetter(pds);
            }
            if (_selectorSetter != null)
            {
                await pds.SetSelector(await _selectorSetter(pds));
            }
            if (_moverSetter != null)
            {
                await pds.SetMover(await _moverSetter(pds));
            }
            if (_adderSetter != null)
            {
                await pds.SetAdder(await _adderSetter(pds));
            }
            if (_removerSetter != null)
            {
                await pds.SetRemover(await _removerSetter(pds));
            }
            if (_dataSourceSetter != null)
            {
                await pds.SetDataSource(await _dataSourceSetter(pds));
            }
            if (_itemFilterSetter != null)
            {
                pds.ItemFilter = await _itemFilterSetter(pds);
            }
            if (_filterSetter != null)
            {
                await pds.SetFilter(await _filterSetter(pds));
            }
            return(pds);
        }
        public async Task <IPageContent <string> > GeneratePageContent()
        {
            var currentPage = await PagedDataSet.GetCurrentPageIndex();

            var pageCount = await PagedDataSet.GetPageCount();

            var isFocus = await PagedDataSet.GetFocusState();

            var name = await PagedDataSet.GetName();

            var left  = currentPage > 0 ? EmojiPrevPage : string.Empty;
            var right = currentPage < pageCount ? EmojiNextPage : string.Empty;

            var header = $"{left}{name} (Page {currentPage + DisplayPageOffset}/{pageCount}){right}";

            if (isFocus)
            {
                header = await FocusDecorator(this, header);
            }

            var pageItems = await PagedDataSet.GetPageItems();

            header = await OnHeaderGenerated(header, pageItems);

            StringBuilder sb  = new StringBuilder();
            int           i   = 0;
            var           sel = await PagedDataSet.GetSelector();

            foreach (var item in pageItems)
            {
                var isSel = sel != null && await sel.GetCaretPosition() == i;

                var content = await ItemProvider.GetItemString(item);

                if (isSel && (isFocus || UnfocusHighlight))
                {
                    content = await HighlighDecorator(this, item, content);
                }
                if (i > 0)
                {
                    sb.Append(ItemSeperator);
                }
                sb.Append(await OnItemContentGenerated(content, item, isSel, pageItems));
                i++;
            }

            return(new StringPageContent(header, await OnContentGenerated(sb.ToString(), pageItems)));
        }
 public Addable(PagedDataSet <TItem, TResult> pagedDataSet)
 {
     PagedDataSet = pagedDataSet;
 }