Click here to Skip to main content
15,884,353 members
Articles / Desktop Programming / Windows Forms

BSEtunes

Rate me:
Please Sign up or sign in to vote.
4.67/5 (11 votes)
24 Apr 2010CPOL4 min read 64.6K   4.3K   58  
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
using System;
using System.Collections;
using System.Text;
using System.Collections.Generic;

namespace BSE.Platten.BO
{
    public class CTrackCollection : CollectionBase, IEnumerable<CTrack>
    {
        #region FieldsPrivate

        private int m_iIndex = -1;

        #endregion

        #region Properties

        public int Index
        {
            get { return this.m_iIndex; }
        }

        public CTrack this[int iIndex]
        {
            get { return this.List[iIndex] as CTrack; }
            set { this.List[iIndex] = value; }
        }

        public CTrack CurrentTrack
        {
            get
            {
                if ((this.m_iIndex >= 0 && this.m_iIndex < this.Count) == false)
                {
                    throw new IndexOutOfRangeException();
                }
                return this.List[this.m_iIndex] as CTrack;
            }
        }
        /// <summary>
        /// Checks if a next track is available.
        /// </summary>
        public bool IsNextTrackAvailable
        {
            get
            {
                return (this.m_iIndex < this.Count - 1);
            }
        }
        /// <summary>
        /// Checks if a previous track is available.
        /// </summary>
        public bool IsPreviousTrackAvailable
        {
            get { return (this.m_iIndex > 0);}
        }
        #endregion

        #region MethodsPublic

        public CTrackCollection()
        {
        }

        public CTrackCollection(int iCapacity)
            : this()
        {
            this.Capacity = iCapacity;
        }

        public CTrack Add(CTrack track)
        {
            this.List.Add(track);
            return track;
        }

        public bool MoveNext()
        {
            this.m_iIndex++;
            return this.m_iIndex >= 0 && this.m_iIndex < this.Count;
        }

        public bool MovePrevious()
        {
            bool bMovePrevious = false;
            if (this.IsPreviousTrackAvailable == true)
            {
                this.m_iIndex--;
                return this.m_iIndex >= 0 && this.m_iIndex < this.Count;
            }
            return bMovePrevious;
        }

        public bool MoveRandom()
        {
            Random random = new Random();
            this.m_iIndex = random.Next(0, this.Count - 1);
            return this.m_iIndex >= 0 && this.m_iIndex < this.Count;
        }

        public int GetRandomIndex()
        {
            Random random = new Random();
            return random.Next(0, this.Count - 1);
        }

        public void Reset()
        {
            this.m_iIndex = -1;
        }

        public new IEnumerator<CTrack> GetEnumerator()
        {
            foreach (CTrack track in this.List)
            {
                yield return track;
            }
        }

        public int IndexOf(CTrack value)
        {
            return ((IList)this).IndexOf((object)value);
        }

        public bool Contains(CTrack value)
        {
            return ((IList)this).Contains((object)value);
        }

        public void Insert(int index, CTrack value)
        {
            ((IList)this).Insert(index, (object)value);
        }

        public void Remove(CTrack value)
        {
            ((IList)this).Remove((object)value);
        }

        public void CopyTo(CTrack[] array, int index)
        {
            ((ICollection)this).CopyTo(array, index);
        }

        #endregion

        #region MethodsProtected
        #endregion

        #region MethodsPrivate
        #endregion
    }
}

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 Code Project Open License (CPOL)


Written By
Switzerland Switzerland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions