2022-05-20 15:39:52 +08:00
|
|
|
|
using System;
|
2022-05-10 15:33:06 +08:00
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
|
|
|
|
|
|
|
namespace GeekDesk.Converts
|
|
|
|
|
|
{
|
|
|
|
|
|
class StringAppendConvert : IValueConverter
|
|
|
|
|
|
{
|
|
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
2022-06-08 15:52:48 +08:00
|
|
|
|
if (value == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
value = "";
|
|
|
|
|
|
}
|
2022-05-10 15:33:06 +08:00
|
|
|
|
if (parameter == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return value.ToString();
|
2022-05-20 15:39:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2022-05-10 15:33:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
string val = value.ToString();
|
2022-06-08 15:52:48 +08:00
|
|
|
|
if (string.IsNullOrEmpty(val))
|
|
|
|
|
|
{
|
|
|
|
|
|
return parameter.ToString()
|
|
|
|
|
|
.Replace("\\n", "")
|
|
|
|
|
|
.Replace("{}", "");
|
|
|
|
|
|
}
|
2022-05-10 15:33:06 +08:00
|
|
|
|
string param = parameter.ToString();
|
2022-06-08 15:52:48 +08:00
|
|
|
|
param = param.Replace("\\n", "\n");
|
2022-05-10 15:33:06 +08:00
|
|
|
|
return param.Replace("{}", val);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|