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

            return(SvgSource.Load(path, baseUri));
        }
Beispiel #2
0
        private WindowIcon CreateIconFromPath(ITypeDescriptorContext context, string s)
        {
            var uri = s.StartsWith("/")
                ? new Uri(s, UriKind.Relative)
                : new Uri(s, UriKind.RelativeOrAbsolute);

            if (uri.IsAbsoluteUri && uri.IsFile)
            {
                return(new WindowIcon(uri.LocalPath));
            }
            var assets = AvaloniaLocator.Current.GetService <IAssetLoader>();

            return(new WindowIcon(assets.Open(uri, context.GetContextBaseUri())));
        }
Beispiel #3
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)
            {
#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);
        }
        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);

            if (uri.IsAbsoluteUri && uri.IsFile)
            {
                return(new Bitmap(uri.LocalPath));
            }

            var assets = AvaloniaLocator.Current.GetService <IAssetLoader>();

            return(new Bitmap(assets.Open(uri, context.GetContextBaseUri())));
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            var s = (string)value;

            return(FontFamily.Parse(s, context.GetContextBaseUri()));
        }