我看到的大多数例子都说要把它放在剪贴板上并使用粘贴,但这似乎不是很好,因为它会覆盖剪贴板.
我确实看到一种方法,使用pinvoke手动将图像放入RTF,将图像转换为wmf.这是最好的方法吗?我还能做更直接的事吗?
在RichtTextBox中,我想用表情:D
符号图像自动替换表情符号字符串(例如).我到目前为止工作,除了当我在现有的单词/字符串之间写出表情符号字符串时,图像会在行尾插入.
例如:
hello (inserting :D here) this is a message
结果:
hello this is a message ?
<< image
另一个(微小的)问题是插入后的插入位置在插入之前设置.
这就是我已经得到的:
public class Emoticon
{
public Emoticon(string key, Bitmap bitmap)
{
Key = key;
Bitmap = bitmap;
BitmapImage = bitmap.ToBitmapImage();
}
public string Key { get; }
public Bitmap Bitmap { get; }
public BitmapImage BitmapImage { get; }
}
public class EmoticonRichTextBox : RichTextBox
{
private readonly List<Emoticon> _emoticons;
public EmoticonRichTextBox()
{
_emoticons = new List<Emoticon>
{ …
Run Code Online (Sandbox Code Playgroud)