/// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.CellAt"]/*' />
 public DataGridViewCell this[int index]
 {
     get
     {
         Debug.Assert(index >= 0);
         Debug.Assert(index < this.count);
         if (this.lastAccessedIndex == -1 || index < this.lastAccessedIndex)
         {
             DataGridViewCellLinkedListElement tmp = this.headElement;
             int tmpIndex = index;
             while (tmpIndex > 0)
             {
                 tmp = tmp.Next;
                 tmpIndex--;
             }
             this.lastAccessedElement = tmp;
             this.lastAccessedIndex = index;
             return tmp.DataGridViewCell;
         }
         else
         {
             while (this.lastAccessedIndex < index)
             {
                 this.lastAccessedElement = this.lastAccessedElement.Next;
                 this.lastAccessedIndex++;
             }
             return this.lastAccessedElement.DataGridViewCell;
         }
     }
 }
 public void Clear()
 {
     this.lastAccessedElement = null;
     this.lastAccessedIndex = -1;
     this.headElement = null;
     this.count = 0;
 }
 public bool Remove(DataGridViewCell dataGridViewCell)
 {
     DataGridViewCellLinkedListElement element = null;
     DataGridViewCellLinkedListElement headElement = this.headElement;
     while (headElement != null)
     {
         if (headElement.DataGridViewCell == dataGridViewCell)
         {
             break;
         }
         element = headElement;
         headElement = headElement.Next;
     }
     if (headElement.DataGridViewCell != dataGridViewCell)
     {
         return false;
     }
     DataGridViewCellLinkedListElement next = headElement.Next;
     if (element == null)
     {
         this.headElement = next;
     }
     else
     {
         element.Next = next;
     }
     this.count--;
     this.lastAccessedElement = null;
     this.lastAccessedIndex = -1;
     return true;
 }
 public void Add(DataGridViewCell dataGridViewCell)
 {
     DataGridViewCellLinkedListElement element = new DataGridViewCellLinkedListElement(dataGridViewCell);
     if (this.headElement != null)
     {
         element.Next = this.headElement;
     }
     this.headElement = element;
     this.count++;
     this.lastAccessedElement = null;
     this.lastAccessedIndex = -1;
 }
 bool IEnumerator.MoveNext()
 {
     if (this.reset)
     {
         this.current = this.headElement;
         this.reset = false;
     }
     else
     {
         this.current = this.current.Next;
     }
     return (this.current != null);
 }
 public bool Contains(DataGridViewCell dataGridViewCell)
 {
     int num = 0;
     DataGridViewCellLinkedListElement headElement = this.headElement;
     while (headElement != null)
     {
         if (headElement.DataGridViewCell == dataGridViewCell)
         {
             this.lastAccessedElement = headElement;
             this.lastAccessedIndex = num;
             return true;
         }
         headElement = headElement.Next;
         num++;
     }
     return false;
 }
Example #7
0
        public bool Contains(DataGridViewCell dataGridViewCell)
        {
            Debug.Assert(dataGridViewCell != null);
            int index = 0;
            DataGridViewCellLinkedListElement tmp = headElement;

            while (tmp != null)
            {
                if (tmp.DataGridViewCell == dataGridViewCell)
                {
                    lastAccessedElement = tmp;
                    lastAccessedIndex   = index;
                    return(true);
                }
                tmp = tmp.Next;
                index++;
            }
            return(false);
        }
 public DataGridViewCell this[int index]
 {
     get
     {
         if ((this.lastAccessedIndex != -1) && (index >= this.lastAccessedIndex))
         {
             while (this.lastAccessedIndex < index)
             {
                 this.lastAccessedElement = this.lastAccessedElement.Next;
                 this.lastAccessedIndex++;
             }
             return(this.lastAccessedElement.DataGridViewCell);
         }
         DataGridViewCellLinkedListElement headElement = this.headElement;
         for (int i = index; i > 0; i--)
         {
             headElement = headElement.Next;
         }
         this.lastAccessedElement = headElement;
         this.lastAccessedIndex   = index;
         return(headElement.DataGridViewCell);
     }
 }
Example #9
0
        public bool Remove(DataGridViewCell dataGridViewCell)
        {
            Debug.Assert(dataGridViewCell is not null);
            DataGridViewCellLinkedListElement tmp1 = null, tmp2 = headElement;

            while (tmp2 is not null)
            {
                if (tmp2.DataGridViewCell == dataGridViewCell)
                {
                    break;
                }

                tmp1 = tmp2;
                tmp2 = tmp2.Next;
            }

            if (tmp2.DataGridViewCell == dataGridViewCell)
            {
                DataGridViewCellLinkedListElement tmp3 = tmp2.Next;
                if (tmp1 is null)
                {
                    headElement = tmp3;
                }
                else
                {
                    tmp1.Next = tmp3;
                }

                count--;
                lastAccessedElement = null;
                lastAccessedIndex   = -1;
                return(true);
            }

            return(false);
        }
 /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedListEnumerator.IEnumerator.Reset"]/*' />
 void IEnumerator.Reset()
 {
     this.reset   = true;
     this.current = null;
 }
 public DataGridViewCellLinkedListEnumerator(DataGridViewCellLinkedListElement headElement)
 {
     this.headElement = headElement;
     reset            = true;
 }
 void IEnumerator.Reset()
 {
     reset   = true;
     current = null;
 }
 public int RemoveAllCellsAtBand(bool column, int bandIndex)
 {
     int num = 0;
     DataGridViewCellLinkedListElement element = null;
     DataGridViewCellLinkedListElement headElement = this.headElement;
     while (headElement != null)
     {
         if ((column && (headElement.DataGridViewCell.ColumnIndex == bandIndex)) || (!column && (headElement.DataGridViewCell.RowIndex == bandIndex)))
         {
             DataGridViewCellLinkedListElement next = headElement.Next;
             if (element == null)
             {
                 this.headElement = next;
             }
             else
             {
                 element.Next = next;
             }
             headElement = next;
             this.count--;
             this.lastAccessedElement = null;
             this.lastAccessedIndex = -1;
             num++;
         }
         else
         {
             element = headElement;
             headElement = headElement.Next;
         }
     }
     return num;
 }
 /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.Remove"]/*' />
 public bool Remove(DataGridViewCell dataGridViewCell)
 {
     Debug.Assert(dataGridViewCell != null);
     DataGridViewCellLinkedListElement tmp1 = null, tmp2 = this.headElement;
     while (tmp2 != null)
     {
         if (tmp2.DataGridViewCell == dataGridViewCell)
         {
             break;
         }
         tmp1 = tmp2;
         tmp2 = tmp2.Next;
     }
     if (tmp2.DataGridViewCell == dataGridViewCell)
     {
         DataGridViewCellLinkedListElement tmp3 = tmp2.Next;
         if (tmp1 == null)
         {
             this.headElement = tmp3;
         }
         else
         {
             tmp1.Next = tmp3;
         }
         this.count--;
         this.lastAccessedElement = null;
         this.lastAccessedIndex = -1;
         return true;
     }
     return false;
 }
 /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedListEnumerator.IEnumerator.MoveNext"]/*' />
 bool IEnumerator.MoveNext()
 {
     if (this.reset)
     {
         Debug.Assert(this.current == null);
         this.current = this.headElement;
         this.reset = false;
     }
     else
     {
         Debug.Assert(this.current != null); // Since this is for internal use only.
         this.current = this.current.Next;
     }
     return (this.current != null);
 }
        /* Unused for now
        /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.RemoveHead"]/*' />
        public DataGridViewCell RemoveHead()
        {
            if (this.headElement == null)
            {
                return null;
            }
            DataGridViewCellLinkedListElement tmp = this.headElement;
            this.headElement = tmp.Next;
            this.count--;
            this.lastAccessedElement = null;
            this.lastAccessedIndex = -1;
            return tmp.DataGridViewCell;
        }
        */

        /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.RemoveAllCellsAtColumn"]/*' />
        public int RemoveAllCellsAtBand(bool column, int bandIndex)
        {
            int removedCount = 0;
            DataGridViewCellLinkedListElement tmp1 = null, tmp2 = this.headElement;
            while (tmp2 != null)
            {
                if ((column && tmp2.DataGridViewCell.ColumnIndex == bandIndex) ||
                    (!column && tmp2.DataGridViewCell.RowIndex == bandIndex))
                {
                    DataGridViewCellLinkedListElement tmp3 = tmp2.Next;
                    if (tmp1 == null)
                    {
                        this.headElement = tmp3;
                    }
                    else
                    {
                        tmp1.Next = tmp3;
                    }
                    tmp2 = tmp3;
                    this.count--;
                    this.lastAccessedElement = null;
                    this.lastAccessedIndex = -1;
                    removedCount++;
                }
                else
                {
                    tmp1 = tmp2;
                    tmp2 = tmp2.Next;
                }
            }
            return removedCount;
        }
 /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.Add"]/*' />
 public void Add(DataGridViewCell dataGridViewCell)
 {
     Debug.Assert(dataGridViewCell != null);
     Debug.Assert(dataGridViewCell.DataGridView.SelectionMode == DataGridViewSelectionMode.CellSelect ||
                  dataGridViewCell.DataGridView.SelectionMode == DataGridViewSelectionMode.ColumnHeaderSelect ||
                  dataGridViewCell.DataGridView.SelectionMode == DataGridViewSelectionMode.RowHeaderSelect);
     DataGridViewCellLinkedListElement newHead = new DataGridViewCellLinkedListElement(dataGridViewCell);
     if (this.headElement != null)
     {
         newHead.Next = this.headElement;
     }
     this.headElement = newHead;
     this.count++;
     this.lastAccessedElement = null;
     this.lastAccessedIndex = -1;
 }
 public DataGridViewCell this[int index]
 {
     get
     {
         if ((this.lastAccessedIndex != -1) && (index >= this.lastAccessedIndex))
         {
             while (this.lastAccessedIndex < index)
             {
                 this.lastAccessedElement = this.lastAccessedElement.Next;
                 this.lastAccessedIndex++;
             }
             return this.lastAccessedElement.DataGridViewCell;
         }
         DataGridViewCellLinkedListElement headElement = this.headElement;
         for (int i = index; i > 0; i--)
         {
             headElement = headElement.Next;
         }
         this.lastAccessedElement = headElement;
         this.lastAccessedIndex = index;
         return headElement.DataGridViewCell;
     }
 }
 public DataGridViewCellLinkedListEnumerator(DataGridViewCellLinkedListElement headElement)
 {
     this.headElement = headElement;
     this.reset = true;
 }
 /// <include file='doc\DataGridViewCellLinkedList.uex' path='docs/doc[@for="DataGridViewCellLinkedList.Contains"]/*' />
 public bool Contains(DataGridViewCell dataGridViewCell)
 {
     Debug.Assert(dataGridViewCell != null);
     int index = 0;
     DataGridViewCellLinkedListElement tmp = this.headElement;
     while (tmp != null)
     {
         if (tmp.DataGridViewCell == dataGridViewCell)
         {
             this.lastAccessedElement = tmp;
             this.lastAccessedIndex = index;
             return true;
         }
         tmp = tmp.Next;
         index++;
     }
     return false;
 }
 void IEnumerator.Reset()
 {
     this.reset = true;
     this.current = null;
 }