-
Notifications
You must be signed in to change notification settings - Fork 400
Expand file tree
/
Copy pathOFPAConverters.cs
More file actions
37 lines (31 loc) · 1.03 KB
/
OFPAConverters.cs
File metadata and controls
37 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using Avalonia.Data.Converters;
namespace SourceGit.Converters
{
public class PathToDisplayNameConverter : IMultiValueConverter
{
public object Convert(IList<object> values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Count < 2)
return "";
string path = values[0] as string ?? string.Empty;
var decodedPaths = values[1] as IReadOnlyDictionary<string, string>;
if (decodedPaths != null &&
decodedPaths.TryGetValue(path, out var decoded) &&
!string.IsNullOrEmpty(decoded))
{
return decoded;
}
if (parameter as string == "PureFileName")
return Path.GetFileName(path);
return path;
}
}
public static class OFPAConverters
{
public static readonly PathToDisplayNameConverter PathToDisplayName = new();
}
}