protected override async Task <object> GetAsync(object foreground = null) { if (string.IsNullOrWhiteSpace(_source)) { return(null); } object icon; if (_parsed) { icon = await XamlTools.FromXamlStringAsync(_source).ConfigureAwait(true); } else { icon = await XamlTools.FromSvgStringAsync(_source).ConfigureAwait(true); _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); }
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); }
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 }); }
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); }