From dab8b3b4cfbe05f84bb89fb76252c68c41d3a06f Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 22 Jan 2012 20:45:08 +0000 Subject: WinGui: (WPF) Further work on the Audio and Subtitle tabs along with the API & Utilities. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4418 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Functions/EnumHelper.cs | 12 + .../HandBrake.ApplicationServices.csproj | 1 + .../Model/Encoding/AudioTrack.cs | 250 ++++++++++++++------- .../Model/Encoding/SubtitleTrack.cs | 105 ++++++--- .../Utilities/CharCodesUtilities.cs | 59 +++++ .../Utilities/LanguageUtilities.cs | 7 +- 6 files changed, 325 insertions(+), 109 deletions(-) create mode 100644 win/CS/HandBrake.ApplicationServices/Utilities/CharCodesUtilities.cs (limited to 'win/CS/HandBrake.ApplicationServices') diff --git a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs index 8147f527f..0308069f9 100644 --- a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs @@ -10,6 +10,7 @@ namespace HandBrake.ApplicationServices.Functions using System.Collections.ObjectModel; using System.ComponentModel; using System.ComponentModel.DataAnnotations; + using System.Linq; using System.Reflection; /// @@ -71,6 +72,17 @@ namespace HandBrake.ApplicationServices.Functions throw new ArgumentOutOfRangeException("The Description for the enum was not recognized."); } + /// + /// Return a list of all the enum values. + /// + /// + /// An Enum Oject List + /// + public static IEnumerable GetEnumList() + { + return Enum.GetValues(typeof(T)).Cast().ToList(); + } + /// /// Get a list of string names for each enum value. /// diff --git a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj index 2cb6ab738..ff6f8cd4b 100644 --- a/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj +++ b/win/CS/HandBrake.ApplicationServices/HandBrake.ApplicationServices.csproj @@ -150,6 +150,7 @@ + diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs index 9a92eab80..3ef786629 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/AudioTrack.cs @@ -1,7 +1,11 @@ -/* AudioTrack.cs $ - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// An Audio Track for the Audio Panel +// +// -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.ApplicationServices.Model.Encoding { @@ -17,27 +21,56 @@ namespace HandBrake.ApplicationServices.Model.Encoding /// public class AudioTrack : ModelBase { - #region Private Variables + #region Constants and Fields + /// - /// The gain value + /// The bitrate. /// - private int gain; + private int bitrate; /// - /// The DRC Value + /// The DRC Value /// private double drc; /// - /// The Scanned Audio Track + /// The encoder. + /// + private AudioEncoder encoder; + + /// + /// The gain value + /// + private int gain; + + /// + /// The mix down. + /// + private Mixdown mixDown; + + /// + /// The sample rate. + /// + private double sampleRate; + + /// + /// The Scanned Audio Track /// [NonSerialized] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] private Audio scannedTrack; + + /// + /// The track name. + /// + private string trackName; + #endregion + #region Constructors and Destructors + /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// public AudioTrack() { @@ -50,166 +83,231 @@ namespace HandBrake.ApplicationServices.Model.Encoding this.ScannedTrack = new Audio(); } + #endregion + + #region Public Properties + /// - /// Gets the Audio Track Name + /// Gets AudioEncoderDisplayValue. /// - public int? Track + public string AudioEncoderDisplayValue { get { - if (this.ScannedTrack != null) + return EnumHelper.GetDisplay(this.Encoder); + } + } + + /// + /// Gets AudioMixdownDisplayValue. + /// + public string AudioMixdownDisplayValue + { + get + { + return EnumHelper.GetDisplay(this.MixDown); + } + } + + /// + /// Gets the The UI display value for bit rate + /// + public string BitRateDisplayValue + { + get + { + if (this.Encoder == AudioEncoder.Ac3Passthrough || this.Encoder == AudioEncoder.DtsPassthrough + || this.Encoder == AudioEncoder.DtsHDPassthrough) { - return this.ScannedTrack.TrackNumber; + return "Auto"; } - return null; + return this.Bitrate.ToString(); } } /// - /// Gets or sets the Scanned Audio Tracks + /// Gets or sets Audio Bitrate /// - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public Audio ScannedTrack + public int Bitrate { get { - return this.scannedTrack; + return this.bitrate; } set { - this.scannedTrack = value; - this.OnPropertyChanged("ScannedTrack"); - this.OnPropertyChanged("TrackDisplay"); + this.bitrate = value; + this.OnPropertyChanged("Bitrate"); } } /// - /// Gets the Display Value for this model. + /// Gets or sets Dynamic Range Compression /// - public string TrackDisplay + public double DRC { get { - return this.ScannedTrack == null ? string.Empty : this.ScannedTrack.ToString(); + return this.drc; + } + + set + { + if (!object.Equals(value, this.drc)) + { + this.drc = value; + this.OnPropertyChanged("DRC"); + } } } /// - /// Gets the The UI display value for sample rate + /// Gets or sets Audio Encoder /// - public string SampleRateDisplayValue + public AudioEncoder Encoder { get { - return this.SampleRate == 0 ? "Auto" : this.SampleRate.ToString(); + return this.encoder; + } + + set + { + this.encoder = value; + this.OnPropertyChanged("Encoder"); } } /// - /// Gets the The UI display value for bit rate + /// Gets or sets the Gain for the audio track /// - public string BitRateDisplayValue + public int Gain { get { - if (this.Encoder == AudioEncoder.Ac3Passthrough || this.Encoder == AudioEncoder.DtsPassthrough || - this.Encoder == AudioEncoder.DtsHDPassthrough) + return this.gain; + } + + set + { + if (!object.Equals(value, this.gain)) { - return "Auto"; + this.gain = value; + this.OnPropertyChanged("Gain"); } - - return this.Bitrate.ToString(); } } /// - /// Gets AudioEncoderDisplayValue. + /// Gets or sets Audio Mixdown /// - public string AudioEncoderDisplayValue + public Mixdown MixDown { get { - return EnumHelper.GetDisplay(this.Encoder); + return this.mixDown; + } + + set + { + this.mixDown = value; + this.OnPropertyChanged("MixDown"); } } /// - /// Gets AudioMixdownDisplayValue. + /// Gets or sets Audio SampleRate /// - public string AudioMixdownDisplayValue + public double SampleRate { get { - return EnumHelper.GetDisplay(this.MixDown); + return this.sampleRate; } - } + set + { + this.sampleRate = value; + this.OnPropertyChanged("SampleRate"); + } + } /// - /// Gets or sets Audio Mixdown + /// Gets the The UI display value for sample rate /// - public Mixdown MixDown { get; set; } + public string SampleRateDisplayValue + { + get + { + return this.SampleRate == 0 ? "Auto" : this.SampleRate.ToString(); + } + } /// - /// Gets or sets Audio Encoder + /// Gets or sets the Scanned Audio Tracks /// - public AudioEncoder Encoder { get; set; } + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public Audio ScannedTrack + { + get + { + return this.scannedTrack; + } - /// - /// Gets or sets Audio Bitrate - /// - public int Bitrate { get; set; } + set + { + this.scannedTrack = value; + this.OnPropertyChanged("ScannedTrack"); + this.OnPropertyChanged("TrackDisplay"); + } + } /// - /// Gets or sets Audio SampleRate + /// Gets the Audio Track Name /// - public double SampleRate { get; set; } + public int? Track + { + get + { + if (this.ScannedTrack != null) + { + return this.ScannedTrack.TrackNumber; + } - /// - /// Gets or sets TrackName. - /// - public string TrackName { get; set; } + return null; + } + } /// - /// Gets or sets Dynamic Range Compression + /// Gets the Display Value for this model. /// - public double DRC + public string TrackDisplay { get { - return this.drc; - } - - set - { - if (!object.Equals(value, this.drc)) - { - this.drc = value; - this.OnPropertyChanged("DRC"); - } + return this.ScannedTrack == null ? string.Empty : this.ScannedTrack.ToString(); } } /// - /// Gets or sets the Gain for the audio track + /// Gets or sets TrackName. /// - public int Gain + public string TrackName { get { - return this.gain; + return this.trackName; } set { - if (!object.Equals(value, this.gain)) - { - this.gain = value; - this.OnPropertyChanged("Gain"); - } + this.trackName = value; + this.OnPropertyChanged("TrackName"); } } + + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs b/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs index f69abed7d..fa7dfd10e 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/Encoding/SubtitleTrack.cs @@ -1,82 +1,123 @@ -/* SubtitleTrack.cs $ - This file is part of the HandBrake source code. - Homepage: . - It may be used under the terms of the GNU General Public License. */ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Subtitle Information +// +// -------------------------------------------------------------------------------------------------------------------- namespace HandBrake.ApplicationServices.Model.Encoding { + using System; using System.Windows.Forms; + using HandBrake.ApplicationServices.Parsing; + /// /// Subtitle Information /// - public class SubtitleTrack + public class SubtitleTrack : ModelBase { - /// - /// Gets or sets Track. - /// - public string Track { get; set; } + #region Constants and Fields /// - /// Gets or sets a value indicating whether Forced. + /// The source track. /// - public bool Forced { get; set; } + private Subtitle sourceTrack; + + #endregion + + #region Public Properties /// - /// Gets or sets a value indicating whether Burned. + /// Gets or sets a value indicating whether Burned. /// public bool Burned { get; set; } /// - /// Gets or sets a value indicating whether Default. + /// Gets or sets a value indicating whether Default. /// public bool Default { get; set; } - #region SRT Specific Options + /// + /// Gets or sets a value indicating whether Forced. + /// + public bool Forced { get; set; } /// - /// Gets or sets the SRT Language + /// Gets a value indicating whether this is an SRT subtitle. /// - public string SrtLang { get; set; } + public bool IsSrtSubtitle + { + get + { + return this.SrtFileName != "-"; + } + } /// - /// Gets or sets the SRT Character Code + /// Gets or sets Track. /// - public string SrtCharCode { get; set; } + [Obsolete("Use SourceTrack Instead")] + public string Track { get; set; } + /// - /// Gets or sets the SRT Offset + /// Gets or sets SourceTrack. /// - public int SrtOffset { get; set; } + public Subtitle SourceTrack + { + get + { + return this.sourceTrack; + } + + set + { + this.sourceTrack = value; + this.OnPropertyChanged("SourceTrack"); + if (this.sourceTrack != null) + { + this.Track = this.sourceTrack.ToString(); + } + } + } /// - /// Gets or sets the Path to the SRT file + /// Gets or sets the SRT Character Code /// - public string SrtPath { get; set; } + public string SrtCharCode { get; set; } /// - /// Gets or sets the SRT Filename + /// Gets or sets the SRT Filename /// public string SrtFileName { get; set; } /// - /// Gets a value indicating whether this is an SRT subtitle. + /// Gets or sets the SRT Language /// - public bool IsSrtSubtitle - { - get { return this.SrtFileName != "-"; } - } + public string SrtLang { get; set; } - #endregion + /// + /// Gets or sets the SRT Offset + /// + public int SrtOffset { get; set; } /// - /// Gets or sets the type of the subtitle + /// Gets or sets the Path to the SRT file + /// + public string SrtPath { get; set; } + + /// + /// Gets or sets the type of the subtitle /// public SubtitleType SubtitleType { get; set; } /// - /// Gets A ListViewItem Containing information about this subitlte + /// Gets A ListViewItem Containing information about this subitlte /// + [Obsolete("Used only for the old forms gui. Will be removed.")] public ListViewItem ListView { get @@ -91,5 +132,7 @@ namespace HandBrake.ApplicationServices.Model.Encoding return listTrack; } } + + #endregion } } \ No newline at end of file diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/CharCodesUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/CharCodesUtilities.cs new file mode 100644 index 000000000..9c9801015 --- /dev/null +++ b/win/CS/HandBrake.ApplicationServices/Utilities/CharCodesUtilities.cs @@ -0,0 +1,59 @@ +/* AppcastReader.cs $ + This file is part of the HandBrake source code. + Homepage: . + It may be used under the terms of the GNU General Public License. */ + +namespace HandBrake.ApplicationServices.Utilities +{ + using System.Collections.Generic; + + /// + /// Char Codes + /// + public class CharCodesUtilities + { + /// + /// Get a command subset of character codes. + /// + /// + /// A String List of Character codes. + /// + public static List GetCharacterCodes() + { + return new List + { + "ANSI_X3.4-1968", + "ANSI_X3.4-1986", + "ANSI_X3.4", + "ANSI_X3.110-1983", + "ANSI_X3.110", + "ASCII", + "ECMA-114", + "ECMA-118", + "ECMA-128", + "ECMA-CYRILLIC", + "IEC_P27-1", + "ISO-8859-1", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + "ISO-8859-9E", + "ISO-8859-10", + "ISO-8859-11", + "ISO-8859-13", + "ISO-8859-14", + "ISO-8859-15", + "ISO-8859-16", + "UTF-7", + "UTF-8", + "UTF-16", + "UTF-32" + }; + } + } +} diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs index d879afd27..ff56be2dc 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/LanguageUtilities.cs @@ -3,10 +3,13 @@ Homepage: . It may be used under the terms of the GNU General Public License. */ -using System.Collections.Generic; - namespace HandBrake.ApplicationServices.Utilities { + using System.Collections.Generic; + + /// + /// Language Utilities + /// public class LanguageUtilities { /// -- cgit v1.2.3