From 54e6a851ccec4be58087f8d90d4e04fb2623b4b5 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 8 Jan 2012 15:09:40 +0000 Subject: WinGui: (WPF) Further work on hooking up the various tabs on the Main Window. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4404 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Converters/BooleanConverter.cs | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Converters/BooleanConverter.cs (limited to 'win/CS/HandBrakeWPF/Converters') diff --git a/win/CS/HandBrakeWPF/Converters/BooleanConverter.cs b/win/CS/HandBrakeWPF/Converters/BooleanConverter.cs new file mode 100644 index 000000000..a01b3bf67 --- /dev/null +++ b/win/CS/HandBrakeWPF/Converters/BooleanConverter.cs @@ -0,0 +1,78 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// Defines the BooleanConverter type. +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Converters +{ + using System.Globalization; + using System.Windows.Data; + using System; + + /// + /// Boolean to Visibility Converter + /// + public sealed class BooleanConverter : IValueConverter + { + /// + /// Convert a boolean to visibility property. + /// + /// + /// The value. + /// + /// + /// The target type. + /// + /// + /// The parameter. (A boolean which inverts the output) + /// + /// + /// The culture. + /// + /// + /// Visibility property + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + // Paramater is a boolean which inverts the output. + var param = System.Convert.ToBoolean(parameter, CultureInfo.InvariantCulture); + + if (value is Boolean) + { + return param ? !(bool)value : value; + } + + return value; + } + + /// + /// Convert Back for the IValueConverter Interface. Not used! + /// + /// + /// The value. + /// + /// + /// The target type. + /// + /// + /// The parameter. + /// + /// + /// The culture. + /// + /// + /// Nothing + /// + /// + /// This method is not used! + /// + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return this.Convert(value, targetType, parameter, culture); + } + } +} -- cgit v1.2.3