public void SetText(string sText, Enumerations.FontSize oFontSize = Enumerations.FontSize.Medium, FontStyle oFontStyle = FontStyle.Regular, bool bFontExpanded = false, Enumerations.TextAlignmentType oTextAlignmentType = Enumerations.TextAlignmentType.Center, bool bBreakLine = true)
        {
            string sSpaces;

            switch (oTextAlignmentType)
            {
            case Enumerations.TextAlignmentType.Center:
                sSpaces = PrintUtility.GetCenterAlignmentText(sText, TotalCharactersPerLine, oFontSize);
                SetText(sSpaces, oFontSize, FontStyle.Regular, bFontExpanded, Enumerations.TextAlignmentType.Left, false);
                break;

            case Enumerations.TextAlignmentType.Right:
                sSpaces = PrintUtility.GetRightAlignmentText(sText, TotalCharactersPerLine, oFontSize);
                SetText(sSpaces, oFontSize, FontStyle.Regular, bFontExpanded, Enumerations.TextAlignmentType.Left, false);
                break;

            case Enumerations.TextAlignmentType.Left:
            default:
                break;
            }

            int iItalic    = oFontStyle.ToString().Contains(FontStyle.Italic.ToString()) ? 1 : 0;
            int iUnderline = oFontStyle.ToString().Contains(FontStyle.Underline.ToString()) ? 1 : 0;
            int iExpanded  = bFontExpanded ? 1 : 0;
            int iBold      = oFontStyle.ToString().Contains(FontStyle.Bold.ToString()) ? 1 : 0;

            Commands.Add(new Command("BematechInterface.FormataTX", () => BematechInterface.FormataTX(sText, (int)oFontSize, iItalic, iUnderline, iExpanded, iBold)));

            if (bBreakLine)
            {
                BreakLine(1);
            }
        }
Exemplo n.º 2
0
        private static int AdjustCharactersPerLine(int qntCharactersPerLine, Enumerations.FontSize fontSize)
        {
            switch (fontSize)
            {
            case Enumerations.FontSize.Small:
                qntCharactersPerLine += 17;
                break;

            case Enumerations.FontSize.Large:
                qntCharactersPerLine -= 24;
                break;
            }

            return(qntCharactersPerLine);
        }
Exemplo n.º 3
0
        public static string GetRightAlignmentText(string text, int qntCharactersPerLine, Enumerations.FontSize fontSize)
        {
            if (string.IsNullOrEmpty(text))
            {
                throw new ArgumentException();
            }

            qntCharactersPerLine = AdjustCharactersPerLine(qntCharactersPerLine, fontSize);

            var qntSpaces = qntCharactersPerLine - text.Length;
            var spaces    = new string(' ', qntSpaces);

            return(spaces);
        }