public AdaptiveCardsContainerBuilder AddTextBlock(string text, TextWeight weight, TextSize size) { TextBlock textBlock = new TextBlock() { Text = text, Weight = weight, Size = size }; _container.Items.Add(textBlock); return(this); }
internal static TextWeight FromClassList(HTMLElement element, TextWeight defaultValue) { var curFontSize = element.classList.FirstOrDefault(t => t.StartsWith("tss-fontweight-")); if (curFontSize is object && Enum.TryParse <TextWeight>(curFontSize.Substring("tss-fontweight-".Length), true, out var result)) { return(result); } else { return(defaultValue); } }
public bool PrintFieldValue(String nameText, String valueText, int textSize, int textWeight) { TextSize size = TextSize.Normal; TextWeight weight = TextWeight.Normal; if (Enum.IsDefined(typeof(TextSize), textSize)) { size = (TextSize)textSize; } if (Enum.IsDefined(typeof(TextWeight), textWeight)) { weight = (TextWeight)textWeight; } if (_printer == null) { _printer = FindPrinter(_deviceName); } if (_printer != null) { string textField = nameText.Replace("ESC", ((char)27).ToString()); string textValue = valueText.Replace("ESC", ((char)27).ToString()); string mods = ""; switch (size) { case TextSize.Large: mods += DoubleWideAndHightCharacters; break; } switch (weight) { case TextWeight.Bold: mods += Bold; break; } //add padding to fill expected receipt width while (textField.Length + textValue.Length < RECEIPT_CHAR_WIDTH) { textValue = " " + textValue; } _printer.PrintNormal(PrinterStation.Receipt, mods + textField + textValue + NewLine); return(true); } return(false); }
public void AddLine(string line, TextSize size = TextSize.Normal, TextAlignment align = TextAlignment.Left, TextWeight weight = TextWeight.Normal) { ReceiptLine l = new ReceiptLine(); l.Text = (line ?? string.Empty); l.Size = size; l.Weight = weight; l.Alignment = align; l.TextRight = null; _lines.Add(l); }
public void AddLineValuePair(string name, string value, TextSize size = TextSize.Large, TextWeight weight = TextWeight.Normal) { ReceiptLine l = new ReceiptLine(); l.Text = (name ?? string.Empty); l.TextRight = (value ?? string.Empty); l.Size = size; l.Weight = weight; l.Alignment = TextAlignment.Center; _lines.Add(l); }
internal static string ToClassName(this TextWeight textWeight) { return($"tss-fontweight-{textWeight.ToString().ToLower()}"); }
public static T SetTextWeight <T>(this T hasTextSize, TextWeight textWeight) where T : ITextFormating { hasTextSize.Weight = textWeight; return(hasTextSize); }
public bool Print(String input, int textSize, int textWeight, int textAlignment, string signatureUrl) { TextSize size = TextSize.Normal; TextWeight weight = TextWeight.Normal; TextAlignment align = TextAlignment.Left; if (Enum.IsDefined(typeof(TextSize), textSize)) { size = (TextSize)textSize; } if (Enum.IsDefined(typeof(TextWeight), textWeight)) { weight = (TextWeight)textWeight; } if (Enum.IsDefined(typeof(TextAlignment), textAlignment)) { align = (TextAlignment)textAlignment; } if (_printer == null) { _printer = FindPrinter(_deviceName); } if (_printer != null) { string textToPrint = input; string text = textToPrint.Replace("ESC", ((char)27).ToString()); string mods = ""; switch (size) { case TextSize.Large: mods += DoubleWideAndHightCharacters; break; } switch (align) { case TextAlignment.Center: mods += CenterAlign; break; case TextAlignment.Right: mods += RightAlign; break; } switch (weight) { case TextWeight.Bold: mods += Bold; break; } if (text.Contains("©")) { var index = text.IndexOf("©"); if (index == 0) { PrintCopyrightSymbol(); if (index < text.Length - 1) { DumpToPrinter(mods + text[index + 1] + NewLine, false); } else { DumpToPrinter(mods + NewLine, false); } } else if (index == text.Length - 1) { DumpToPrinter(mods + text[index - 1], false); PrintCopyrightSymbol(); DumpToPrinter(mods + NewLine, false); } else { DumpToPrinter(mods + text[index - 1], false); PrintCopyrightSymbol(); DumpToPrinter(mods + text[index + 1] + NewLine, false); } } else if (text.Contains("Signature")) { var eSignature = !string.IsNullOrEmpty(signatureUrl); if (eSignature) { text = text.Replace("_", ""); } DumpToPrinter(mods + text + NewLine, false); if (eSignature) { PrintSignature(signatureUrl); } } else { DumpToPrinter(mods + text + NewLine, false); } return(true); } return(false); }