コード例 #1
0
        /// <summary>
        /// Inserts a new item at the given index to the list.
        /// </summary>
        /// <param name="index">The index to place the new item.</param>
        /// <param name="item">The item to add.</param>
        public void Insert(int index, ObjectField item)
        {
            IList list = Value as IList;

            if (list != null)
            {
                list.Insert(index, item.Value);
                Items.Insert(index, item);
                Count++;
                RefreshItemNames();
                OnItemAdded(item);
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes an item from the list.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        public override void Remove(ObjectField item)
        {
            IList list = Value as IList;

            if (list != null && Items.Contains(item))
            {
                list.Remove(item.Value);
                Items.Remove(item);
                RefreshItemNames();
                Count--;
                OnItemRemoved(item);
            }
        }
コード例 #3
0
        /// <summary>
        /// Adds a new item to the list.
        /// </summary>
        /// <param name="item">The item to add.</param>
        public override void Add(ObjectField item)
        {
            IList list = Value as IList;

            if (list != null)
            {
                list.Add(item.Value);
                Items.Add(item);
                Count++;
                RefreshItemNames();
                OnItemAdded(item);
            }
        }
コード例 #4
0
        /// <summary>
        /// Removes an item from the dictionary.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        public override void Remove(ObjectField item)
        {
            IDictionary dictionary = Value as IDictionary;
            string      key        = item.NameTag as string;

            if (dictionary != null && key != null)
            {
                dictionary.Remove(key);
                Items.Remove(key);
                Count--;
                OnItemRemoved(item);
            }
        }
コード例 #5
0
        /// <summary>
        /// Adds a new item to the dictionary.
        /// </summary>
        /// <param name="item">The item itself.</param>
        public override void Add(ObjectField item)
        {
            IDictionary dictionary = Value as IDictionary;
            string      key        = item.NameTag as string;

            if (dictionary != null && key != null)
            {
                dictionary.Add(key, item.Value);
                Items.Add(key, item);
                Count++;
                OnItemAdded(item);
            }
        }
コード例 #6
0
        /// <summary>
        /// Moves an item of the list to another position.
        /// </summary>
        /// <param name="item">The item to move.</param>
        /// <param name="newIndex">The new position inside the list of items.</param>
        public void Move(ObjectField item, int newIndex)
        {
            int   oldIndex = Items.IndexOf(item);
            IList list     = Value as IList;

            if (list != null && oldIndex >= 0)
            {
                Remove(item);
                if (oldIndex < newIndex)
                {
                    list.Insert(newIndex - 1, item.Value);
                    Items.Insert(newIndex - 1, item);
                }
                else
                {
                    list.Insert(newIndex, item.Value);
                    Items.Insert(newIndex, item);
                }
                Count++; // We removed the old item, so Count was decreased before.
                RefreshItemNames();
                OnItemAdded(item);
            }
        }
コード例 #7
0
 /// <summary>
 /// Removes an item from the collection.
 /// </summary>
 /// <param name="item">The item to remove.</param>
 public abstract void Remove(ObjectField item);
コード例 #8
0
        // ========================================================================
        // Methods

        #region === Methods

        /// <summary>
        /// Adds a new item to the collection.
        /// </summary>
        /// <param name="item">The item itself.</param>
        public abstract void Add(ObjectField item);