private int RemoveHelper(int removeAt, int count, SortedRangeValueList <T> moveRanges) { if (removeAt >= Count) { return(rangeValues.Count); } int n = Split(removeAt); Split(removeAt + count); int total = 0; int deleteCount = 0; while (total < count && n + deleteCount < rangeValues.Count) { RangeValuePair <T> rv = rangeValues[n + deleteCount]; total += rv.Count; deleteCount++; if (moveRanges != null && !rv.Value.Equals(defaultValue)) { moveRanges.rangeValues.Add(new RangeValuePair <T>(rv.Start - removeAt, rv.Count, rv.Value)); } } rangeValues.RemoveRange(n, deleteCount); return(n); }
protected virtual void Dispose(bool isDisposing) { if (!isDisposing) { return; } if (lineNested != null) { lineNested.Clear(); } if (distances != null) { distances.Clear(); } LineSizeChanged = null; LineHiddenChanged = null; DefaultLineSizeChanged = null; LineCountChanged = null; HeaderLineCountChanged = null; FooterLineCountChanged = null; LinesInserted = null; LinesRemoved = null; //while reusing detailsview it throws excepiton so commented below the line. //lineSizes = null; lineHidden = null; }
/// <summary> /// Removes a range at the specified index. When necessary ranges /// are merged when preceeding and subsquent ranges have the same /// value. /// </summary> /// <param name="removeAt">The index for the range to be removed.</param> /// <param name="count">The count.</param> /// <param name="moveRanges">Allocate this object before a Remove call when moving ranges /// and pass it to a subsequent Insert call. Otherwise specify null.</param> public void Remove(int removeAt, int count, SortedRangeValueList <T> moveRanges) { if (removeAt >= Count) { return; } int n = RemoveHelper(removeAt, count, moveRanges); AdjustStart(n, -count); if (n > 0) { Merge(n - 1); } }
/// <summary> /// Set the hidden state all at once in one operation. Use this method if you want to change the hidden /// state of many rows at once since this will be much faster instead of individually setting rows hidden. /// </summary> /// <param name="values">The new hidden state for rows. </param> public void SetHiddenState(bool[] values) { SuspendUpdates(); lineHidden = new SortedRangeValueList <bool>(); int count = Math.Min(lineCount, values.Length); for (int index = 0; index < count; index++) { lineHidden[index] = values[index]; } ResumeUpdates(); }
/// <summary> /// Inserts a range intialized with a given value at /// the specified index. When necessary it splits a range and creates /// a new range value pair. /// </summary> /// <param name="insertAt">The insertion point.</param> /// <param name="count">The count.</param> /// <param name="value">The value.</param> /// <param name="moveRanges">Allocate this object before a preceeding Remove call when moving ranges. /// Otherwise specify null.</param> public void Insert(int insertAt, int count, T value, SortedRangeValueList <T> moveRanges) { if (insertAt >= Count) { if (value.Equals(defaultValue) && (moveRanges == null || moveRanges.Count == 0)) { return; } EnsureCount(insertAt); rangeValues.Add(new RangeValuePair <T>(insertAt, count, value)); if (rangeValues.Count >= 2) { Merge(rangeValues.Count - 2); } } else { int n = rangeValues.BinarySearch(new RangeValuePair <T>(insertAt)); RangeValuePair <T> rv = rangeValues[n]; if (value.Equals(rv.Value)) { rv.Count += count; AdjustStart(n + 1, count); } else { n = Split(insertAt, n); Split(insertAt + 1); var rv2 = new RangeValuePair <T>(insertAt, count, value); rangeValues.Insert(n, rv2); AdjustStart(n + 1, count); Merge(n); if (n > 0) { Merge(n - 1); } } } if (moveRanges != null) { foreach (RangeValuePair <T> rv in moveRanges) { SetRange(rv.Start + insertAt, rv.Count, rv.Value); } } }
/// <summary> /// Initialize the collection with a pattern of hidden lines. /// </summary> /// <param name="start">The index of the first line where the pattern should be /// started to be applied.</param> /// <param name="lineCount">The pattern is applied up to until the lineCount given. /// The last initialized line is at index lineCount-1.</param> /// <param name="values">The pattern that is applied repeatedly.</param> public void SetHiddenInterval(int start, int lineCount, bool[] values) { SuspendUpdates(); lineHidden = new SortedRangeValueList <bool>(); for (int index = start; index < lineCount; index += values.Length) { for (int n = 0; n < values.Length; n++) { if (n + index < lineCount) { lineHidden[index + n] = values[n]; } } } ResumeUpdates(); }
/// <summary> /// Inserts a range intialized with <see cref="DefaultValue"/> at /// the specified index. When necessary it splits a range and creates /// a new range value pair. /// </summary> /// <param name="insertAt">The insertion point.</param> /// <param name="count">The count.</param> /// <param name="moveRanges">Allocate this object before a preceeding Remove call when moving ranges. /// Otherwise specify null.</param> public void Insert(int insertAt, int count, SortedRangeValueList <T> moveRanges) { Insert(insertAt, count, DefaultValue, moveRanges); }
public void ResetHiddenState() { this.lineHidden = new SortedRangeValueList <bool>(); }