Ejemplo n.º 1
0
        public void Remove(int index, int count = 1)
        {
            if (index + count > builder.Length)
            {
                count = builder.Length - index;
            }
            if (count < 1)
            {
                return;
            }
            int start = index;
            int end   = index + count;

            emojis.RemoveAll((o) => { return(o.pos >= start & o.pos <= end); });
            for (int i = 0; i < emojis.Count; i++)
            {
                if (emojis[i].pos > index)
                {
                    emojis[i].pos -= count;
                }
            }
            builder.Remove(index, count);
            m_str = builder.ToString();
            f_str = EmojiMap.EmojiToFullString(m_str, emojis);
        }
Ejemplo n.º 2
0
        public void Insert(int index, EmojiString emoji)
        {
            if (index > m_str.Length)
            {
                index = m_str.Length;
            }
            var list = emoji.emojis;

            for (int i = 0; i < list.Count; i++)
            {
                list[i].pos += index;
            }
            string str = emoji.FilterString;

            builder.Insert(index, str);
            int l = str.Length;

            for (int i = 0; i < emojis.Count; i++)//将后面的表情符位置往后移
            {
                if (emojis[i].pos >= index)
                {
                    emojis[i].pos += l;
                }
            }
            emojis.AddRange(list);
            emojis.Sort((a, b) => { return(a.pos > b.pos ? 1 : -1); });
            m_str = builder.ToString();
            f_str = EmojiMap.EmojiToFullString(m_str, emojis);
        }
Ejemplo n.º 3
0
 public EmojiString(string str)
 {
     m_str = EmojiMap.CheckEmoji(str, emojis);
     builder.Append(m_str);
     f_str = str;
 }