internal static Label MakeSingleColorLabel(IUIService uiService, IFontService fontService, string friendlyName, Color?FGColor, float fontSize, FontStyle style, Color?BGColor = null) { // Single Color FGColor = TQColorHelper.GetColorFromTaggedString(friendlyName)?.Color() ?? FGColor ?? TQColor.White.Color(); // Color Tag take précédence var txt = TQColorHelper.RemoveLeadingColorTag(friendlyName); var row = new Label() { Text = txt, ForeColor = FGColor.Value, Font = fontService.GetFontAlbertusMTLight(fontSize, style, uiService.Scale), AutoSize = true, Anchor = AnchorStyles.Left, BackColor = BGColor ?? Color.Transparent, //BackColor = Color.Red, BorderStyle = BorderStyle.None, // BorderStyle.FixedSingle Margin = new Padding(0), }; if (BGColor.HasValue) { row.BackColor = BGColor.Value; } return(row); }
/// <summary> /// Gets a color tag for a line of text /// </summary> /// <param name="text">text containing the color tag</param> /// <returns>System.Drawing.Color of the embedded color code</returns> public static Color GetColor(this Item itm, string text) { if (string.IsNullOrEmpty(text)) { // Use the standard color code for the item return(Color(itm.ItemStyle)); } // Look for a formatting tag in the beginning of the string TQColor?colorCode = TQColorHelper.GetColorFromTaggedString(text); // We didn't find a code so use the standard color code for the item if (colorCode is null) { return(Color(itm.ItemStyle)); } // We found something so lets try to find the code return(Color(colorCode.Value)); }