/// <summary> /// Adds an item to the list /// </summary> public int Add(ColorStop value) { //check if not enough space then allocate more if (mCount >= mCapacity) { //calculate new capacity int newCapacity; if (mCapacity < 1000) newCapacity = (int)(mCapacity * 2); else if (mCapacity < 5000) newCapacity = (int)(mCapacity * 1.5); else newCapacity = (int)(mCapacity * 1.2); //allocate new buffer ColorStop[] newItems = new ColorStop[newCapacity]; //copy old values to new buffer mItems.CopyTo(newItems, 0); //assign the new bufer to current buffer mItems = newItems; mCapacity = newCapacity; } //assign the new value to the end of current buffer mItems[mCount] = value; mCount++; IsChangeStops = true; return mCount - 1; }
/// <summary> /// Determines the index of a specific item /// </summary> public int IndexOf(ColorStop value) { if (value == null) { //search for the first occurence of null item for (int i = 0; i < mCount; i++) { if (mItems[i] == null) { return(i); } } } else { //search for the first match for (int i = 0; i < mCount; i++) { if (value.Equals(mItems[i])) { return(i); } } } return(-1); }
/// <summary> /// Inserts an item to the list at the specified index /// </summary> public void Insert(int index, ColorStop value) { //check if not enough space then allocate more if (mCount >= mCapacity) { //calculate new capacity int newCapacity; if (mCapacity < 1000) { newCapacity = (int)(mCapacity * 2); } else if (mCapacity < 5000) { newCapacity = (int)(mCapacity * 1.5); } else { newCapacity = (int)(mCapacity * 1.2); } //allocate new buffer ColorStop[] newItems = new ColorStop[newCapacity]; //copy old values from left of index to new buffer if (index > 0) { Array.Copy(mItems, 0, newItems, 0, index); } //assign the new value to the index position of the new buffer newItems[index] = value; //copy old values from right of index to new buffer if (index < mCount) { Array.Copy(mItems, index, newItems, index + 1, mCount - index); } //assign the new bufer to current buffer mItems = newItems; mCapacity = newCapacity; mCount++; } else { //copy old values from right of index to new buffer if (index < mCount) { Array.Copy(mItems, index, mItems, index + 1, mCount - index); } //assign the new value to the index position of the new buffer mItems[index] = value; mCount++; } IsChangeStops = true; }
/// <summary> /// Removes the first occurrence of a specific object from the list. /// </summary> public void Remove(ColorStop value) { int index = IndexOf(value); if (index >= 0) { RemoveAt(index); } IsChangeStops = true; }
/// <summary> /// Advances the enumerator to the next queue of the enumeration, if one is currently available. /// </summary> /// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns> public bool MoveNext() { mIndex++; if (mIndex < mCollection.mCount) { mCurrentElement = mCollection.mItems[mIndex]; return(true); } mIndex = mCollection.mCount; return(false); }
/// <summary> /// Adds an item to the list /// </summary> public int Add(ColorStop value) { //check if not enough space then allocate more if (mCount >= mCapacity) { //calculate new capacity int newCapacity; if (mCapacity < 1000) { newCapacity = (int)(mCapacity * 2); } else if (mCapacity < 5000) { newCapacity = (int)(mCapacity * 1.5); } else { newCapacity = (int)(mCapacity * 1.2); } //allocate new buffer ColorStop[] newItems = new ColorStop[newCapacity]; //copy old values to new buffer mItems.CopyTo(newItems, 0); //assign the new bufer to current buffer mItems = newItems; mCapacity = newCapacity; } //assign the new value to the end of current buffer mItems[mCount] = value; mCount++; IsChangeStops = true; return(mCount - 1); }
/// <summary> /// Advances the enumerator to the next queue of the enumeration, if one is currently available. /// </summary> /// <returns>true, if the enumerator was succesfully advanced to the next queue; false, if the enumerator has reached the end of the enumeration.</returns> public bool MoveNext() { mIndex++; if (mIndex < mCollection.mCount) { mCurrentElement = mCollection.mItems[mIndex]; return true; } mIndex = mCollection.mCount; return false; }
/// <summary> /// Reset the cursor, so it points to the beginning of the enumerator. /// </summary> public void Reset() { mIndex = -1; mCurrentElement = null; }
/// <summary> /// Adds a new color stop /// </summary> /// <param name="color">The color value of stop</param> /// <param name="stop">Position of stop (must be in range [0..1]</param> public int Add(Color color, double stop) { ColorStop cs = new ColorStop(color, stop); return Add(cs); }
/// <summary> /// Removes the first occurrence of a specific object from the list. /// </summary> public void Remove(ColorStop value) { int index = IndexOf(value); if (index >= 0) RemoveAt(index); IsChangeStops = true; }
/// <summary> /// Inserts an item to the list at the specified index /// </summary> public void Insert(int index, ColorStop value) { //check if not enough space then allocate more if (mCount >= mCapacity) { //calculate new capacity int newCapacity; if (mCapacity < 1000) newCapacity = (int)(mCapacity * 2); else if (mCapacity < 5000) newCapacity = (int)(mCapacity * 1.5); else newCapacity = (int)(mCapacity * 1.2); //allocate new buffer ColorStop[] newItems = new ColorStop[newCapacity]; //copy old values from left of index to new buffer if (index > 0) { Array.Copy(mItems, 0, newItems, 0, index); } //assign the new value to the index position of the new buffer newItems[index] = value; //copy old values from right of index to new buffer if (index < mCount) { Array.Copy(mItems, index, newItems, index + 1, mCount - index); } //assign the new bufer to current buffer mItems = newItems; mCapacity = newCapacity; mCount++; } else { //copy old values from right of index to new buffer if (index < mCount) { Array.Copy(mItems, index, mItems, index + 1, mCount - index); } //assign the new value to the index position of the new buffer mItems[index] = value; mCount++; } IsChangeStops = true; }
/// <summary> /// Determines the index of a specific item /// </summary> public int IndexOf(ColorStop value) { if (value == null) { //search for the first occurence of null item for (int i = 0; i < mCount; i++) { if (mItems[i] == null) return i; } } else { //search for the first match for (int i = 0; i < mCount; i++) { if (value.Equals(mItems[i])) return i; } } return -1; }
/// <summary> /// Adds a new color stop /// </summary> /// <param name="color">The color value of stop</param> /// <param name="stop">Position of stop (must be in range [0..1]</param> public int Add(Color color, double stop) { ColorStop cs = new ColorStop(color, stop); return(Add(cs)); }