summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/C#/Controls/PictureSettings.cs16
-rw-r--r--win/C#/HandBrakeCS.csproj6
-rw-r--r--win/C#/Model/Cropping.cs56
-rw-r--r--win/C#/Model/SubtitleType.cs18
-rw-r--r--win/C#/Parsing/AudioTrack.cs73
-rw-r--r--win/C#/Parsing/Chapter.cs17
-rw-r--r--win/C#/Parsing/Subtitle.cs42
-rw-r--r--win/C#/Parsing/Title.cs127
-rw-r--r--win/C#/Settings.StyleCop32
-rw-r--r--win/C#/frmMain.cs5
10 files changed, 325 insertions, 67 deletions
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs
index b9a0bf040..333bec3b0 100644
--- a/win/C#/Controls/PictureSettings.cs
+++ b/win/C#/Controls/PictureSettings.cs
@@ -97,10 +97,10 @@ namespace Handbrake.Controls
// Set the Recommended Cropping values, but only if a preset doesn't have hard set picture settings.
if ((CurrentlySelectedPreset != null && CurrentlySelectedPreset.PictureSettings == false) || CurrentlySelectedPreset == null)
{
- crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[0]);
- crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[1]);
- crop_left.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[2]);
- crop_right.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions[3]);
+ crop_top.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Top);
+ crop_bottom.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Bottom);
+ crop_left.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Left);
+ crop_right.Value = GetCropMod2Clean(sourceTitle.AutoCropDimensions.Right);
}
SetPresetCropWarningLabel(CurrentlySelectedPreset);
@@ -424,10 +424,10 @@ namespace Handbrake.Controls
if (Source != null)
{
- crop_top.Value = Source.AutoCropDimensions[0];
- crop_bottom.Value = Source.AutoCropDimensions[1];
- crop_left.Value = Source.AutoCropDimensions[2];
- crop_right.Value = Source.AutoCropDimensions[3];
+ crop_top.Value = Source.AutoCropDimensions.Top;
+ crop_bottom.Value = Source.AutoCropDimensions.Bottom;
+ crop_left.Value = Source.AutoCropDimensions.Left;
+ crop_right.Value = Source.AutoCropDimensions.Right;
}
}
diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj
index 98c9d23f9..6ba8d140c 100644
--- a/win/C#/HandBrakeCS.csproj
+++ b/win/C#/HandBrakeCS.csproj
@@ -154,6 +154,10 @@
<HintPath>libraries\Growl.CoreLibrary.dll</HintPath>
<Private>True</Private>
</Reference>
+ <Reference Include="HandBrakeInterop, Version=1.3.0.0, Culture=neutral, processorArchitecture=x86">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>libraries\HandBrakeInterop.dll</HintPath>
+ </Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
@@ -217,6 +221,8 @@
<DependentUpon>frmExceptionWindow.cs</DependentUpon>
</Compile>
<Compile Include="Model\ActivityLogMode.cs" />
+ <Compile Include="Model\Cropping.cs" />
+ <Compile Include="Model\SubtitleType.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\Encode.cs" />
<Compile Include="frmPreview.cs">
diff --git a/win/C#/Model/Cropping.cs b/win/C#/Model/Cropping.cs
new file mode 100644
index 000000000..63a84afb1
--- /dev/null
+++ b/win/C#/Model/Cropping.cs
@@ -0,0 +1,56 @@
+/* Cropping.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. */
+
+namespace Handbrake.Model
+{
+ /// <summary>
+ /// Cropping T B L R
+ /// </summary>
+ public class Cropping
+ {
+ /// <summary>
+ /// Gets or sets Top.
+ /// </summary>
+ public int Top { get; set; }
+
+ /// <summary>
+ /// Gets or sets Bottom.
+ /// </summary>
+ public int Bottom { get; set; }
+
+ /// <summary>
+ /// Gets or sets Left.
+ /// </summary>
+ public int Left { get; set; }
+
+ /// <summary>
+ /// Gets or sets Right.
+ /// </summary>
+ public int Right { get; set; }
+
+ /// <summary>
+ /// Create a cropping object
+ /// </summary>
+ /// <param name="top">
+ /// The top.
+ /// </param>
+ /// <param name="bottom">
+ /// The bottom.
+ /// </param>
+ /// <param name="left">
+ /// The left.
+ /// </param>
+ /// <param name="right">
+ /// The right.
+ /// </param>
+ /// <returns>
+ /// A Cropping object
+ /// </returns>
+ public static Cropping CreateCroppingObject(int top, int bottom, int left, int right)
+ {
+ return new Cropping { Top = top, Bottom = bottom, Left = left, Right = right };
+ }
+ }
+}
diff --git a/win/C#/Model/SubtitleType.cs b/win/C#/Model/SubtitleType.cs
new file mode 100644
index 000000000..a9c8609f3
--- /dev/null
+++ b/win/C#/Model/SubtitleType.cs
@@ -0,0 +1,18 @@
+/* SubtitleType.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. */
+
+namespace Handbrake.Model
+{
+ /// <summary>
+ /// Subtitle Type.
+ /// 0: Picture
+ /// 1: Text
+ /// </summary>
+ public enum SubtitleType
+ {
+ Picture,
+ Text
+ }
+}
diff --git a/win/C#/Parsing/AudioTrack.cs b/win/C#/Parsing/AudioTrack.cs
index 489f360d2..fb00bcf47 100644
--- a/win/C#/Parsing/AudioTrack.cs
+++ b/win/C#/Parsing/AudioTrack.cs
@@ -25,19 +25,24 @@ namespace Handbrake.Parsing
public string Language { get; private set; }
/// <summary>
- /// Gets The primary format of this Audio Track
+ /// Gets or sets LanguageCode.
/// </summary>
- public string Format { get; private set; }
+ public string LanguageCode { get; set; }
+
+ /// <summary>
+ /// Gets or sets Description.
+ /// </summary>
+ public string Description { get; set; }
/// <summary>
- /// Gets Additional format info for this Audio Track
+ /// Gets The primary format of this Audio Track
/// </summary>
- public string SubFormat { get; private set; }
+ public string Format { get; private set; }
/// <summary>
/// Gets The frequency (in MHz) of this Audio Track
/// </summary>
- public int Frequency { get; private set; }
+ public int SampleRate { get; private set; }
/// <summary>
/// Gets The bitrate (in kbps) of this Audio Track
@@ -45,9 +50,48 @@ namespace Handbrake.Parsing
public int Bitrate { get; private set; }
/// <summary>
- /// Gets ISO639_2.
+ /// Create a new Audio Track object
/// </summary>
- public string ISO639_2 { get; private set; }
+ /// <param name="track">
+ /// The track.
+ /// </param>
+ /// <param name="lang">
+ /// The lang.
+ /// </param>
+ /// <param name="langCode">
+ /// The lang code.
+ /// </param>
+ /// <param name="desc">
+ /// The desc.
+ /// </param>
+ /// <param name="format">
+ /// The format.
+ /// </param>
+ /// <param name="samplerate">
+ /// The samplerate.
+ /// </param>
+ /// <param name="bitrate">
+ /// The bitrate.
+ /// </param>
+ /// <returns>
+ /// A new Audio Track
+ /// </returns>
+ public static AudioTrack CreateAudioTrack(int track, string lang, string langCode, string desc, string format, int samplerate, int bitrate)
+ {
+ AudioTrack newTrack = new AudioTrack
+ {
+ TrackNumber = track,
+ Language = lang,
+ LanguageCode = langCode,
+ Description = desc,
+ Format = format,
+ SampleRate = samplerate,
+ Bitrate = bitrate
+ };
+
+ return newTrack;
+
+ }
/// <summary>
/// Parse the CLI input to an Audio Track object
@@ -77,12 +121,11 @@ namespace Handbrake.Parsing
{
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)
+ Format = m.Groups[3].Value,
+ Description = subformat,
+ SampleRate = int.Parse(samplerateVal),
+ Bitrate = int.Parse(bitrateVal),
+ LanguageCode = iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty)
};
return thisTrack;
}
@@ -119,10 +162,10 @@ namespace Handbrake.Parsing
/// <returns>A string formatted as: {track #} {language} ({format}) ({sub-format})</returns>
public override string ToString()
{
- if (SubFormat == null)
+ if (Description == null)
return string.Format("{0} {1} ({2})", TrackNumber, Language, Format);
- return string.Format("{0} {1} ({2}) ({3})", TrackNumber, Language, Format, SubFormat);
+ return string.Format("{0} {1} ({2}) ({3})", TrackNumber, Language, Format, Description);
}
}
} \ No newline at end of file
diff --git a/win/C#/Parsing/Chapter.cs b/win/C#/Parsing/Chapter.cs
index 4b3bb2d00..ca8fc3023 100644
--- a/win/C#/Parsing/Chapter.cs
+++ b/win/C#/Parsing/Chapter.cs
@@ -26,6 +26,23 @@ namespace Handbrake.Parsing
public TimeSpan Duration { get; private set; }
/// <summary>
+ /// Create a chapter Object
+ /// </summary>
+ /// <param name="number">
+ /// The number.
+ /// </param>
+ /// <param name="duration">
+ /// The duration.
+ /// </param>
+ /// <returns>
+ /// A new Chapter Object
+ /// </returns>
+ public static Chapter CreateChapterOjbect(int number, TimeSpan duration)
+ {
+ return new Chapter { ChapterNumber = number, Duration = duration };
+ }
+
+ /// <summary>
/// Parse a CLI string to a Chapter object
/// </summary>
/// <param name="output">
diff --git a/win/C#/Parsing/Subtitle.cs b/win/C#/Parsing/Subtitle.cs
index 52a0729db..fd0cdc552 100644
--- a/win/C#/Parsing/Subtitle.cs
+++ b/win/C#/Parsing/Subtitle.cs
@@ -9,6 +9,8 @@ namespace Handbrake.Parsing
using System.IO;
using System.Text.RegularExpressions;
+ using Handbrake.Model;
+
/// <summary>
/// An object that represents a subtitle associated with a Title, in a DVD
/// </summary>
@@ -32,7 +34,41 @@ namespace Handbrake.Parsing
/// <summary>
/// Gets the Subtitle Type
/// </summary>
- public string Type { get; private set; }
+ public SubtitleType SubtitleType { get; private set; }
+
+ /// <summary>
+ /// Gets Subtitle Type
+ /// </summary>
+ public string TypeString
+ {
+ get
+ {
+ return this.SubtitleType == SubtitleType.Picture ? "Bitmap" : "Text";
+ }
+ }
+
+ /// <summary>
+ /// Create a new Subtitle Object
+ /// </summary>
+ /// <param name="track">
+ /// The track.
+ /// </param>
+ /// <param name="lang">
+ /// The lang.
+ /// </param>
+ /// <param name="langCode">
+ /// The lang code.
+ /// </param>
+ /// <param name="type">
+ /// The type.
+ /// </param>
+ /// <returns>
+ /// A Subtitle Object
+ /// </returns>
+ public static Subtitle CreateSubtitleObject(int track, string lang, string langCode, SubtitleType type)
+ {
+ return new Subtitle { TrackNumber = track, Language = lang, LanguageCode = langCode, SubtitleType = type };
+ }
/// <summary>
/// Parse the input strings related to subtitles
@@ -55,7 +91,7 @@ namespace Handbrake.Parsing
TrackNumber = int.Parse(m.Groups[1].Value.Trim()),
Language = m.Groups[2].Value,
LanguageCode = m.Groups[3].Value,
- Type = m.Groups[4].Value
+ SubtitleType = m.Groups[4].Value.Contains("Text") ? SubtitleType.Text : SubtitleType.Picture
};
return thisSubtitle;
}
@@ -92,7 +128,7 @@ namespace Handbrake.Parsing
/// <returns>A string formatted as: {track #} {language}</returns>
public override string ToString()
{
- return string.Format("{0} {1} ({2})", TrackNumber, Language, Type);
+ return string.Format("{0} {1} ({2})", TrackNumber, Language, TypeString);
}
}
} \ No newline at end of file
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs
index ab3a27423..3a3e6ca06 100644
--- a/win/C#/Parsing/Title.cs
+++ b/win/C#/Parsing/Title.cs
@@ -12,6 +12,8 @@ namespace Handbrake.Parsing
using System.IO;
using System.Text.RegularExpressions;
+ using Handbrake.Model;
+
/// <summary>
/// An object that represents a single Title of a DVD
/// </summary>
@@ -24,16 +26,16 @@ namespace Handbrake.Parsing
/// <summary>
/// Initializes a new instance of the <see cref="Title"/> class.
- /// The constructor for this object
/// </summary>
public Title()
{
- Angles = new List<string>();
AudioTracks = new List<AudioTrack>();
Chapters = new List<Chapter>();
Subtitles = new List<Subtitle>();
}
+ #region Properties
+
/// <summary>
/// Gets a Collection of chapters in this Title
/// </summary>
@@ -55,16 +57,6 @@ namespace Handbrake.Parsing
public int TitleNumber { get; private set; }
/// <summary>
- /// Gets a value indicating whether this is a MainTitle.
- /// </summary>
- public bool MainTitle { get; private set; }
-
- /// <summary>
- /// Gets the Source Name
- /// </summary>
- public string SourceName { get; private set; }
-
- /// <summary>
/// Gets the length in time of this Title
/// </summary>
public TimeSpan Duration { get; private set; }
@@ -77,7 +69,12 @@ namespace Handbrake.Parsing
/// <summary>
/// Gets the aspect ratio of this Title
/// </summary>
- public float AspectRatio { get; private set; }
+ public double AspectRatio { get; private set; }
+
+ /// <summary>
+ /// Gets AngleCount.
+ /// </summary>
+ public int AngleCount { get; private set; }
/// <summary>
/// Gets Par Value
@@ -92,17 +89,93 @@ namespace Handbrake.Parsing
/// 2: L
/// 3: R
/// </summary>
- public int[] AutoCropDimensions { get; private set; }
+ public Cropping AutoCropDimensions { get; private set; }
/// <summary>
- /// Gets a Collection of Angles in this Title
+ /// Gets the FPS of the source.
/// </summary>
- public List<string> Angles { get; private set; }
+ public double Fps { get; private set; }
/// <summary>
- /// Gets the FPS of the source.
+ /// Gets a value indicating whether this is a MainTitle.
/// </summary>
- public float Fps { get; private set; }
+ public bool MainTitle { get; private set; }
+
+ /// <summary>
+ /// Gets the Source Name
+ /// </summary>
+ public string SourceName { get; private set; }
+
+ #endregion
+
+ /// <summary>
+ /// Creates a Title
+ /// </summary>
+ /// <param name="angles">
+ /// The angles.
+ /// </param>
+ /// <param name="aspectRatio">
+ /// The aspect Ratio.
+ /// </param>
+ /// <param name="audioTracks">
+ /// The audio Tracks.
+ /// </param>
+ /// <param name="crop">
+ /// The crop.
+ /// </param>
+ /// <param name="chapters">
+ /// The chapters.
+ /// </param>
+ /// <param name="duration">
+ /// The duration.
+ /// </param>
+ /// <param name="fps">
+ /// The fps.
+ /// </param>
+ /// <param name="mainTitle">
+ /// The main Title.
+ /// </param>
+ /// <param name="parVal">
+ /// The par Val.
+ /// </param>
+ /// <param name="resolution">
+ /// The resolution.
+ /// </param>
+ /// <param name="sourceName">
+ /// The source Name.
+ /// </param>
+ /// <param name="subtitles">
+ /// The subtitles.
+ /// </param>
+ /// <param name="titleNumber">
+ /// The title Number.
+ /// </param>
+ /// <returns>
+ /// A Title Object
+ /// </returns>
+ public static Title CreateTitle(int angles, double aspectRatio, List<AudioTrack> audioTracks, Cropping crop, List<Chapter> chapters,
+ TimeSpan duration, float fps, bool mainTitle, Size parVal, Size resolution, string sourceName, List<Subtitle> subtitles,
+ int titleNumber)
+ {
+ Title title = new Title
+ {
+ AngleCount = angles,
+ AspectRatio = aspectRatio,
+ AudioTracks = audioTracks,
+ AutoCropDimensions = crop,
+ Chapters = chapters,
+ Duration = duration,
+ Fps = fps,
+ MainTitle = mainTitle,
+ ParVal = parVal,
+ Resolution = resolution,
+ SourceName = sourceName,
+ Subtitles = subtitles,
+ TitleNumber = titleNumber
+ };
+
+ return title;
+ }
/// <summary>
/// Parse the Title Information
@@ -142,8 +215,7 @@ namespace Handbrake.Parsing
int angleCount;
int.TryParse(angleList, out angleCount);
- for (int i = 1; i <= angleCount; i++)
- thisTitle.Angles.Add(i.ToString());
+ thisTitle.AngleCount = angleCount;
}
}
@@ -165,11 +237,15 @@ 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.AutoCropDimensions = new[]
- {
- 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.AutoCropDimensions = new Cropping
+ {
+ Top = int.Parse(m.Groups[1].Value),
+ Bottom = int.Parse(m.Groups[2].Value),
+ Left = int.Parse(m.Groups[3].Value),
+ Right = int.Parse(m.Groups[4].Value)
+ };
+ }
thisTitle.Chapters.AddRange(Chapter.ParseList(output));
@@ -210,5 +286,6 @@ namespace Handbrake.Parsing
{
return string.Format("{0} ({1:00}:{2:00}:{3:00})", TitleNumber, Duration.Hours, Duration.Minutes, Duration.Seconds);
}
+
}
} \ No newline at end of file
diff --git a/win/C#/Settings.StyleCop b/win/C#/Settings.StyleCop
index 8d623254e..139f00afe 100644
--- a/win/C#/Settings.StyleCop
+++ b/win/C#/Settings.StyleCop
@@ -1,7 +1,4 @@
<StyleCopSettings Version="4.3">
- <GlobalSettings>
- <StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
- </GlobalSettings>
<Parsers>
<Parser ParserId="Microsoft.StyleCop.CSharp.CsParser">
<ParserSettings>
@@ -12,55 +9,60 @@
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
<Rules>
- <Rule Name="FileHeaderMustShowCopyright">
+ <Rule Name="PropertyDocumentationMustHaveValueText">
+ <RuleSettings>
+ <BooleanProperty Name="Enabled">True</BooleanProperty>
+ </RuleSettings>
+ </Rule>
+ <Rule Name="DocumentationTextMustMeetMinimumCharacterLength">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileHeaderMustHaveCopyrightText">
+ <Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileHeaderMustContainFileName">
+ <Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
+ <Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileHeaderMustHaveValidCompanyText">
+ <Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="FileMustHaveHeader">
+ <Rule Name="FileHeaderMustHaveCopyrightText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="PropertyDocumentationMustHaveValueText">
+ <Rule Name="FileHeaderMustContainFileName">
<RuleSettings>
- <BooleanProperty Name="Enabled">True</BooleanProperty>
+ <BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="DocumentationTextMustMeetMinimumCharacterLength">
+ <Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
- <Rule Name="DocumentationTextMustContainWhitespace">
+ <Rule Name="FileHeaderMustHaveValidCompanyText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings>
- <StringProperty Name="CompanyName">HandBrake Project</StringProperty>
- <StringProperty Name="Copyright">Copyright 2010 HandBrake Team - It may be used under the terms of the GNU General Public License.</StringProperty>
+ <StringProperty Name="CompanyName">HandBrake Project (http://handbrake.fr)</StringProperty>
+ <StringProperty Name="Copyright">This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.</StringProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules">
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 1a1cfae47..91e39706f 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -1377,7 +1377,10 @@ namespace Handbrake
{
drop_angle.Visible = true;
lbl_angle.Visible = true;
- drop_angle.Items.AddRange(selectedTitle.Angles.ToArray());
+
+ for (int i = 1; i <= selectedTitle.AngleCount; i++)
+ drop_angle.Items.Add(i.ToString());
+
if (drop_angle.Items.Count != 0)
drop_angle.SelectedIndex = 0;
}