diff options
author | sr55 <[email protected]> | 2011-04-08 19:34:20 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2011-04-08 19:34:20 +0000 |
commit | 5f692a69a63f106cabe9dad4dfc85cc5c6d93cb9 (patch) | |
tree | 8f9762b3f7a4ad797ba7e8016d1d25bc9f94f709 /win/CS/HandBrake.ApplicationServices/Functions | |
parent | 122c93f2b05790907e79c9a292342b3763399948 (diff) |
WinGui: AudioPanel refactored.
- Switch the Audio panel to use DataBinding to a BindingList collection leading to much cleaner code.
- Added gain support (--gain=3,4) to the services library. (UI has not been done yet)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3911 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Functions')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs index 0bbc746d7..657434f31 100644 --- a/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs +++ b/win/CS/HandBrake.ApplicationServices/Functions/EnumHelper.cs @@ -12,7 +12,10 @@ namespace HandBrake.ApplicationServices.Functions /// <summary>
/// Enum Helpers
/// </summary>
- public class EnumHelper
+ /// <typeparam name="T">
+ /// The Type Parameter
+ /// </typeparam>
+ public class EnumHelper<T>
{
/// <summary>
/// Get the description of an Enum
@@ -23,7 +26,7 @@ namespace HandBrake.ApplicationServices.Functions /// <returns>
/// The Description string
/// </returns>
- public static string GetDescription(Enum value)
+ public static string GetDescription(T value)
{
FieldInfo fieldInfo = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes =
@@ -31,5 +34,24 @@ namespace HandBrake.ApplicationServices.Functions typeof(DescriptionAttribute), false);
return (attributes.Length > 0) ? attributes[0].Description : value.ToString();
}
+
+ /// <summary>
+ /// Get the Enumeration for a given Enum Description
+ /// </summary>
+ /// <param name="description">The String description</param>
+ /// <returns>The Enum Value</returns>
+ public static T GetValue(string description)
+ {
+ foreach (T val in Enum.GetValues(typeof(T)))
+ {
+ string currDescription = GetDescription(val);
+ if (currDescription == description)
+ {
+ return val;
+ }
+ }
+
+ throw new ArgumentOutOfRangeException("The Description for the enum was not recognized.");
+ }
}
}
|