Skip to content

Commit

Permalink
WinGui:
Browse files Browse the repository at this point in the history
- More stylecop warnings cleaned up

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3235 b64f7644-9d1e-0410-96f1-a4d463321fa5
  • Loading branch information
sr55 committed Apr 17, 2010
1 parent 39c2456 commit f282624
Show file tree
Hide file tree
Showing 27 changed files with 602 additions and 250 deletions.
6 changes: 3 additions & 3 deletions win/C#/Controls/AudioPanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions win/C#/Controls/Filters.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* Filters.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. */
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. */

namespace Handbrake.Controls
{
Expand Down
6 changes: 3 additions & 3 deletions win/C#/Controls/Subtitles.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* Subtitles.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. */
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. */

namespace Handbrake.Controls
{
Expand Down
142 changes: 94 additions & 48 deletions win/C#/Parsing/AudioTrack.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
/* AudioTrack.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. */
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. */

namespace Handbrake.Parsing
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
Expand All @@ -16,87 +14,114 @@ namespace Handbrake.Parsing
/// </summary>
public class AudioTrack
{
private int m_bitrate;
private string m_format;
private int m_frequency;
private string m_language;
private string m_subFormat;
private int m_trackNumber;
private string m_iso639_2;
/// <summary>
/// The Track bitrate
/// </summary>
private int bitrate;

/// <summary>
/// The track format
/// </summary>
private string format;

/// <summary>
/// The Frequency
/// </summary>
private int frequency;

/// <summary>
/// Track Language
/// </summary>
private string language;

/// <summary>
/// Sub Format
/// </summary>
private string subFormat;

/// <summary>
/// Track Number
/// </summary>
private int trackNumber;

/// <summary>
/// The ISO639_2 code
/// </summary>
private string iso639_2;

/// <summary>
/// The track number of this Audio Track
/// Gets The track number of this Audio Track
/// </summary>
public int TrackNumber
{
get { return m_trackNumber; }
get { return trackNumber; }
}

/// <summary>
/// The language (if detected) of this Audio Track
/// Gets The language (if detected) of this Audio Track
/// </summary>
public string Language
{
get { return m_language; }
get { return language; }
}

/// <summary>
/// The primary format of this Audio Track
/// Gets The primary format of this Audio Track
/// </summary>
public string Format
{
get { return m_format; }
get { return format; }
}

/// <summary>
/// Additional format info for this Audio Track
/// Gets Additional format info for this Audio Track
/// </summary>
public string SubFormat
{
get { return m_subFormat; }
get { return subFormat; }
}

/// <summary>
/// The frequency (in MHz) of this Audio Track
/// Gets The frequency (in MHz) of this Audio Track
/// </summary>
public int Frequency
{
get { return m_frequency; }
get { return frequency; }
}

/// <summary>
/// The bitrate (in kbps) of this Audio Track
/// Gets The bitrate (in kbps) of this Audio Track
/// </summary>
public int Bitrate
{
get { return m_bitrate; }
get { return bitrate; }
}

/// <summary>
/// Gets ISO639_2.
/// </summary>
public string ISO639_2
{
get { return m_iso639_2; }
get { return iso639_2; }
}

/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// Parse the CLI input to an Audio Track object
/// </summary>
/// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
public override string ToString()
{
if (m_subFormat == null)
return string.Format("{0} {1} ({2})", m_trackNumber, m_language, m_format);

return string.Format("{0} {1} ({2}) ({3})", m_trackNumber, m_language, m_format, m_subFormat);
}

/// <param name="output">
/// The output.
/// </param>
/// <returns>
/// An Audio Track obkect
/// </returns>
public static AudioTrack Parse(StringReader output)
{
string audio_track = output.ReadLine();
Match m = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\)");
Match track = Regex.Match(audio_track, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); // ID and Language
Match iso639_2 = Regex.Match(audio_track, @"iso639-2: ([a-zA-Z]*)\)");
Match samplerate = Regex.Match(audio_track, @"([0-9]*)Hz");
Match bitrate = Regex.Match(audio_track, @"([0-9]*)bps");
string audioTrack = output.ReadLine();
Match m = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\) \((.*)\)");
Match track = Regex.Match(audioTrack, @"^ \+ ([0-9]*), ([A-Za-z0-9]*) \((.*)\)"); // ID and Language
Match iso639_2 = Regex.Match(audioTrack, @"iso639-2: ([a-zA-Z]*)\)");
Match samplerate = Regex.Match(audioTrack, @"([0-9]*)Hz");
Match bitrate = Regex.Match(audioTrack, @"([0-9]*)bps");

string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value;
string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", string.Empty).Trim() : "0";
Expand All @@ -106,13 +131,13 @@ public static AudioTrack Parse(StringReader output)
{
var thisTrack = new AudioTrack
{
m_trackNumber = int.Parse(track.Groups[1].Value.Trim()),
m_language = track.Groups[2].Value,
m_format = m.Groups[3].Value,
m_subFormat = subformat,
m_frequency = int.Parse(samplerateVal),
m_bitrate = int.Parse(bitrateVal),
m_iso639_2 =
trackNumber = int.Parse(track.Groups[1].Value.Trim()),
language = track.Groups[2].Value,
format = m.Groups[3].Value,
subFormat = subformat,
frequency = int.Parse(samplerateVal),
bitrate = int.Parse(bitrateVal),
iso639_2 =
iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty)
};
return thisTrack;
Expand All @@ -121,6 +146,15 @@ public static AudioTrack Parse(StringReader output)
return null;
}

/// <summary>
/// Pase a list of audio tracks
/// </summary>
/// <param name="output">
/// The output.
/// </param>
/// <returns>
/// An array of audio tracks
/// </returns>
public static AudioTrack[] ParseList(StringReader output)
{
var tracks = new List<AudioTrack>();
Expand All @@ -134,5 +168,17 @@ public static AudioTrack[] ParseList(StringReader output)
}
return tracks.ToArray();
}

/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
/// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
public override string ToString()
{
if (subFormat == null)
return string.Format("{0} {1} ({2})", trackNumber, language, format);

return string.Format("{0} {1} ({2}) ({3})", trackNumber, language, format, subFormat);
}
}
}
64 changes: 44 additions & 20 deletions win/C#/Parsing/Chapter.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* Chapter.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. */
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. */

namespace Handbrake.Parsing
{
Expand All @@ -16,51 +15,67 @@ namespace Handbrake.Parsing
/// </summary>
public class Chapter
{
private int m_chapterNumber;
/// <summary>
/// Chapter Number
/// </summary>
private int chapterNumber;

private TimeSpan m_duration;
/// <summary>
/// The Duration of the chapter
/// </summary>
private TimeSpan duration;

/// <summary>
/// The number of this Chapter, in regards to it's parent Title
/// Gets The number of this Chapter, in regards to it's parent Title
/// </summary>
public int ChapterNumber
{
get { return m_chapterNumber; }
get { return chapterNumber; }
}

/// <summary>
/// The length in time this Chapter spans
/// Gets The length in time this Chapter spans
/// </summary>
public TimeSpan Duration
{
get { return m_duration; }
get { return duration; }
}

/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// Parse a CLI string to a Chapter object
/// </summary>
/// <returns>A string formatted as: {chapter #}</returns>
public override string ToString()
{
return m_chapterNumber.ToString();
}

/// <param name="output">
/// The output.
/// </param>
/// <returns>
/// A chapter Object
/// </returns>
public static Chapter Parse(StringReader output)
{
Match m = Regex.Match(output.ReadLine(),
Match m = Regex.Match(
output.ReadLine(),
@"^ \+ ([0-9]*): cells ([0-9]*)->([0-9]*), ([0-9]*) blocks, duration ([0-9]{2}:[0-9]{2}:[0-9]{2})");
if (m.Success)
{
var thisChapter = new Chapter
{
m_chapterNumber = int.Parse(m.Groups[1].Value.Trim()),
m_duration = TimeSpan.Parse(m.Groups[5].Value)
chapterNumber = int.Parse(m.Groups[1].Value.Trim()),
duration = TimeSpan.Parse(m.Groups[5].Value)
};
return thisChapter;
}
return null;
}

/// <summary>
/// Prase a list of strings / chatpers
/// </summary>
/// <param name="output">
/// The output.
/// </param>
/// <returns>
/// An array of chapter objects
/// </returns>
public static Chapter[] ParseList(StringReader output)
{
var chapters = new List<Chapter>();
Expand All @@ -81,5 +96,14 @@ public static Chapter[] ParseList(StringReader output)
}
return chapters.ToArray();
}

/// <summary>
/// Override of the ToString method to make this object easier to use in the UI
/// </summary>
/// <returns>A string formatted as: {chapter #}</returns>
public override string ToString()
{
return chapterNumber.ToString();
}
}
}
Loading

0 comments on commit f282624

Please sign in to comment.