Click here to Skip to main content
15,891,253 members
Articles / Web Development / HTML

DayPilot Scheduler Control for ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.91/5 (54 votes)
20 Jan 2016Apache4 min read 306.2K   8K   276  
Flexible open-source scheduler control (resource booking, project management, timeline and free/busy visualization, Gantt)
/*
Copyright � 2005 - 2012 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
{
    /// <summary>
    /// Collection of resources definitions.
    /// </summary>

    [TypeConverter(typeof(ResourceCollectionConverter))]
    public class ResourceCollection : CollectionBase
    {
        internal bool designMode;

        /// <summary>
        /// Gets the specified <see cref="Resource">Resource</see>.
        /// </summary>
        /// <param name="index">Item index</param>
        /// <returns>Resource at the specified position.</returns>
        public Resource this[int index]
        {
            get
            {
                return ((Resource)List[index]);
            }
            set
            {
                List[index] = value;
            }
        }

        /// <summary>
        /// Converts ResourceCollection to ArrayList.
        /// </summary>
        /// <returns>ArrayList with ResourceCollection items.</returns>
        public ArrayList ToArrayList()
        {
            ArrayList retArray = new ArrayList();
            for (int i = 0; i < this.Count; i++)
            {
                retArray.Add(this[i]);
            }

            return retArray;
        }

        /// <summary>
        /// Adds a new <see cref="Resource">Resource</see> to the collection.
        /// </summary>
        /// <param name="value">Resource to be added.</param>
        /// <returns></returns>
        public int Add(Resource value)
        {
            return (List.Add(value));
        }

        /// <summary>
        /// Adds a new <see cref="Resource">Resource</see> to the collection.
        /// </summary>
        /// <param name="name">Resource name</param>
        /// <param name="id">Resource id</param>
        /// <returns></returns>
        public int Add(string name, string id)
        {
            return Add(new Resource(name, id));
        }

        /// <summary>
        /// Determines the index of a specific item in the collection.
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public int IndexOf(Resource value)
        {
            return (List.IndexOf(value));
        }

        /// <summary>
        /// Inserts a new resource at the specified position.
        /// </summary>
        /// <param name="index">New resource position.</param>
        /// <param name="value">Resource to be added.</param>
        public void Insert(int index, Resource value)
        {
            List.Insert(index, value);
        }

        /// <summary>
        /// Removes a Resource from the collection.
        /// </summary>
        /// <param name="value">Resource to be removed.</param>
        public void Remove(Resource value)
        {
            List.Remove(value);
        }


        /// <summary>
        /// Determines whether the collection contains a specified resource.
        /// </summary>
        /// <param name="value">Resource to be found.</param>
        /// <returns>True if the collection contains the resource</returns>
        public bool Contains(Resource value)
        {
            return (List.Contains(value));
        }


        /// <summary>
        /// Creates a new collection from an ArrayList.
        /// </summary>
        /// <param name="items">ArrayList that contains the new resources.</param>
        public ResourceCollection(ArrayList items)
            : base()
        {
            for (int i = 0; i < items.Count; i++)
            {
                if (items[i] is Resource)
                {
                    this.Add((Resource)items[i]);
                }
            }
        }

        /// <summary>
        /// Creates a new ResourceCollection.
        /// </summary>
        public ResourceCollection()
            : base()
        { }
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


Written By
Czech Republic Czech Republic
My open-source event calendar/scheduling web UI components:

DayPilot for JavaScript, Angular, React and Vue

Comments and Discussions