This is a migrated thread and some comments may be shown as answers.

[Solved] Changing structure of RadRichTextBox programatically

1 Answer 128 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
edward
Top achievements
Rank 1
edward asked on 01 Aug 2011, 11:22 AM
Hello, I am having the following problem:

i need to use an image from web, but my application is not considered trusted, so I am insert the image the following way:

BitmapImage bitmapImage = new BitmapImage(new Uri(imageFile, UriKind.Absolute));
 
           Image image = new Image()
           {
               Source = bitmapImage,
               Width = bitmapImage.PixelWidth,
               Height = bitmapImage.PixelHeight,
           };
 
           Telerik.Windows.Documents.Model.InlineUIContainer imageContainer =
               new Telerik.Windows.Documents.Model.InlineUIContainer(image,
                   new Size(150, 150));

But after that I have to save the contents in a database to recover later on, but I need to keep just a reference from the location where it is stored (http://www.foo.bar/image.png). So I have a idea: When I click to save I want to pick the contents of RadRichTextBox and where there is a ImageInline replace it by the "raw" URL (http://www.foo.bar/image.png) and to do the reverse process when I load the contents from database.

Do you have a snippet of code that could help me with this task? Or another suggestion?

Thanks beforehand. I am looking forward to an answer.

1 Answer, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 04 Aug 2011, 09:19 AM
Hi Edward,

If you insert the images as in your code-snippet, they will not be regarded as ImageInline objects, but as Image objects embedded in InlineUIContainers.
You did not mention in what format you are preserving the contents of your document, but if it is HTML, you can make use of the export settings and the import settings of the provider to implement the serialization and deserialization the way you wish to have it. More information on the use of Import and ExportSettings with the format providers can be found here.

Best wishes,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Tags
RichTextBox
Asked by
edward
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Share this question
or