31 lines
779 B
C#
31 lines
779 B
C#
|
|
using Microsoft.UI.Xaml.Data;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace VDownload.GUI.Converters
|
|||
|
|
{
|
|||
|
|
public class StringToUriConverter : IValueConverter
|
|||
|
|
{
|
|||
|
|
public object Convert(object value, Type targetType, object parameter, string language)
|
|||
|
|
{
|
|||
|
|
if (value is string str)
|
|||
|
|
{
|
|||
|
|
return new Uri(str, UriKind.RelativeOrAbsolute);
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public object ConvertBack(object value, Type targetType, object parameter, string language)
|
|||
|
|
{
|
|||
|
|
if (value is Uri uri)
|
|||
|
|
{
|
|||
|
|
return uri.OriginalString;
|
|||
|
|
}
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|