// -------------------------------------------------------------------------------------------------------------------- // // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. // // // Defines the FullPathToFileNameConverter type. // // -------------------------------------------------------------------------------------------------------------------- namespace HandBrakeWPF.Converters { using System.Globalization; using System.IO; using System.Windows.Data; using System; /// /// Converts a Full Path to Filename only. /// public sealed class FullPathToFileNameConverter : IValueConverter { /// /// Convert an Enum to it's display value (attribute) /// /// /// 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) { string path = value as string; if (!string.IsNullOrEmpty(path) && !path.EndsWith("\\")) { return Path.GetFileName(path); } return "Unknown"; } /// /// 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) { throw new NotImplementedException(); } } }