2 using System.Collections.Generic;
\r
6 namespace Handbrake.Parsing
\r
9 /// An object representing a Chapter aosciated with a Title, in a DVD
\r
11 public class Chapter
\r
13 private int m_chapterNumber;
\r
15 /// The number of this Chapter, in regards to it's parent Title
\r
17 public int ChapterNumber
\r
21 return this.m_chapterNumber;
\r
25 private TimeSpan m_duration;
\r
27 /// The length in time this Chapter spans
\r
29 public TimeSpan Duration
\r
33 return this.m_duration;
\r
38 /// Override of the ToString method to make this object easier to use in the UI
\r
40 /// <returns>A string formatted as: {chapter #}</returns>
\r
41 public override string ToString()
\r
43 return this.m_chapterNumber.ToString();
\r
46 public static Chapter Parse(StreamReader output)
\r
48 string curLine = output.ReadLine();
\r
49 if (!curLine.Contains(" + audio tracks:"))
\r
51 Chapter thisChapter = new Chapter();
\r
52 string[] splitter = curLine.Split(new string[] { " + ", ": cells ", ", ", " blocks, duration ", "->" }, StringSplitOptions.RemoveEmptyEntries);
\r
53 thisChapter.m_chapterNumber = int.Parse(splitter[0]);
\r
54 thisChapter.m_duration = TimeSpan.Parse(splitter[4]);
\r
63 public static Chapter[] ParseList(StreamReader output)
\r
65 List<Chapter> chapters = new List<Chapter>();
\r
66 string curLine = output.ReadLine();
\r
67 while (!curLine.Contains(" + audio tracks:"))
\r
69 Chapter thisChapter = Chapter.Parse(output);
\r
71 if (thisChapter != null)
\r
73 chapters.Add(thisChapter);
\r
80 return chapters.ToArray();
\r