public void AppendIcon(IIcon icon) { var font = IconFonts.FindModuleOf(icon)?.ToUIFont(_iconText.Font.PointSize); var attrStr = new NSAttributedString($"{icon.Character}", font, _iconText.TextColor); Append(attrStr); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { var icon = (Project1UIIconType)value; string result = IconFonts.GetUnicodeString(icon); return(result); }
public void AppendIcon(IIcon icon) { Append(icon.Character); SetSpan(new CustomTypefaceSpan(IconFonts.FindModuleOf(icon).ToTypeface(Application.Context)), Length() - 1, Length(), SpanTypes.ExclusiveInclusive); SetSpan(new ForegroundColorSpan(_iconText.TextColor), Length() - 1, Length(), SpanTypes.ExclusiveInclusive); SetSpan(new AbsoluteSizeSpan((int)_iconText.TextSize), Length() - 1, Length(), SpanTypes.ExclusiveInclusive); }
/// <summary> /// To the UI image. /// </summary> /// <param name="icon">The icon.</param> /// <param name="size">The size.</param> /// <returns></returns> public static UIImage ToUIImage(this IIcon icon, nfloat size) { var attributedString = new NSAttributedString($"{icon.Character}", new CTStringAttributes { Font = new CTFont(IconFonts.FindModuleOf(icon).FontName, size), ForegroundColorFromContext = true }); var boundSize = attributedString.GetBoundingRect(new CGSize(10000f, 10000f), NSStringDrawingOptions.UsesLineFragmentOrigin, null).Size; UIGraphics.BeginImageContextWithOptions(boundSize, false, 0f); attributedString.DrawString(new CGRect(0f, 0f, boundSize.Width, boundSize.Height)); using (var image = UIGraphics.GetImageFromCurrentImageContext()) { UIGraphics.EndImageContext(); return(image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)); } }
public static NSAttributedString DoParseIcons(this IIconText iconText) { var regex = new Regex("{.*?}"); var text = iconText.Text ?? ""; var stringBuilder = new IconStringBuilder(iconText); var firstIconGroupEntry = text.IndexOf("{", StringComparison.InvariantCulture); if (firstIconGroupEntry != -1) { stringBuilder.AppendText(text.Substring(0, firstIconGroupEntry)); } foreach (Match match in regex.Matches(text)) { var icon = IconFonts.FindIconForKey(match.Value.Replace("{", "").Replace("}", "")); if (icon != null) { stringBuilder.AppendIcon(icon); } else { stringBuilder.AppendText("?"); } var nextMatch = match.NextMatch(); if (!string.IsNullOrEmpty(nextMatch.Value)) { var textToNextIcon = text.Substring(match.Index + match.Length, nextMatch.Index - match.Index - match.Length); stringBuilder.AppendText(textToNextIcon); } else { var textToEndOfLine = text.Substring(match.Index + match.Length, text.Length - match.Index - match.Length); stringBuilder.AppendText(textToEndOfLine); } } return(stringBuilder.Text); }
/// <summary> /// Create an <see cref="IconDrawable" />. /// </summary> /// <param name="context">Your activity or application context.</param> /// <param name="icon">The icon you want this drawable to display.</param> public IconDrawable(Context context, IIcon icon) { var module = IconFonts.FindModuleOf(icon); if (module is null) { throw new Java.Lang.IllegalStateException($"Unable to find the module associated with icon {icon.Key}, have you registered the module you are trying to use with IconFonts.With(...) in your Application?"); } _context = context; _icon = icon; _paint = new TextPaint { AntiAlias = true, TextAlign = Paint.Align.Center, UnderlineText = false }; _paint.SetStyle(Paint.Style.Fill); _paint.SetTypeface(module.ToTypeface(context)); }
public FrmMain() { // set the base name (used later to rename the form) this.BaseName = "Breaking Aurum"; InitializeComponent(); // set the form's style manager to the control `metroStyleManager` // it will allow to propagate the theme selection this.StyleManager = this.metroStyleManager; // Create the fonts icons collection & set the default one (MaterialIcons) this.IconFontManager = (new IconFonts()); this.IconFont = this.IconFontManager.GetFont(IconFonts.FONT_FAMILY.MaterialIcons, 17.0f); // set the default page and switch to it this.DefaultPage = this.HomePage; this.Font = new Font("Arial", 11f, FontStyle.Regular, GraphicsUnit.Pixel); // ---- // Load the user's preferences LoadSettings(); // Load the LocalizationManager that will provide the localization system Program.settings.localize.ImportResourceLocalization(this.Name); // load the form's localization data Program.settings.localize.ImportResourceLocalization("Sidebar"); // load the sidebar's localization data // try to localize every sub-control Program.settings.localize.ControlerTranslator(this); // create the sidebar's top entries this.TopSidebarEntries = new SidebarEntry[] { // (To have a parent that do nothing: pass as first parameter: `(MultiPanePage)null`) new SidebarEntry(this.HomePage, new byte[] { 0xEE, 0xA2, 0x8A }, // little "house" icon Program.settings.localize.Translate("sidebar_page_home")), new SidebarEntry( target: this.PageDashboard, callback: () => this.UpdateDashboard(), icon: new byte[] { 0xEE, 0xA1, 0xB1 }, // a grid icon text: Program.settings.localize.Translate("sidebar_page_dashboard"), children: null ), new SidebarEntry(() => (new FrmCalendrierPrev()).ShowDialog(), new byte[] { 0xEE, 0xA4, 0x96 }, // a timetable icon Program.settings.localize.Translate("sidebar_page_calendrier_previsionnel")), // budget previsonnel new SidebarEntry((MultiPanePage)null, new byte[] { 0xEE, 0xA2, 0xA1 }, // credit card icon Program.settings.localize.Translate("sidebar_page_budget_previsionnel"), new SidebarEntry[] { new SidebarEntry(this.PagePostesFixes, Program.settings.localize.Translate("sidebar_page_poste_fixe")), new SidebarEntry(this.PagePostesPonctuel, Program.settings.localize.Translate("sidebar_page_poste_ponctuel")), new SidebarEntry(this.PageRevenus, Program.settings.localize.Translate("sidebar_page_revenu")), new SidebarEntry(() => (new FrmTableauDeBordPostes()).ShowDialog(), Program.settings.localize.Translate("sidebar_page_lister_postes")), } ), // budget du mois new SidebarEntry((MultiPanePage)null, new byte[] { 0xEE, 0xA1, 0xAC }, // "validate/ check" icon Program.settings.localize.Translate("sidebar_page_budget_mois"), new SidebarEntry[] { new SidebarEntry( () => { (new AjouterTransaction()).ShowDialog(); this.UpdateDashboard(); }, Program.settings.localize.Translate("sidebar_page_ajouter_transaction") ), new SidebarEntry( () => (new FrmAffichage1par1()).ShowDialog(), Program.settings.localize.Translate("sidebar_page_lister_transactions") ), new SidebarEntry( () => (new TransactionsToPDF()).ShowDialog(), Program.settings.localize.Translate("sidebar_page_exporter_transactions") ), }), }; // create the sidebar's bottom entries this.BottomSidebarEntries = new SidebarEntry[] { new SidebarEntry(this.SettingsPage, new byte[] { 0xEE, 0xA1, 0xA9 }, // gear icon Program.settings.localize.Translate("sidebar_page_settings")), new SidebarEntry(this.LicensesPage, new byte[] { 0xEE, 0x90, 0xA0 }, // smiling icon Program.settings.localize.Translate("sidebar_page_licenses")) }; // initialize sub panels InitializePostesFixes(); InitializePostesPonctuels(echancesContainer); InitiliazePosteRevenu(); InitiliazeSettingsPage(); }