Exemplo n.º 1
0
        /// <summary>
        /// Adds an array of previously created DateTime objects to the collection.
        /// </summary>
        /// <param name="inputItems">An array of DateTime objects representing the dates to add to the collection.</param>
        public virtual void AddRange(DateTime[] inputItems)
        {
            if (inputItems == null)
            {
                throw new ArgumentNullException();
            }

            if (inputItems.Length == 0)
            {
                return;
            }

            if (!this.calendar.AllowMultipleSelect)
            {
                this.Add(inputItems[0]);
                return;
            }

            if (!this.updating)
            {
                SelectionEventArgs args = this.calendar.CallOnSelectionChanging(this);
                if (args.Cancel)
                {
                    return;
                }
            }

            for (int i = 0; i < inputItems.Length; i++)
            {
                if (this.CanAdd(inputItems[i]))
                {
                    this.children.Add(inputItems[i]);
                }
            }

            if (!this.updating)
            {
                this.calendar.CallOnSelectionChanged();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Removes a range of DateTime elements from the DateTimeCollection.
        /// </summary>
        /// <param name="index">The zero-based starting index of the range of elements to remove.</param>
        /// <param name="count">The number of elements to remove.</param>
        public virtual void RemoveRange(int index, int count)
        {
            if (count == 0)
            {
                return;
            }
            for (int i = index; i < count; i++)
            {
                if (this.calendar != null && !this.updating)
                {
                    SelectionEventArgs args = this.calendar.CallOnSelectionChanging(this);
                    if (args.Cancel)
                    {
                        return;
                    }
                }

                children.RemoveAt(i);
                if (this.calendar != null && !this.updating)
                {
                    this.calendar.CallOnSelectionChanged();
                }
            }
        }