Beispiel #1
0
        /// <summary>
        /// Removes the element at the specified index of the collection.
        /// </summary>
        /// <param name="index">The zero-based index of the element to remove.</param>
        protected override void RemoveItem(int index)
        {
            // Remember the removedElement
            ChartNamedElement removedElement = index < Count ? this[index] : null;

            if (_disableDeleteCount == 0)
            {
                ((INameController)this).OnNameReferenceChanged(new NameReferenceChangedEventArgs(removedElement, null));
            }
            base.RemoveItem(index);
            if (_disableDeleteCount == 0)
            {
                // All elements referencing the removed element will be redirected to the first element in collection
                // Fire the NameReferenceChanged event to update all the dependent elements
                ChartNamedElement defaultElement = Count > 0 ? this[0] : null;
                ((INameController)this).OnNameReferenceChanged(new NameReferenceChangedEventArgs(removedElement, defaultElement));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Replaces the element at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the element to replace.</param>
        /// <param name="item">The new value for the element at the specified index.</param>
        protected override void SetItem(int index, T item)
        {
            if (String.IsNullOrEmpty(item.Name))
            {
                item.Name = NextUniqueName();
            }
            else if (!IsUniqueName(item.Name) && IndexOf(item.Name) != index)
            {
                throw new ArgumentException(SR.ExceptionNameAlreadyExistsInCollection(item.Name, GetType().Name));
            }

            //If the item references other named references we might need to fix the references
            FixNameReferences(item);

            // Remember the removedElement
            ChartNamedElement removedElement = index < Count ? this[index] : null;

            ((INameController)this).OnNameReferenceChanging(new NameReferenceChangedEventArgs(removedElement, item));
            base.SetItem(index, item);
            // Fire the NameReferenceChanged event to update all the dependent elements
            ((INameController)this).OnNameReferenceChanged(new NameReferenceChangedEventArgs(removedElement, item));
        }
Beispiel #3
0
 public NameReferenceChangedEventArgs(ChartNamedElement oldElement, string oldName, string newName)
 {
     _oldElement = oldElement;
     _oldName    = oldName;
     _newName    = newName;
 }
Beispiel #4
0
 public NameReferenceChangedEventArgs(ChartNamedElement oldElement, ChartNamedElement newElement)
 {
     _oldElement = oldElement;
     _oldName    = oldElement != null ? oldElement.Name : string.Empty;
     _newName    = newElement != null ? newElement.Name : string.Empty;
 }