Example #1
0
        /// <summary>
        /// AppendRichText 在现有内容后面追加富文本。
        /// </summary>
        /// <param name="textContent">文本内容</param>
        /// <param name="imagePosition_imageID">图片在textContent中的位置以及图片的ID</param>
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Font font, Color color)
        {
            int count = this.Text.Length; //.TextLength

            if (imagePosition_imageID != null)
            {
                string     temp    = textContent;
                List <int> posList = imagePosition_imageID.GetAllKeyList();
                for (int i = posList.Count - 1; i >= 0; i--)
                {
                    temp = temp.Remove(posList[i], 1);
                }
                this.AppendText(temp);

                for (int i = 0; i < posList.Count; i++)
                {
                    int position = posList[i];
                    this.InsertImage(imagePosition_imageID[position], count + position);
                }
            }
            else
            {
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        }
Example #2
0
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Font font, Color color)
        {
            int length = this.Text.Length;

            if (imagePosition_imageID != null)
            {
                int        num2;
                string     text       = textContent;
                List <int> allKeyList = imagePosition_imageID.GetAllKeyList();
                for (num2 = allKeyList.Count - 1; num2 >= 0; num2--)
                {
                    text = text.Remove(allKeyList[num2], 1);
                }
                base.AppendText(text);
                for (num2 = 0; num2 < allKeyList.Count; num2++)
                {
                    int num3 = allKeyList[num2];
                    this.InsertImage(imagePosition_imageID[num3], length + num3);
                }
            }
            else
            {
                base.AppendText(textContent);
            }
            base.Select(length, textContent.Length);
            base.SelectionColor = color;
            if (font != null)
            {
                base.SelectionFont = font;
            }
        }
Example #3
0
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Dictionary <int, Image> foreignObjectAry, Font font, Color color)
        {
            int count = this.Text.Length; //.TextLength

            if (imagePosition_imageID != null)
            {
                string pureText = textContent;
                //去掉表情和图片的占位符
                List <int> posList = imagePosition_imageID.GetAllKeyList();
                // List<int> foreignPosList = foreignObjectAry.Keys();

                List <int> tempList = new List <int>();
                tempList.AddRange(posList);
                foreach (int key in foreignObjectAry.Keys)
                {
                    tempList.Add(key);
                }

                tempList.Sort();

                for (int i = tempList.Count - 1; i >= 0; i--)
                {
                    pureText = pureText.Remove(tempList[i], 1);
                }
                this.AppendText(pureText);
                //插入表情
                for (int i = 0; i < tempList.Count; i++)
                {
                    int position = tempList[i];
                    if (posList.Contains(position))
                    {
                        this.InsertImage(imagePosition_imageID[position], count + position);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[position], count + position);
                    }
                }
            }
            else
            {
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        }
Example #4
0
        public void AppendRichText(string textContent, SortedArray <int, uint> imagePosition_imageID, Dictionary <int, Image> foreignObjectAry, Font font, Color color)
        {
            int length = this.Text.Length;

            if (imagePosition_imageID != null)
            {
                int        num3;
                string     text       = textContent;
                List <int> allKeyList = imagePosition_imageID.GetAllKeyList();
                List <int> list2      = new List <int>();
                list2.AddRange(allKeyList);
                foreach (int num2 in foreignObjectAry.Keys)
                {
                    list2.Add(num2);
                }
                list2.Sort();
                for (num3 = list2.Count - 1; num3 >= 0; num3--)
                {
                    text = text.Remove(list2[num3], 1);
                }
                base.AppendText(text);
                for (num3 = 0; num3 < list2.Count; num3++)
                {
                    int item = list2[num3];
                    if (allKeyList.Contains(item))
                    {
                        this.InsertImage(imagePosition_imageID[item], length + item);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[item], length + item);
                    }
                }
            }
            else
            {
                base.AppendText(textContent);
            }
            base.Select(length, textContent.Length);
            base.SelectionColor = color;
            if (font != null)
            {
                base.SelectionFont = font;
            }
        }
        public void AppendRichText(string textContent, SortedArray<int, uint> imagePosition_imageID, Dictionary<int, Image> foreignObjectAry, Font font, Color color)
        {
            int count = this.Text.Length; //.TextLength
            if (imagePosition_imageID != null)
            {
                string pureText = textContent;
                //去掉表情和图片的占位符
                List<int> posList = imagePosition_imageID.GetAllKeyList();
               // List<int> foreignPosList = foreignObjectAry.Keys();

                List<int> tempList = new List<int>();
                tempList.AddRange(posList);
                foreach (int key in foreignObjectAry.Keys)
                {
                    tempList.Add(key);
                }
               
                tempList.Sort();

                for (int i = tempList.Count - 1; i >= 0; i--)
                {
                    pureText = pureText.Remove(tempList[i], 1);
                }
                this.AppendText(pureText);
                //插入表情
                for (int i = 0; i < tempList.Count; i++)
                {
                    int position = tempList[i];
                    if (posList.Contains(position))
                    {
                        this.InsertImage(imagePosition_imageID[position], count + position);
                    }
                    else
                    {
                        this.InsertImage(foreignObjectAry[position], count + position);
                    }
                }
            }
            else
            {
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        } 
        /// <summary>
        /// AppendRichText 在现有内容后面追加富文本。
        /// </summary>
        /// <param name="textContent">文本内容</param>
        /// <param name="imagePosition_imageID">图片在textContent中的位置以及图片的ID</param>
        public void AppendRichText(string textContent, SortedArray<int, uint> imagePosition_imageID ,Font font ,Color color)
        {
            int count = this.Text.Length; //.TextLength
            if (imagePosition_imageID != null)
            {               
                string temp = textContent;
                List<int> posList = imagePosition_imageID.GetAllKeyList();
                for (int i = posList.Count - 1; i >= 0; i--)
                {
                    temp = temp.Remove(posList[i], 1);
                }
                this.AppendText(temp);

                for (int i = 0; i < posList.Count; i++)
                {
                    int position = posList[i];
                    this.InsertImage(imagePosition_imageID[position], count + position);
                }
            }
            else
            {                
                this.AppendText(textContent);
            }

            this.Select(count, textContent.Length);
            if (color != null)
            {
                this.SelectionColor = color;
            }
            if (font != null)
            {
                this.SelectionFont = font;
            }
        }