1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00
Artemis/src/Artemis.UI/Converters/UriToFileNameConverter.cs
Robert ab754942d5 Profile editor - Added adapt menu option
Profile editor - Implement menu title casing
Device properties - Display LED ID even if missing from enum
2021-06-30 17:07:44 +02:00

23 lines
658 B
C#

using System;
using System.Globalization;
using System.IO;
using System.Windows.Data;
namespace Artemis.UI.Converters
{
[ValueConversion(typeof(Uri), typeof(string))]
public class UriToFileNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Uri uri && uri.IsFile)
return Path.GetFileName(uri.LocalPath);
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Binding.DoNothing;
}
}
}