Esempio n. 1
0
        public DisplayBuilder WithSecondaryRichText(string text, FontSizeEnum fontSize)
        {
            Guard.NullRequired(template.TextContent.SecondaryText, "SecondaryText already used");
            var formated = FontSize.GetText(fontSize, text);

            template.TextContent.SecondaryText = new TextField()
            {
                Type = TextField.TextTypeEnum.RichText, Text = formated
            };
            return(this);
        }
        /// <summary>
        /// 字体大小
        /// </summary>
        /// <returns></returns>
        public static byte[] FontSize(FontSizeEnum fontsize)
        {
            byte[] cmdData = new byte[4];

            //放大
            cmdData[0] = 0x1d;
            cmdData[1] = 0x21;

            switch (fontsize)
            {
            case FontSizeEnum.Normal:
                cmdData[2] = 0x00;
                break;

            case FontSizeEnum.Size16:
                cmdData[2] = 0x11;
                break;

            case FontSizeEnum.Size32:
                cmdData[2] = 0x22;
                break;
            }
            return(cmdData);
        }
        internal void ChangeFontSize(FontSizeEnum fontSizeEnum)
        {
            foreach (string f in StyleFiles)
            {
                StringBuilder newFile = new StringBuilder();
                string temp = "";
                string[] fileAsString = File.ReadAllLines(f);
                bool searchingForFontSize = false;

                foreach (string fileLine in fileAsString)
                {
                    if (searchingForFontSize && this.FontSizeRegex.IsMatch(fileLine) && !fileLine.Contains(this.Osx))
                    {
                        temp = FontSizeRegex.Replace(fileLine, ((int)fontSizeEnum).ToString(), 1);
                        newFile.AppendLine(temp);
                        searchingForFontSize = false;
                    }
                    else if (StylesInfo.Steam.FontSizes.Any(s => fileLine.Contains(s.Name)))
                    {
                        searchingForFontSize = true;
                        newFile.AppendLine(fileLine);
                    }
                    else
                    {
                        newFile.AppendLine(fileLine);
                    }
                }

                File.WriteAllText(f, newFile.ToString());
            }

            this.PopulateStylesInfo();

            if (this.Verbose == true)
                Console.WriteLine();
        }
Esempio n. 4
0
 public static string GetText(FontSizeEnum fontSize, string text)
 {
     return(string.Format(FormatString, (int)fontSize, text));
 }