protected override object Get(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_name))
            {
                return(null);
            }

            object icon;

            if (_parsed)
            {
                icon = XamlTools.FromXamlString(_source);
            }
            else
            {
                using var xamlStream = _resourceManager.GetStream(_name);
                if (xamlStream == null)
                {
                    return(null);
                }

                icon    = XamlTools.FromXamlStream(xamlStream);
                _source = XamlWriter.Save(icon);
                _parsed = true;
            }

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.Value, brush);
            }

            return(icon);
        }
Exemplo n.º 2
0
        protected override object Get(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_source))
            {
                return(null);
            }

            object icon;

            if (_parsed)
            {
                icon = XamlTools.FromXamlString(_source);
            }
            else
            {
                icon    = XamlTools.FromSvgString(_source);
                _source = XamlWriter.Save(icon);
                _parsed = true;
            }

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.ToColor(), brush);
            }

            return(icon);
        }
Exemplo n.º 3
0
        protected override object Get(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_name))
            {
                return(null);
            }

            object icon;

            if (_parsed)
            {
                icon = XamlTools.FromXamlString(_sourceXaml);
            }
            else
            {
                AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
                using var svg = _resourceManager.GetStream(_name);
                icon          = XamlTools.FromSvgStream(svg);
                _sourceXaml   = XamlWriter.Save(icon);
                _parsed       = true;
            }

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.Value, brush);
            }

            return(icon);
        }
Exemplo n.º 4
0
        protected override async Task <object> GetAsync(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_name))
            {
                return(null);
            }

            object icon;

            if (_parsed)
            {
                icon = await XamlTools.FromXamlStringAsync(_sourceXaml).ConfigureAwait(true);

                //XamlTools.SetBinding((DependencyObject)icon1, _foreColor);
            }
            else
            {
                AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
                await using var svg = _resourceManager.GetStream(_name);
                icon = await XamlTools.FromSvgStreamAsync(svg).ConfigureAwait(true);

                if (icon != null)
                {
                    _sourceXaml = XamlWriter.Save(icon);
                    _parsed     = true;
                }
            }

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.Value, brush);
            }

            return(icon);
        }
Exemplo n.º 5
0
        private static async Task <object> GetXamlIconAsync(string source, int?foreColor)
        {
            var icon = (UIElement)await XamlTools.FromXamlStringAsync(source).ConfigureAwait(true);

            return(new Viewbox
            {
                Child = icon,
                MaxHeight = 30
            });
        }
Exemplo n.º 6
0
        protected override object Get(object foreground = null)
        {
            AppContext.SetSwitch("Switch.System.Xml.AllowDefaultResolver", true);
            var icon = Application.LoadComponent(_uri);

            if (icon is DependencyObject o && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor, brush);
            }

            return(icon);
        }
Exemplo n.º 7
0
        private static async Task <object> GetSvgIconAsync(string source, int?foreColor)
        {
            if (string.IsNullOrWhiteSpace(source))
            {
                return(null);
            }
            var icon = (UIElement)await XamlTools.FromSvgStringAsync(source).ConfigureAwait(true);

            return(new Viewbox
            {
                Child = icon,
                MaxHeight = 30
            });
        }
Exemplo n.º 8
0
        protected override object Get(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_name))
            {
                return(null);
            }

            var icon = XamlTools.FromXamlString(_source);

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.ToColor(), brush);
            }

            return(icon);
        }
Exemplo n.º 9
0
        protected override async Task <object> GetAsync(object foreground = null)
        {
            if (string.IsNullOrWhiteSpace(_name))
            {
                return(null);
            }

            var icon = await XamlTools.FromXamlStringAsync(_source).ConfigureAwait(true);

            if (icon is DependencyObject o && _foreColor.HasValue && foreground is Brush brush)
            {
                XamlTools.SetForeground(o, _foreColor.ToColor(), brush);
            }

            return(icon);
        }
Exemplo n.º 10
0
 private async Task ToXamlAsync()
 {
     Model.SourceXaml = await XamlTools.SvgToXamlAsync(Model.SourceSvg).ConfigureAwait(false);
 }