From 979826e24b3f187c3b488da47b720234c93f293d Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 8 Jan 2009 20:11:26 +0000 Subject: WinGui: - Code cleanup. Remoes old using tags, removes unused code, cleans up some functions to make them shorter/more readable etc. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2069 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Parsing/Title.cs | 108 ++++++++++++++++++++---------------------------- 1 file changed, 44 insertions(+), 64 deletions(-) (limited to 'win/C#/Parsing/Title.cs') diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index 6f0f6ffc3..74ccab752 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -7,10 +7,9 @@ using System; using System.Collections.Generic; using System.Drawing; +using System.Globalization; using System.IO; -using System.Windows.Forms; using System.Text.RegularExpressions; -using System.Globalization; namespace Handbrake.Parsing { @@ -19,91 +18,82 @@ namespace Handbrake.Parsing /// public class Title { - private List m_chapters; + private static readonly CultureInfo Culture = new CultureInfo("en-US", false); + private readonly List m_audioTracks; + private readonly List m_chapters; + private readonly List m_subtitles; + private float m_aspectRatio; + private int[] m_autoCrop; + private TimeSpan m_duration; + private Size m_resolution; + private int m_titleNumber; + + /// + /// The constructor for this object + /// + public Title() + { + m_audioTracks = new List(); + m_chapters = new List(); + m_subtitles = new List(); + } + /// /// Collection of chapters in this Title /// public List Chapters { - get - { - return this.m_chapters; - } + get { return m_chapters; } } - private List m_audioTracks; /// /// Collection of audio tracks associated with this Title /// public List AudioTracks { - get - { - return this.m_audioTracks; - } + get { return m_audioTracks; } } - private List m_subtitles; /// /// Collection of subtitles associated with this Title /// public List Subtitles { - get - { - return this.m_subtitles; - } + get { return m_subtitles; } } - private int m_titleNumber; /// /// The track number of this Title /// public int TitleNumber { - get - { - return this.m_titleNumber; - } + get { return m_titleNumber; } } - private TimeSpan m_duration; /// /// The length in time of this Title /// public TimeSpan Duration { - get - { - return this.m_duration; - } + get { return m_duration; } } - private Size m_resolution; /// /// The resolution (width/height) of this Title /// public Size Resolution { - get - { - return this.m_resolution; - } + get { return m_resolution; } } - private float m_aspectRatio; /// /// The aspect ratio of this Title /// public float AspectRatio { - get - { - return this.m_aspectRatio; - } + get { return m_aspectRatio; } } - private int[] m_autoCrop; /// /// The automatically detected crop region for this Title. /// This is an int array with 4 items in it as so: @@ -114,20 +104,7 @@ namespace Handbrake.Parsing /// public int[] AutoCropDimensions { - get - { - return this.m_autoCrop; - } - } - - /// - /// The constructor for this object - /// - public Title() - { - this.m_audioTracks = new List(); - this.m_chapters = new List(); - this.m_subtitles = new List(); + get { return m_autoCrop; } } /// @@ -136,20 +113,18 @@ namespace Handbrake.Parsing /// A string representing this track in the format: {title #} (00:00:00) public override string ToString() { - return string.Format("{0} ({1:00}:{2:00}:{3:00})", this.m_titleNumber, this.m_duration.Hours, - this.m_duration.Minutes, this.m_duration.Seconds); + return string.Format("{0} ({1:00}:{2:00}:{3:00})", m_titleNumber, m_duration.Hours, + m_duration.Minutes, m_duration.Seconds); } - static readonly private CultureInfo Culture = new CultureInfo("en-US", false); - public static Title Parse(StringReader output) { - Title thisTitle = new Title(); + var thisTitle = new Title(); Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):"); // Match track number for this title if (m.Success) - thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString()); + thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim()); String testData = output.ReadLine(); @@ -160,7 +135,8 @@ namespace Handbrake.Parsing thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value); // Get resolution, aspect ratio and FPS for this title - m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); + m = Regex.Match(output.ReadLine(), + @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); if (m.Success) { thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); @@ -170,7 +146,11 @@ namespace Handbrake.Parsing // Get autocrop region for this title m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)"); if (m.Success) - thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) }; + thisTitle.m_autoCrop = new int[4] + { + int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), + int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) + }; thisTitle.m_chapters.AddRange(Chapter.ParseList(output)); @@ -183,8 +163,8 @@ namespace Handbrake.Parsing public static Title[] ParseList(string output) { - List titles = new List<Title>(); - StringReader sr = new StringReader(output); + var titles = new List<Title>(); + var sr = new StringReader(output); while (sr.Peek() == '+' || sr.Peek() == ' ') { @@ -192,10 +172,10 @@ namespace Handbrake.Parsing if (sr.Peek() == ' ') // If the character is a space, then chances are it's the combing detected line. sr.ReadLine(); // Skip over it else - titles.Add(Title.Parse(sr)); + titles.Add(Parse(sr)); } return titles.ToArray(); } } -} +} \ No newline at end of file -- cgit v1.2.3