Esempio n. 1
0
        /// <summary>
        /// A range of lines has been replaced with a new range of lines.  The new set may be
        /// the same size, larger, or smaller than the previous.
        /// </summary>
        /// <param name="startIndex">Start index of change area.</param>
        /// <param name="oldCount">Number of old lines.</param>
        /// <param name="newCount">Number of new lines.  May be zero.</param>
        public void ClearListSegment(int startIndex, int oldCount, int newCount)
        {
            Debug.WriteLine("ClearListSegment start=" + startIndex + " old=" + oldCount +
                            " new=" + newCount + " (mList.Count=" + mList.Count + ")");

            Debug.Assert(startIndex >= 0 && startIndex < mList.Count);
            Debug.Assert(oldCount >= 0 && startIndex + oldCount <= mList.Count);
            Debug.Assert(newCount >= 0);

            // Remove the old elements to clear them.
            if (oldCount != 0)
            {
                mList.RemoveRange(startIndex, oldCount);
            }
            // Replace with the appropriate number of null entries.
            for (int i = 0; i < newCount; i++)
            {
                mList.Insert(startIndex, null);
            }
            // TODO(someday): can we null out existing entries, and just insert/remove when
            //   counts differ?

            if (oldCount != newCount)
            {
                SelectedIndices = new DisplayListSelection(mList.Count);
                RecalculateListIndices();
            }

            OnPropertyChanged(CountString);
            OnPropertyChanged(IndexerName);
            // TODO: this causes the ListView to format the entire listing, despite
            //   being virtual.  So we're regenerating the entire list after something trivial,
            //   like renaming a label, which hampers performance.  Need to figure this out.
            OnCollectionReset();
        }
Esempio n. 2
0
        /// <summary>
        /// A range of lines has been replaced with a new range of lines.  The new set may be
        /// the same size, larger, or smaller than the previous.
        /// </summary>
        /// <param name="startIndex">Start index of change area.</param>
        /// <param name="oldCount">Number of old lines.</param>
        /// <param name="newCount">Number of new lines.  May be zero.</param>
        public void ClearListSegment(int startIndex, int oldCount, int newCount)
        {
            Debug.WriteLine("ClearListSegment start=" + startIndex + " old=" + oldCount +
                            " new=" + newCount + " (mList.Count=" + mList.Count + ")");

            Debug.Assert(startIndex >= 0 && startIndex < mList.Count);
            Debug.Assert(oldCount > 0 && startIndex + oldCount <= mList.Count);
            Debug.Assert(newCount >= 0);

            // Remove the old elements to clear them.
            mList.RemoveRange(startIndex, oldCount);
            // Replace with the appropriate number of null entries.
            for (int i = 0; i < newCount; i++)
            {
                mList.Insert(startIndex, null);
            }
            // TODO: can we null out existing entries, and just insert/remove when counts differ?

            if (oldCount != newCount)
            {
                SelectedIndices = new DisplayListSelection(mList.Count);
                RecalculateListIndices();
            }

            OnPropertyChanged(CountString);
            OnPropertyChanged(IndexerName);
            OnCollectionReset();
        }
Esempio n. 3
0
        public void Clear()
        {
            ((IList <FormattedParts>)mList).Clear();
            OnPropertyChanged(CountString);
            OnPropertyChanged(IndexerName);
            OnCollectionReset();

            // Not strictly necessary, but does free up the memory sooner.
            SelectedIndices = new DisplayListSelection();
        }
Esempio n. 4
0
        /// <summary>
        /// Resets the list, filling it with empty elements.  Also resets the selected indices.
        /// </summary>
        /// <param name="size">New size of the list.</param>
        public void ResetList(int size)
        {
            // TODO: can we recycle existing elements and just add/trim as needed?
            Clear();
            mList.Capacity = size;
            for (int i = 0; i < size; i++)
            {
                // add directly to list so we don't send events
                mList.Add(null);
            }

            SelectedIndices = new DisplayListSelection(size);

            // send one big notification at the end; "reset" means "forget everything you knew"
            OnPropertyChanged(CountString);
            OnPropertyChanged(IndexerName);
            OnCollectionReset();
        }
Esempio n. 5
0
 /// <summary>
 /// Constructs an empty collection, with the default initial capacity.
 /// </summary>
 public DisplayList()
 {
     mList           = new List <FormattedParts>();
     SelectedIndices = new DisplayListSelection();
 }