我想与内联图像聊天。 RichTextBox的好,因为我可以将图像,但我要发送的文字/图片分开。 -first:发送文本(并将在文本中的图像占位符)。 - 第二:发送图像和占位符代替它。
i want a chat with inline images. The richtextbox good, because i can place images in it, but i want to send the text / images separate. -first: send the text (and place a image-placeholder in the text). -second: send the image and replace it with the placeholder.
有关,我需要删除所有图像RichTextBox的(并把他们分开)。 ,而我怎么能找到图片
For that i need to remove all images in the richtextbox (and send them separate). But how can i find the images?
和BTW:??是否有可能重新调整依赖于RichTextBox的宽度的图片
And btw: Is it possible to rescale the image dependent on the width of the richtextbox?
感谢您:)
推荐答案要找到所有图像在一个RichTextBox,你需要通过所有段和内联遍历;然后,你可以做任何你需要的图片。例如,下面的代码将增加一个RichTextBox内的所有图像的大小(1个像素)。
To find all images in a RichTextBox, you need to traverse through all Paragraphs and its Inlines; and then you can do whatever you need with the image. For example, the following code will increase the size (by 1 pixel) of all images inside a RichTextBox.
public static void ResizeRtbImages(RichTextBox rtb) { foreach (Block block in rtb.Blocks) { if (block is Paragraph) { Paragraph paragraph = (Paragraph)block; foreach (Inline inline in paragraph.Inlines) { if (inline is InlineUIContainer) { InlineUIContainer uiContainer = (InlineUIContainer)inline; if (uiContainer.Child is Image) { Image image = (Image)uiContainer.Child; image.Width = image.ActualWidth + 1; image.Height = image.ActualHeight + 1; } } } } } }更多推荐
C#/ WPF:RichTextBox的:查找所有图片
发布评论