/* Copyright © 2005 - 2008 Annpoint, s.r.o. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ------------------------------------------------------------------------- NOTE: Reuse requires the following acknowledgement (see also NOTICE): This product includes DayPilot (http://www.daypilot.org) developed by Annpoint, s.r.o. */ using System.Collections; using System.ComponentModel; using DayPilot.Web.Ui.Serialization; namespace DayPilot.Web.Ui { /// /// Collection of resources definitions. /// [TypeConverter(typeof(ResourceCollectionConverter))] public class ResourceCollection : CollectionBase { internal bool designMode; /// /// Gets the specified Resource. /// /// Item index /// Resource at the specified position. public Resource this[int index] { get { return ((Resource)List[index]); } set { List[index] = value; } } /// /// Converts ResourceCollection to ArrayList. /// /// ArrayList with ResourceCollection items. public ArrayList ToArrayList() { ArrayList retArray = new ArrayList(); for (int i = 0; i < this.Count; i++) { retArray.Add(this[i]); } return retArray; } /// /// Adds a new Resource to the collection. /// /// Resource to be added. /// public int Add(Resource value) { return (List.Add(value)); } /// /// Adds a new Resource to the collection. /// /// Resource name /// Resource id /// public int Add(string name, string id) { return Add(new Resource(name, id)); } /// /// Determines the index of a specific item in the collection. /// /// /// public int IndexOf(Resource value) { return (List.IndexOf(value)); } /// /// Inserts a new resource at the specified position. /// /// New resource position. /// Resource to be added. public void Insert(int index, Resource value) { List.Insert(index, value); } /// /// Removes a Resource from the collection. /// /// Resource to be removed. public void Remove(Resource value) { List.Remove(value); } /// /// Determines whether the collection contains a specified resource. /// /// Resource to be found. /// True if the collection contains the resource public bool Contains(Resource value) { return (List.Contains(value)); } /// /// Creates a new collection from an ArrayList. /// /// ArrayList that contains the new resources. public ResourceCollection(ArrayList items) : base() { for (int i = 0; i < items.Count; i++) { if (items[i] is Resource) { this.Add((Resource)items[i]); } } } /// /// Creates a new ResourceCollection. /// public ResourceCollection() : base() { } } }