iTextSharp.text.SpecialSymbol.Index C# (CSharp) Метод

Index() публичный статический Метод

public static Index ( string str ) : int
str string
Результат int
        public static int Index(string str)
        {
            int length = str.Length;
            for (int i = 0; i < length; i++) {
                if (GetCorrespondingSymbol(str[i]) != ' ') {
                    return i;
                }
            }
            return -1;
        }

Usage Example

Пример #1
0
        /**
         * Gets a special kind of Phrase that changes some characters into corresponding symbols.
         * @param leading
         * @param string
         * @param font
         * @return a newly constructed Phrase
         */
        public static Phrase GetInstance(int leading, String str, Font font)
        {
            Phrase p = new Phrase(true);

            p.Leading = leading;
            p.font    = font;
            if (font.Family != Font.FontFamily.SYMBOL && font.Family != Font.FontFamily.ZAPFDINGBATS && font.BaseFont == null)
            {
                int index;
                while ((index = SpecialSymbol.Index(str)) > -1)
                {
                    if (index > 0)
                    {
                        String firstPart = str.Substring(0, index);
                        p.Add(new Chunk(firstPart, font));
                        str = str.Substring(index);
                    }
                    Font          symbol = new Font(Font.FontFamily.SYMBOL, font.Size, font.Style, font.Color);
                    StringBuilder buf    = new StringBuilder();
                    buf.Append(SpecialSymbol.GetCorrespondingSymbol(str[0]));
                    str = str.Substring(1);
                    while (SpecialSymbol.Index(str) == 0)
                    {
                        buf.Append(SpecialSymbol.GetCorrespondingSymbol(str[0]));
                        str = str.Substring(1);
                    }
                    p.Add(new Chunk(buf.ToString(), symbol));
                }
            }
            if (!string.IsNullOrEmpty(str))
            {
                p.Add(new Chunk(str, font));
            }
            return(p);
        }
All Usage Examples Of iTextSharp.text.SpecialSymbol::Index