示例#1
0
        /// <summary>
        /// Filter items
        /// </summary>
        private void FilterItems()
        {
            // Clear displayed items
            DisplayedItems.Clear();

            // Do we have any items to filter?
            if (Items.Count > 0)
            {
                // Iterate over all items
                foreach (MItem item in Items)
                {
                    // Do primary text contains searched word (filter) ?
                    if (item.PrimaryText.ToLower().Contains(_filter.ToLower()))
                    {
                        // Add item to displayed-items collection
                        DisplayedItems.Add(item);
                    }
                }
            }

            // Redraw control
            Invalidate(true);

            // Force update component
            Component.Outdated = true;

            // Force update scroll-bar
            Scrollbar.ForceUpdate();

            // Call resize
            OnResize(EventArgs.Empty);

            // Refresh control
            Refresh();
        }
示例#2
0
 public void UpdateDisplayedItems()
 {
     DisplayedItems.Clear();
     if (_selectedItem != null)
     {
         LoadSelectedItemToDisplayedItems();
     }
     else
     {
         LoadSelectedSupplierItemsToDisplayedItems();
     }
 }
示例#3
0
    private void ChangePage(int newPage)
    {
        if (newPage >= 1 && newPage <= PageCount)
        {
            CurrentPage = newPage;

            DisplayedItems.Clear();
            foreach (T item in _items.Take(CurrentPage * PageSize).Skip((CurrentPage - 1) * PageSize))
            {
                DisplayedItems.Add(item);
            }

            StateHasChanged();
        }
    }
示例#4
0
    private void RefreshItems()
    {
        IEnumerable <T> items = Items.ToList();

        if (SortFunction is not null && !string.IsNullOrWhiteSpace(_sortColumn))
        {
            items = SortFunction(items, _sortColumn, _sortAscending);
        }

        if (FilterFunction is not null && !string.IsNullOrWhiteSpace(_filter))
        {
            items = FilterFunction(items, _filter);
        }

        _items = items;

        if (Paginate)
        {
            PageCount = (int)Math.Ceiling(1.0 * _items.Count() / PageSize);
            if (PageCount <= 0)
            {
                DisplayedItems.Clear();
            }
            else
            {
                ChangePage(Math.Clamp(CurrentPage, 1, PageCount));
            }
        }
        else
        {
            DisplayedItems.Clear();
            foreach (T game in _items)
            {
                DisplayedItems.Add(game);
            }
        }

        StateHasChanged();
    }
示例#5
0
        /// <summary>
        /// Clears both Items and DisplayedItems collections. Resets selected item property.
        /// </summary>
        public void Clear()
        {
            // Reset selected item
            SelectedItem = null;

            // Clear items
            Items.Clear();

            // Clear displayed items
            DisplayedItems.Clear();

            // Redraw control
            Invalidate(true);

            // Force update component
            Component.Outdated = true;

            // Force update scroll-bar
            Scrollbar.ForceUpdate();

            // Refresh control
            Refresh();
        }