/// <inheritdoc/>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var path    = (string)value;
            var baseUri = context.GetContextBaseUri();

            return(SvgSource.Load <SvgSource>(path, baseUri));
        }
Ejemplo n.º 2
0
        /// <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);
            }
            var assets = AvaloniaLocator.Current.GetService <IAssetLoader>();

            svg.Load(assets.Open(uri, context.GetContextBaseUri()));
            return(svg);
        }
Ejemplo n.º 3
0
 public SvgCustomDrawOperation(Rect bounds, SvgSource svg)
 {
     _svg   = svg;
     Bounds = bounds;
 }