Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. Image img = Image.FromFile("is_smile.png");
  2. Clipboard.Clear();
  3. Clipboard.SetImage(img);
  4. richTextBox1.Paste();
  5. Clipboard.Clear();
  6.  
  7. Image img = Image.FromFile(@"is_smile.png");
  8. Clipboard.SetDataObject(img);
  9. DataFormats.Format dataFormat =
  10. DataFormats.GetFormat(DataFormats.Bitmap);
  11. if (richTextBox1.CanPaste(dataFormat))
  12. {
  13. richTextBox1.Paste(dataFormat);
  14. }
  15.  
  16. Bitmap myBitmap = new Bitmap(Properties.Resources.is_smile);
  17. Clipboard.SetDataObject(myBitmap);
  18. DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);
  19. richTextBox1.Paste(myFormat);
  20.  
  21. Hashtable emotions;
  22.  
  23. void CreateEmotions()
  24. {
  25. emotions = new Hashtable(2);
  26. emotions.Add(":-)", Properties.Resources.is_smile);
  27. emotions.Add(":)", Properties.Resources.is_smile);
  28. }
  29.  
  30. void AddEmotions()
  31. {
  32. foreach (string emote in emotions.Keys)
  33. {
  34. while (richTextBox1.Text.Contains(emote))
  35. {
  36. int ind = richTextBox1.Text.IndexOf(emote);
  37. richTextBox1.Select(ind, emote.Length);
  38. Clipboard.SetImage((Image)emotions[emote]);
  39. richTextBox1.Paste();
  40. }
  41. }
  42. }
  43.  
  44. private void richTextBox1_TextChanged_1(object sender, EventArgs e)
  45. {
  46. AddEmotions();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement