blob: b5ee371b6c3b9f71dcd22f925aef6a2f185e1d10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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;
}
}
}
|