Ejemplo n.º 1
0
        /// <summary>
        /// Gets the source list, accounting for sort-order, filter, etc.
        /// </summary>
        private EListInvalids Rebuild__GetFilteredList(EListInvalids checks)
        {
            this._filteredList = this.GetSourceContent().Cast <object>().ToList();

            if (!_showHidden && _source != null && typeof(Visualisable).IsAssignableFrom(_source.DataType))
            {
                int remCount = this._filteredList.RemoveAll(z => ((Visualisable)z).Hidden);
                this._lblHidden.Text    = remCount + " hidden";
                this._lblHidden.Visible = remCount != 0;
            }

            if (this._emptyList && this._filteredList.Count != 0)
            {
                // List was empty, now is not - make sure to rebuild columns since we might have new ones
                checks |= EListInvalids._ColumnsChanged | EListInvalids._ColumnVisibilitiesChanged;
            }

            this._emptyList = this._filteredList.Count == 0;

            if (this._filter != null)
            {
                int remCount = this._filteredList.RemoveAll(this._filter.FilterRemove);
                this._lblFilter.Text = remCount + " filtered";
            }

            if (this._sortOrder != null)
            {
                this._filteredList.Sort(this._sortOrder);
            }

            this._listView.VirtualListSize = this._filteredList.Count;
            return(checks);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reinitialises the list.
        /// </summary>
        /// <param name="checks">What to reinitialise</param>
        public void Rebuild(EListInvalids checks)
        {
            // Suspend updates otherwise we'll get columns for the wrong items (or vice versa)
            this._suspendVirtual = true;

            // Since we now use a virtual list when the list changes we can just refresh the source
            if (checks.HasFlag(EListInvalids._SourceChanged) | checks.HasFlag(EListInvalids._ContentsChanged))
            {
                checks = this.Rebuild__GetFilteredList(checks);
            }

            // If we have not yet got the columns we always need to get them regardless
            if (this._availableColumns.Count == 0)
            {
                checks |= EListInvalids._ColumnsChanged | EListInvalids._ColumnVisibilitiesChanged;
            }

            if (checks.HasFlag(EListInvalids._ColumnsChanged))
            {
                this.GetAvailableColumns();
            }

            if (checks.HasFlag(EListInvalids._ColumnVisibilitiesChanged))
            {
                this.CreateListViewColumnHeaders();
            }

            if (checks.HasFlag(EListInvalids._ValuesChanged))
            {
                // Since we now use a virtual list the only thing we need to update are the previews, the rest will update when we redraw
                this._imageList.Clear();
            }

            // Resume updates
            this._suspendVirtual = false;


            // Redraw everything
            if (this._listView.VirtualListSize != 0)
            {
                this._listView.RedrawItems(0, this._listView.VirtualListSize - 1, true);
            }
        }