using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
namespace DTS.Common.Converters
{
///
/// Converter which converts percentage to String.
///
public class FilePathsToShortStringConverter : IValueConverter
{
///
///
///
/// The decimal value to convert. This value can be a standard decimal value or a nullable decimal value.
/// This parameter is not used.
/// This parameter is not used.
/// The culture to use in the format operation.
/// The value to be passed to the target dependency property.
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var filePaths = value as string[];
if (null == filePaths || filePaths.Length < 1)
{
return string.Empty;
}
if (filePaths.Length > 1)
{
return Strings.Strings.MultipleFiles;
}
var fi = new FileInfo(filePaths[0]);
return fi.Name;
}
///
/// Conversion back is not supported.
///
/// A currency value.
/// This parameter is not used.
/// This parameter is not used.
/// This parameter is not used.
/// The value to be passed to the source object.
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}