Example #1
0
        /// <summary>
        /// 获取Box中的所有内容。
        /// </summary>
        /// <param name="containsForeignObject">内容中是否包含不是由IImagePathGetter管理的图片对象</param>
        /// <returns>key为位置,val为图片的ID</returns>
        public ChatBoxContent GetContent()
        {
            ChatBoxContent  content = new ChatBoxContent(this.Text, this.Font, this.ForeColor);
            List <REOBJECT> list    = this.RichEditOle.GetAllREOBJECT();

            for (int i = 0; i < list.Count; i++)
            {
                uint pos = (uint)list[i].posistion;
                content.PicturePositions.Add(pos);
                if (list[i].dwUser != 10000)
                {
                    content.AddEmotion(pos, list[i].dwUser);
                }
                else
                {
                    GifBox box = (GifBox)Marshal.GetObjectForIUnknown(list[i].poleobj);
                    content.AddForeignImage(pos, box.Image);
                }
            }

            return(content);
        }
Example #2
0
        public void AppendChatBoxContent(ChatBoxContent content)
        {
            try
            {
                if (content == null || content.Text == null)
                {
                    return;
                }

                int count = this.Text.Length;
                if (content.EmotionDictionary != null)
                {
                    string pureText = content.Text;
                    //去掉表情和图片的占位符
                    List <uint> emotionPosList = new List <uint>(content.EmotionDictionary.Keys);
                    List <uint> tempList       = new List <uint>();
                    tempList.AddRange(emotionPosList);
                    foreach (uint key in content.ForeignImageDictionary.Keys)
                    {
                        tempList.Add(key);
                    }
                    tempList.Sort();

                    for (int i = tempList.Count - 1; i >= 0; i--)
                    {
                        pureText = pureText.Remove((int)tempList[i], 1);
                    }
                    this.AppendText(pureText);
                    //插入表情
                    for (int i = 0; i < tempList.Count; i++)
                    {
                        uint position = tempList[i];
                        if (emotionPosList.Contains(position))
                        {
                            this.InsertDefaultEmotion(content.EmotionDictionary[position], (int)(count + position));
                        }
                        else
                        {
                            this.InsertImage(content.ForeignImageDictionary[position], (int)(count + position));
                        }
                    }
                }
                else
                {
                    this.AppendText(content.Text);
                }

                this.Select(count, content.Text.Length);
                if (content.Color != null)
                {
                    this.SelectionColor = content.Color;
                }
                if (content.Font != null)
                {
                    this.SelectionFont = content.Font;
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }
Example #3
0
        /// <summary>
        /// 获取Box中的所有内容。
        /// </summary>        
        /// <param name="containsForeignObject">内容中是否包含不是由IImagePathGetter管理的图片对象</param>
        /// <returns>key为位置,val为图片的ID</returns>
        public ChatBoxContent GetContent()
        {
            ChatBoxContent content = new ChatBoxContent(this.Text ,this.Font,this.ForeColor);
            List<REOBJECT> list = this.RichEditOle.GetAllREOBJECT();
            for (int i = 0; i < list.Count; i++)
            {
                uint pos = (uint)list[i].posistion ;
                content.PicturePositions.Add(pos) ;
                if (list[i].dwUser != 10000)
                {
                    content.AddEmotion(pos, list[i].dwUser);
                }
                else
                {
                    GifBox box = (GifBox)Marshal.GetObjectForIUnknown(list[i].poleobj);
                    content.AddForeignImage(pos, box.Image);
                }
            }

            return content;
        }
Example #4
0
        public void AppendChatBoxContent(ChatBoxContent content)
        {
            try
            {
                if (content == null || content.Text == null)
                {
                    return;
                }

                int count = this.Text.Length;
                if (content.EmotionDictionary != null)
                {
                    string pureText = content.Text;
                    //去掉表情和图片的占位符
                    List<uint> emotionPosList = new List<uint>(content.EmotionDictionary.Keys);
                    List<uint> tempList = new List<uint>();
                    tempList.AddRange(emotionPosList);
                    foreach (uint key in content.ForeignImageDictionary.Keys)
                    {
                        tempList.Add(key);
                    }
                    tempList.Sort();

                    for (int i = tempList.Count - 1; i >= 0; i--)
                    {
                        pureText = pureText.Remove((int)tempList[i], 1);
                    }
                    this.AppendText(pureText);
                    //插入表情
                    for (int i = 0; i < tempList.Count; i++)
                    {
                        uint position = tempList[i];
                        if (emotionPosList.Contains(position))
                        {
                            this.InsertDefaultEmotion(content.EmotionDictionary[position], (int)(count + position));
                        }
                        else
                        {
                            this.InsertImage(content.ForeignImageDictionary[position], (int)(count + position));
                        }
                    }
                }
                else
                {
                    this.AppendText(content.Text);
                }

                this.Select(count, content.Text.Length);
                if (content.Color != null)
                {
                    this.SelectionColor = content.Color;
                }
                if (content.Font != null)
                {
                    this.SelectionFont = content.Font;
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
        }