/// <inheritdoc/> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var s = (string)value; var uri = s.StartsWith("/") ? new Uri(s, UriKind.Relative) : new Uri(s, UriKind.RelativeOrAbsolute); var svg = new SvgSource(); if (uri.IsAbsoluteUri && uri.IsFile) { svg.Load(uri.LocalPath); return(svg); } else { var assets = AvaloniaLocator.Current.GetService <IAssetLoader>(); svg.Load(assets.Open(uri, context.GetContextBaseUri())); } return(svg); }
/// <inheritdoc/> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { var s = (string)value; var uri = s.StartsWith("/") ? new Uri(s, UriKind.Relative) : new Uri(s, UriKind.RelativeOrAbsolute); var svg = new SvgSource(); if (uri.IsAbsoluteUri && uri.IsFile) { #if USE_PICTURE var document = SKSvg.Open(uri.LocalPath); if (document != null) { svg.Picture = SKSvg.ToModel(document); } #else svg.Load(uri.LocalPath); #endif return(svg); } else { var assets = AvaloniaLocator.Current.GetService <IAssetLoader>(); #if USE_PICTURE var document = SKSvg.Open(assets.Open(uri, context.GetContextBaseUri())); if (document != null) { svg.Picture = SKSvg.ToModel(document); } #else svg.Load(assets.Open(uri, context.GetContextBaseUri())); #endif } return(svg); }