summaryrefslogtreecommitdiffstats
path: root/win/C#/interop/SourceData/Title.cs
blob: 8d69494efea0b7ccff3d5a9310ed01e74c14f6a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*  Title.cs $
 	
 	   This file is part of the HandBrake source code.
 	   Homepage: <http://handbrake.fr>.
 	   It may be used under the terms of the GNU General Public License. */

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;
using HandBrake.Interop;

namespace HandBrake.SourceData
{
    /// <summary>
    /// An object that represents a single Title of a DVD
    /// </summary>
    public class Title
    {
        private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
        private readonly List<AudioTrack> audioTracks;
        private readonly List<Chapter> chapters;
        private readonly List<Subtitle> subtitles;
        
        /// <summary>
        /// The constructor for this object
        /// </summary>
        public Title()
        {
            this.audioTracks = new List<AudioTrack>();
            this.chapters = new List<Chapter>();
            this.subtitles = new List<Subtitle>();
        }

        /// <summary>
        /// Collection of chapters in this Title
        /// </summary>
        public List<Chapter> Chapters
        {
            get { return this.chapters; }
        }

        /// <summary>
        /// Collection of audio tracks associated with this Title
        /// </summary>
        public List<AudioTrack> AudioTracks
        {
            get { return this.audioTracks; }
        }

        /// <summary>
        /// Collection of subtitles associated with this Title
        /// </summary>
        public List<Subtitle> Subtitles
        {
            get { return this.subtitles; }
        }

        /// <summary>
        /// The track number of this Title (1-based).
        /// </summary>
        public int TitleNumber { get; set; }

        /// <summary>
        /// The length in time of this Title
        /// </summary>
        public TimeSpan Duration { get; set; }

        /// <summary>
        /// The resolution (width/height) of this Title
        /// </summary>
        public Size Resolution { get; set; }

        /// <summary>
        /// The aspect ratio of this Title
        /// </summary>
        public double AspectRatio { get; set; }

        public int AngleCount { get; set; }

        /// <summary>
        /// Par Value
        /// </summary>
        public Size ParVal { get; set; }

        /// <summary>
        /// The automatically detected crop region for this Title.
        /// This is an int array with 4 items in it as so:
        /// 0: 
        /// 1: 
        /// 2: 
        /// 3: 
        /// </summary>
        public Cropping AutoCropDimensions { get; set; }
  
        /// <summary>
        /// Override of the ToString method to provide an easy way to use this object in the UI
        /// </summary>
        /// <returns>A string representing this track in the format: {title #} (00:00:00)</returns>
        public override string ToString()
        {
            return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.TitleNumber, this.Duration.Hours,
                                 this.Duration.Minutes, this.Duration.Seconds);
        }

        public string Display
        {
            get
            {
                return this.ToString();
            }
        }
    }
}