public static IconElement MakeIconElementFrom(Microsoft.UI.Xaml.Controls.IconSource iconSource) { if (iconSource is Microsoft.UI.Xaml.Controls.FontIconSource fontIconSource) { FontIcon fontIcon = new FontIcon(); fontIcon.Glyph = fontIconSource.Glyph; fontIcon.FontSize = fontIconSource.FontSize; if (fontIconSource.FontFamily != null) { fontIcon.FontFamily = fontIconSource.FontFamily; } fontIcon.FontWeight = fontIconSource.FontWeight; fontIcon.FontStyle = fontIconSource.FontStyle; fontIcon.IsTextScaleFactorEnabled = fontIconSource.IsTextScaleFactorEnabled; fontIcon.MirroredWhenRightToLeft = fontIconSource.MirroredWhenRightToLeft; return(fontIcon); } else if (iconSource is Microsoft.UI.Xaml.Controls.SymbolIconSource symbolIconSource) { SymbolIcon symbolIcon = new SymbolIcon(); symbolIcon.Symbol = symbolIconSource.Symbol; return(symbolIcon); } else if (iconSource is Microsoft.UI.Xaml.Controls.BitmapIconSource bitmapIconSource) { BitmapIcon bitmapIcon = new BitmapIcon(); if (bitmapIconSource.UriSource != null) { bitmapIcon.UriSource = bitmapIconSource.UriSource; } if (IsSystemDll() || ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.BitmapIcon", "ShowAsMonochrome")) { bitmapIcon.ShowAsMonochrome = bitmapIconSource.ShowAsMonochrome; } return(bitmapIcon); } else if (iconSource is Microsoft.UI.Xaml.Controls.PathIconSource pathIconSource) { PathIcon pathIcon = new PathIcon(); if (pathIconSource.Data != null) { pathIcon.Data = pathIconSource.Data; } return(pathIcon); } return(null); }
public Task <Microsoft.UI.Xaml.Controls.IconSource> LoadIconSourceAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken)) { Microsoft.UI.Xaml.Controls.IconSource image = null; if (imagesource is FileImageSource filesource) { string file = filesource.File; image = new Microsoft.UI.Xaml.Controls.BitmapIconSource { UriSource = new Uri("ms-appx:///" + file) }; } return(Task.FromResult(image)); }
public Task <Microsoft.UI.Xaml.Controls.IconSource> LoadIconSourceAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken)) { Microsoft.UI.Xaml.Controls.IconSource image = null; if (imagesource is FontImageSource fontImageSource) { image = new Microsoft.UI.Xaml.Controls.FontIconSource { Glyph = fontImageSource.Glyph, FontFamily = new FontFamily(fontImageSource.FontFamily), FontSize = fontImageSource.Size, Foreground = fontImageSource.Color.ToBrush() }; } return(Task.FromResult(image)); }
public Task <Microsoft.UI.Xaml.Controls.IconSource> LoadIconSourceAsync(ImageSource imagesource, CancellationToken cancellationToken = default(CancellationToken)) { Microsoft.UI.Xaml.Controls.IconSource image = null; if (imagesource is FontImageSource fontImageSource) { image = new WFontIconSource { Glyph = fontImageSource.Glyph, FontSize = fontImageSource.Size, Foreground = fontImageSource.Color.ToBrush() }; var uwpFontFamily = fontImageSource.FontFamily.ToFontFamily(); if (!string.IsNullOrEmpty(uwpFontFamily.Source)) { ((WFontIconSource)image).FontFamily = uwpFontFamily; } } return(Task.FromResult(image)); }
public static void CreateSwipeItem <T>(this Microsoft.UI.Xaml.Controls.SwipeItems flyout, Func <T, bool> visibility, ICommand command, T parameter, string text, Microsoft.UI.Xaml.Controls.IconSource icon = null) where T : class { var value = visibility(parameter as T); if (value) { var flyoutItem = new Microsoft.UI.Xaml.Controls.SwipeItem(); flyoutItem.Command = command; flyoutItem.CommandParameter = parameter; flyoutItem.Text = text; if (icon != null) { flyoutItem.IconSource = icon; } flyout.Add(flyoutItem); } }