/// <summary> /// /// </summary> private TabUiItem GenerateSettingsPage() { ResourceLoader resources = ResourceLoader.GetForCurrentView("Resources"); string title = resources.GetString("ViewTitleSettings"); IconSource icon = new FontIconSource { Glyph = "\uE713", FontFamily = new FontFamily("Segoe MDL2 Assets"), FontSize = 20 }; SettingsView view = new SettingsView(); view.ViewModel.OnOpenTabRequested += ViewModel_OnOpenTabRequested; TabUiItem tabUiItem = this.GenerateTabUiItem(view, title, icon); return(tabUiItem); }
public static IconSource?ToIconSource(this IImageSource source, IMauiContext mauiContext) { IconSource?image = null; if (source is IFileImageSource fis) { image = new BitmapIconSource { UriSource = new Uri("ms-appx:///" + fis.File) }; } else if (source is IUriImageSource uri) { image = new BitmapIconSource { UriSource = uri?.Uri }; } else if (source is IFontImageSource fontImageSource) { image = new FontIconSource { Glyph = fontImageSource.Glyph, FontSize = fontImageSource.Font.Size }; if (fontImageSource.Color != null) { image.Foreground = fontImageSource.Color.ToPlatform(); } else { image.Foreground = Colors.White.ToPlatform(); } var fontManager = mauiContext.Services.GetRequiredService <IFontManager>(); var uwpFontFamily = fontManager.GetFontFamily(fontImageSource.Font); if (!string.IsNullOrEmpty(uwpFontFamily.Source)) { ((FontIconSource)image).FontFamily = uwpFontFamily; } } return(image); }
/// <inheritdoc/> public override object ProvideValue(IServiceProvider serviceProvider) { var fontIcon = new FontIconSource { Glyph = unchecked ((char)Symbol).ToString(), FontFamily = SegoeMDL2AssetsFontFamily, FontWeight = FontWeight, FontStyle = FontStyle }; if (FontSize > 0) { fontIcon.FontSize = FontSize; } if (Foreground != null) { fontIcon.Foreground = Foreground; } return(fontIcon); }
/// <inheritdoc/> public override object ProvideValue(IServiceProvider serviceProvider) { var fontIcon = new FontIconSource { Glyph = Glyph, FontFamily = FontFamily ?? SegoeMDL2AssetsFontFamily, FontWeight = FontWeight, FontStyle = FontStyle }; if (FontSize > 0) { fontIcon.FontSize = FontSize; } if (Foreground != null) { fontIcon.Foreground = Foreground; } return(fontIcon); }
public static async Task AddNewTab(Type type, object tabViewItemArgs, int atIndex = -1) { FontIconSource fontIconSource = new FontIconSource(); fontIconSource.FontFamily = App.MainViewModel.FontName; TabItem tabItem = new TabItem() { Header = null, IconSource = fontIconSource, Description = null }; tabItem.Control.NavigationArguments = new TabItemArguments() { InitialPageType = type, NavigationArg = tabViewItemArgs }; tabItem.Control.ContentChanged += MainPageViewModel.Control_ContentChanged; await MainPageViewModel.UpdateTabInfo(tabItem, tabViewItemArgs); MainPageViewModel.AppInstances.Insert(atIndex == -1 ? MainPageViewModel.AppInstances.Count : atIndex, tabItem); }
/// <inheritdoc/> protected override object ProvideValue() { var fontIcon = new FontIconSource { Glyph = Glyph, FontFamily = FontFamily ?? SegoeMDL2AssetsFontFamily, FontWeight = FontWeight, FontStyle = FontStyle, IsTextScaleFactorEnabled = IsTextScaleFactorEnabled, MirroredWhenRightToLeft = MirroredWhenRightToLeft }; if (FontSize > 0) { fontIcon.FontSize = FontSize; } if (Foreground != null) { fontIcon.Foreground = Foreground; } return(fontIcon); }
private void Flag_ItemInvoked(SwipeItem sender, SwipeItemInvokedEventArgs args) { isFlagged = !isFlagged; CheckAcceptFlagBool(args.SwipeControl); if (isFlagged) { FontIconSource filledFlagIcon = new FontIconSource() { Glyph = "\ueB4B" }; sender.IconSource = filledFlagIcon; sender.Text = "Unmark"; } else { FontIconSource flagIcon = new FontIconSource() { Glyph = "\ue129" }; sender.IconSource = flagIcon; sender.Text = "Flag"; } }
private void Accept_ItemInvoked(SwipeItem sender, SwipeItemInvokedEventArgs args) { isAccepted = !isAccepted; CheckAcceptFlagBool(args.SwipeControl); if (isAccepted) { FontIconSource cancelIcon = new FontIconSource() { Glyph = "\ue711" }; sender.IconSource = cancelIcon; sender.Text = "Cancel"; } else { FontIconSource acceptIcon = new FontIconSource() { Glyph = "\ue10B" }; sender.IconSource = acceptIcon; sender.Text = "Accept"; } }
/// <inheritdoc/> protected override object ProvideValue() { var fontIcon = new FontIconSource { Glyph = unchecked ((char)Symbol).ToString(), FontFamily = SymbolThemeFontFamily, FontWeight = FontWeight, FontStyle = FontStyle, IsTextScaleFactorEnabled = IsTextScaleFactorEnabled, MirroredWhenRightToLeft = MirroredWhenRightToLeft }; if (FontSize > 0) { fontIcon.FontSize = FontSize; } if (Foreground != null) { fontIcon.Foreground = Foreground; } return(fontIcon); }
public void InfoBadgeSupportsAllIconTypes() { InfoBadge infoBadge = null; SymbolIconSource symbolIconSource = null; PathIconSource pathIconSource = null; AnimatedIconSource animatedIconSource = null; BitmapIconSource bitmapIconSource = null; ImageIconSource imageIconSource = null; FontIconSource fontIconSource = null; RunOnUIThread.Execute(() => { infoBadge = new InfoBadge(); symbolIconSource = new SymbolIconSource(); symbolIconSource.Symbol = Symbol.Setting; fontIconSource = new FontIconSource(); fontIconSource.Glyph = "99+"; fontIconSource.FontFamily = new FontFamily("XamlAutoFontFamily"); bitmapIconSource = new BitmapIconSource(); bitmapIconSource.ShowAsMonochrome = false; Uri bitmapUri = new Uri("ms-appx:/Assets/ingredient1.png"); bitmapIconSource.UriSource = bitmapUri; imageIconSource = new ImageIconSource(); var imageUri = new Uri("https://raw.githubusercontent.com/DiemenDesign/LibreICONS/master/svg-color/libre-camera-panorama.svg"); imageIconSource.ImageSource = new SvgImageSource(imageUri); pathIconSource = new PathIconSource(); var geometry = new RectangleGeometry(); geometry.Rect = new Windows.Foundation.Rect { Width = 5, Height = 2, X = 0, Y = 0 }; pathIconSource.Data = geometry; animatedIconSource = new AnimatedIconSource(); animatedIconSource.Source = new AnimatedSettingsVisualSource(); Content = infoBadge; Content.UpdateLayout(); }); IdleSynchronizer.Wait(); RunOnUIThread.Execute(() => { Log.Comment("Switch to Symbol Icon"); infoBadge.IconSource = symbolIconSource; Content.UpdateLayout(); Log.Comment("Switch to Path Icon"); infoBadge.IconSource = pathIconSource; Content.UpdateLayout(); Log.Comment("Switch to Font Icon"); infoBadge.IconSource = fontIconSource; Content.UpdateLayout(); Log.Comment("Switch to bitmap Icon"); infoBadge.IconSource = bitmapIconSource; Content.UpdateLayout(); Log.Comment("Switch to Image Icon"); infoBadge.IconSource = imageIconSource; Content.UpdateLayout(); Log.Comment("Switch to Animated Icon"); infoBadge.IconSource = animatedIconSource; Content.UpdateLayout(); }); }