51 lines
1.9 KiB
C#
51 lines
1.9 KiB
C#
using System;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Windows.Data;
|
|
|
|
namespace DTS.Common.Converters
|
|
{
|
|
|
|
/// <summary>
|
|
/// Converter which converts percentage to String.
|
|
/// </summary>
|
|
public class FilePathsToShortStringConverter : IValueConverter
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="value">The decimal value to convert. This value can be a standard decimal value or a nullable decimal value.</param>
|
|
/// <param name="targetType">This parameter is not used.</param>
|
|
/// <param name="parameter">This parameter is not used.</param>
|
|
/// <param name="culture">The culture to use in the format operation.</param>
|
|
/// <returns>The value to be passed to the target dependency property.</returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Conversion back is not supported.
|
|
/// </summary>
|
|
/// <param name="value">A currency value.</param>
|
|
/// <param name="targetType">This parameter is not used.</param>
|
|
/// <param name="parameter">This parameter is not used.</param>
|
|
/// <param name="culture">This parameter is not used.</param>
|
|
/// <returns>The value to be passed to the source object.</returns>
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|