コード例 #1
0
 public void ReplaceSmileCode(String code, Bitmap bmp)
 {
     if (tb.InvokeRequired)
     {
         ReplaceSmileCodeCB d = new ReplaceSmileCodeCB(ReplaceSmileCode);
         try
         {
             tb.Parent.Invoke(d, new object[] { code, bmp });
         }
         catch { }
     }
     else
     {
         int start = tb.Text.Substring(0).IndexOf(code);
         while (start > 0)
         {
             if (start > 0)
             {
                 tb.SelectionStart  = start;
                 tb.SelectionLength = code.Length;
                 //tb.Cut();
                 tb.InsertImage(bmp);
             }
             start = tb.Text.Substring(0).IndexOf(code);
         }
     }
 }
コード例 #2
0
        private void ReplaceWithSmiley(int _index, string text, Bitmap smiley)
        {
            rtb.Select(_index, text.Length);

            try
            {
                rtb.InsertImage(smiley);
            }
            catch
            {
                smiley.Dispose();
                return;
            }

            int newindex = (_index + text.Length) - 1;

            try
            {
                if ((_index = rtb.Find(text, newindex, RichTextBoxFinds.NoHighlight)) > -1)
                {
                    ReplaceWithSmiley(_index, text, smiley);
                }
            }
            catch {; }

            smiley.Dispose();

            rtb.Select(rtb.Text.Length, 0);
        }
コード例 #3
0
 void AddEmotions(ExRichTextBox richTextBox)
 {
     foreach (string emote in _emotions.Keys)
     {
         while (richTextBox.Text.Contains(emote))
         {
             int ind = richTextBox.Text.IndexOf(emote, StringComparison.Ordinal);
             richTextBox.Select(ind, emote.Length);
             richTextBox.InsertImage((Image)_emotions[emote]);
         }
     }
 }
コード例 #4
0
ファイル: ChatUc.cs プロジェクト: rafeyhusain/InfinityChess
 private void AddEmotionsImages(string text)
 {
     //For Happy Smiley
     if (text.Contains(":)"))
     {
         int _index;
         while ((_index = rtbChat.Find(":)")) > -1)
         {
             rtbChat.Select(_index, ":)".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Happy.png"));
         }
     }
     //For Wink Smiley
     if (text.Contains(";)"))
     {
         int _index;
         while ((_index = rtbChat.Find(";)")) > -1)
         {
             rtbChat.Select(_index, ";)".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Wink.png"));
         }
     }
     //For Sad Smiley
     if (text.Contains(":("))
     {
         int _index;
         while ((_index = rtbChat.Find(":(")) > -1)
         {
             rtbChat.Select(_index, ":(".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Sad.png"));
         }
     }
     //For Angry Smiley
     if (text.Contains(":@"))
     {
         int _index;
         while ((_index = rtbChat.Find(":@")) > -1)
         {
             rtbChat.Select(_index, ":@".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Angry.png"));
         }
     }
     //For Surprised Smiley
     if (text.Contains(":-O") || text.Contains(":-o"))
     {
         int _index;
         while ((_index = rtbChat.Find(":-O")) > -1)
         {
             rtbChat.Select(_index, ":-O".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Suprised.png"));
         }
     }
     //For Kiss Smiley
     if (text.Contains("(K)") || text.Contains("(k)"))
     {
         int _index;
         while ((_index = rtbChat.Find("(K)")) > -1)
         {
             rtbChat.Select(_index, "(K)".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Kiss.png"));
         }
     }
     //For Question Smiley
     if (text.Contains(":?"))
     {
         int _index;
         while ((_index = rtbChat.Find(":?")) > -1)
         {
             rtbChat.Select(_index, ":?".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Question.png"));
         }
     }
     //For Laughing Smiley
     if (text.Contains(":D") || text.Contains(":d"))
     {
         int _index;
         while ((_index = rtbChat.Find(":D")) > -1)
         {
             rtbChat.Select(_index, ":D".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Laughing.png"));
         }
     }
     //For Sleep Smiley
     if (text.Contains(":-)"))
     {
         int _index;
         while ((_index = rtbChat.Find(":-)")) > -1)
         {
             rtbChat.Select(_index, ":-)".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Sleep.png"));
         }
     }
     //For Unfair Smiley
     if (text.Contains(":|"))
     {
         int _index;
         while ((_index = rtbChat.Find(":|")) > -1)
         {
             rtbChat.Select(_index, ":|".Length);
             rtbChat.InsertImage(Image.FromFile(App.Model.Ap.FolderImages + @"smiley\" + "Unfair.png"));
         }
     }
 }