diff options
author | sr55 <[email protected]> | 2012-03-01 19:01:54 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-03-01 19:01:54 +0000 |
commit | 2efd8f264113bcd3d8c39a1f408c16cc27100aa7 (patch) | |
tree | aedb1cc0017839a91bdc80c46819332b76a975f9 /win/CS/HandBrakeWPF/Converters | |
parent | 5bb4078641106578dd0a8e1eab6e1cfbc814067e (diff) |
WinGui: (WPF) Further work wiring up the new UI.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4479 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrakeWPF/Converters')
3 files changed, 158 insertions, 85 deletions
diff --git a/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs b/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs deleted file mode 100644 index b53637bca..000000000 --- a/win/CS/HandBrakeWPF/Converters/AudioEnumConverter.cs +++ /dev/null @@ -1,83 +0,0 @@ -// --------------------------------------------------------------------------------------------------------------------
-// <copyright file="BooleanToVisibilityConverter.cs" company="HandBrake Project (http://handbrake.fr)">
-// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
-// </copyright>
-// <summary>
-// Defines the BooleanToVisibilityConverter type.
-// </summary>
-// --------------------------------------------------------------------------------------------------------------------
-
-namespace HandBrakeWPF.Converters
-{
- using System.Collections.Generic;
- using System.Globalization;
- using System.Windows.Data;
- using System;
-
- using HandBrake.ApplicationServices.Functions;
- using HandBrake.Interop.Model.Encoding;
-
- /// <summary>
- /// Boolean to Visibility Converter
- /// </summary>
- public sealed class AudioEnumConverter : IValueConverter
- {
- /// <summary>
- /// Convert an Enum to it's display value (attribute)
- /// </summary>
- /// <param name="value">
- /// The value.
- /// </param>
- /// <param name="targetType">
- /// The target type.
- /// </param>
- /// <param name="parameter">
- /// The parameter. (A boolean which inverts the output)
- /// </param>
- /// <param name="culture">
- /// The culture.
- /// </param>
- /// <returns>
- /// Visibility property
- /// </returns>
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is Mixdown)
- {
- return EnumHelper<Mixdown>.GetEnumDisplayValues(value.GetType());
- }
- else if (value is AudioEncoder)
- {
- return EnumHelper<AudioEncoder>.GetEnumDisplayValues(value.GetType());
- }
-
- return new List<string>();
- }
-
- /// <summary>
- /// Convert Back for the IValueConverter Interface. Not used!
- /// </summary>
- /// <param name="value">
- /// The value.
- /// </param>
- /// <param name="targetType">
- /// The target type.
- /// </param>
- /// <param name="parameter">
- /// The parameter.
- /// </param>
- /// <param name="culture">
- /// The culture.
- /// </param>
- /// <returns>
- /// Nothing
- /// </returns>
- /// <exception cref="NotImplementedException">
- /// This method is not used!
- /// </exception>
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs new file mode 100644 index 000000000..b5ee371b6 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/EnumComboConverter.cs @@ -0,0 +1,155 @@ +// --------------------------------------------------------------------------------------------------------------------
+// <copyright file="EnumComboConverter.cs" company="HandBrake Project (http://handbrake.fr)">
+// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
+// </copyright>
+// <summary>
+// Defines the EnumComboConverter type.
+// </summary>
+// --------------------------------------------------------------------------------------------------------------------
+
+namespace HandBrakeWPF.Converters
+{
+ using System.Collections.Generic;
+ using System.Globalization;
+ using System.Windows.Data;
+ using System;
+
+ using HandBrake.ApplicationServices.Functions;
+ using HandBrake.Interop.Model.Encoding;
+ using HandBrake.Interop.Model.Encoding.x264;
+
+ /// <summary>
+ /// Enum Combo Converter
+ /// </summary>
+ public sealed class EnumComboConverter : IValueConverter
+ {
+ /// <summary>
+ /// Convert an Enum to it's display value (attribute)
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter. (A boolean which inverts the output)
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// Visibility property
+ /// </returns>
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ // Lists
+ if (value is IEnumerable<x264Preset>)
+ {
+ return EnumHelper<x264Preset>.GetEnumDisplayValues(typeof(x264Preset));
+ }
+ if (value is IEnumerable<x264Profile>)
+ {
+ return EnumHelper<x264Profile>.GetEnumDisplayValues(typeof(x264Profile));
+ }
+ if (value is IEnumerable<x264Tune>)
+ {
+ return EnumHelper<x264Tune>.GetEnumDisplayValues(typeof(x264Tune));
+ }
+ if (value is IEnumerable<VideoEncoder>)
+ {
+ return EnumHelper<VideoEncoder>.GetEnumDisplayValues(typeof(VideoEncoder));
+ }
+ if (value is IEnumerable<Mixdown>)
+ {
+ return EnumHelper<Mixdown>.GetEnumDisplayValues(typeof(Mixdown));
+ }
+
+ if (value is IEnumerable<AudioEncoder>)
+ {
+ return EnumHelper<AudioEncoder>.GetEnumDisplayValues(typeof(AudioEncoder));
+ }
+
+
+
+ // Single Items
+ if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset))
+ {
+ return EnumHelper<x264Preset>.GetDisplay((x264Preset)value);
+ }
+ if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile))
+ {
+ return EnumHelper<x264Profile>.GetDisplay((x264Profile)value);
+ }
+ if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune))
+ {
+ return EnumHelper<x264Tune>.GetDisplay((x264Tune)value);
+ }
+ if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))
+ {
+ return EnumHelper<VideoEncoder>.GetDisplay((VideoEncoder)value);
+ }
+ if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))
+ {
+ return EnumHelper<Mixdown>.GetDisplay((Mixdown)value);
+ }
+ if (targetType == typeof(AudioEncoder) || value.GetType() == typeof(AudioEncoder))
+ {
+ return EnumHelper<AudioEncoder>.GetDisplay((AudioEncoder)value);
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Convert Back for the IValueConverter Interface.
+ /// </summary>
+ /// <param name="value">
+ /// The value.
+ /// </param>
+ /// <param name="targetType">
+ /// The target type.
+ /// </param>
+ /// <param name="parameter">
+ /// The parameter.
+ /// </param>
+ /// <param name="culture">
+ /// The culture.
+ /// </param>
+ /// <returns>
+ /// Nothing
+ /// </returns>
+ /// <exception cref="NotImplementedException">
+ /// This method is not used!
+ /// </exception>
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ if (targetType == typeof(x264Preset) || value.GetType() == typeof(x264Preset))
+ {
+ return EnumHelper<x264Preset>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(x264Profile) || value.GetType() == typeof(x264Profile))
+ {
+ return EnumHelper<x264Profile>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(x264Tune) || value.GetType() == typeof(x264Tune))
+ {
+ return EnumHelper<x264Tune>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(VideoEncoder) || value.GetType() == typeof(VideoEncoder))
+ {
+ return EnumHelper<VideoEncoder>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(Mixdown) || value.GetType() == typeof(Mixdown))
+ {
+ return EnumHelper<Mixdown>.GetValue(value.ToString());
+ }
+ if (targetType == typeof(AudioEncoder) || value.GetType() == typeof(AudioEncoder))
+ {
+ return EnumHelper<AudioEncoder>.GetValue(value.ToString());
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs index b0f764ba8..fa659d232 100644 --- a/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/FullPathToFileNameConverter.cs @@ -39,9 +39,10 @@ namespace HandBrakeWPF.Converters /// </returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (!string.IsNullOrEmpty(value.ToString()))
+ string path = value as string;
+ if (!string.IsNullOrEmpty(path) && ! path.EndsWith("\\"))
{
- return Path.GetFileName(value.ToString());
+ return Path.GetFileName(path);
}
return "Unknown";
|