using System;

/*
    Copyright (c) 2010 flixmonk. (http://DVDSwarm.codeplex.com)
    All Rights Reserved.
        
    Redistribution and use in source and binary forms, with or without modification,
    are permitted provided that the following conditions are met:
        
    * Redistributions of source code must retain the above copyright notice, this list
      of conditions and the following disclaimer.
        
    * Redistributions in binary form must reproduce the above copyright notice, this
    list of conditions and the following disclaimer in the documentation and/or other
    materials provided with the distribution. 
        
    * Neither the name of The Flixmonk nor the names of its contributors may be used to
    endorse or promote products derived from this software without specific prior written
    permission.
        
    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
    OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
    SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
    OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
    TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
namespace DVDSwarm.Dvd
{
    /// <summary>
    /// Contains information about a subtitle. Member of the ProgramChain class.
    /// </summary>
    sealed public class Subtitle
    {
        #region Fields

        private SubtitleAspect _aspect;
        private bool _checked = true;
        private string _description;
        private string _language;
        private Int32 _subpictureIndex;
        private Int32 _trackId;
        
        #endregion

        #region Properties

        /// <summary>
        /// Gets the aspect of the subtitle.
        /// </summary>
        public Dvd.SubtitleAspect Aspect
        {
            get
            {
                return _aspect;
            }
        }
        /// <summary>
        /// Gets and sets whether the subpicture is selected.
        /// </summary>
        public bool Checked
        {
            get
            {
                return _checked;
            }
            set
            {
                _checked = value;
            }
        }
        /// <summary>
        /// Gets a description for the subtitle.
        /// </summary>
        public string Description
        {
            get
            {
                return _description;
            }
        }
        /// <summary>
        /// Gets the language for the subtitle.
        /// </summary>
        public string Language
        {
            get
            {
                return _language;
            }
        }
        /// <summary>
        /// Gets the subpicture stream index associated with the TitleSet.Subpictures property.
        /// </summary>
        public Int32 SubpictureIndex
        {
            get
            {
                return _subpictureIndex;
            }
        }
        /// <summary>
        /// Gets the track ID for the subtitle. Values start at 0x20.
        /// </summary>
        public Int32 TrackId
        {
            get
            {
                return _trackId;
            }       
        }

        #endregion

        #region Methods

        /// <summary>
        /// Creates a new instance of the Subtitle class.
        /// </summary>
        /// <param name="track">The track number for the subtitle. Values start at 0x20.</param>
        /// <param name="subpictureIndex">The subpicture stream index associated with the
        /// TitleSet.Subpictures property.</param>
        /// <param name="language">The language for the subtitle.</param>
        /// <param name="description">The description for the subtitle.</param>
        /// <param name="aspect">The aspect for the subtitle.</param>
        /// <exception cref="System.ArgumentException">Thrown when language is null or empty.</exception>
        /// <exception cref="System.ArgumentException">Thrown when description is null or empty.</exception>
        public Subtitle(Int32 track, Int32 subpictureIndex, string language, string description, SubtitleAspect aspect)
        {
            if (string.IsNullOrEmpty(language))
            {
                throw new ArgumentException("language is null or empty.");
            }
            if (string.IsNullOrEmpty(description))
            {
                throw new ArgumentException("description is null or empty.");
            }

            _aspect = aspect;
            _description = description;
            _language = language;
            _subpictureIndex = subpictureIndex;
            _trackId = track;
        }

        #endregion
    }
}
