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

xamlformatprovider exclude property

7 Answers 112 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.
Sergey
Top achievements
Rank 1
Sergey asked on 29 Nov 2011, 02:20 PM
I am using InlineUIContainer with a custom control.  It serializes some properties of that control into XAML.  Is there a way to have control over what is serialized via an attribute?
Thanks.

7 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 01 Dec 2011, 12:45 PM
Hi Sergey,

There are no customization options for the way XamlFormatProvider serializes the document.
Could you provide some more details on the customization options you would find convenient in this scenario?
Looking forward to your reply.

All the best,
Iva Toteva
the Telerik team

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

0
Sergey
Top achievements
Rank 1
answered on 01 Dec 2011, 01:13 PM
here is my scneario.  I am using InlineUIContainer with a custom custom control in it, bound to a view model.  By default all properties of a view model will be seriualized, where I want to control which ones are serialized into XAML.

Thank you.
0
Iva Toteva
Telerik team
answered on 06 Dec 2011, 05:09 PM
Hi Sergey,

We will add ExportSettings for XamlFormatProvider, the way it has been done for HtmlFormatProvider, RtfFormatProvider and PdfFormatProvider. More information on the way export settings are used can be found here. We will probably implement the same mechanism which has been implemented for HtmlFormatProvider - introducing an InlineUIContainerExporting event. In this way, it will be possible to handle the event and provide your implementation in place of the default one. 
When the feature is implemented, we will make sure to update the article to include XamlFormatProvider.

Please, let us know if you find this solution appropriate. 

Kind regards,
Iva Toteva
the Telerik team

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

0
Dustin
Top achievements
Rank 1
answered on 27 Feb 2012, 03:26 PM
Currently with the HtmlExportSettings you can exclude FloatingImageBlocks from the exports, but with the PdfExportingSettings you can only exclude the InlineUIContainers. Is there any way to exclude FloatingImageBlocks from PDF exports or is this feature going to be incorporated at some point?
0
Iva Toteva
Telerik team
answered on 01 Mar 2012, 11:33 AM
Hi Dustin,

There is no customization point that prevents the export of FloatingImageBlocks to PDF.

With HtmlFormatProvider, we have provided such settings because it is useful in the cases when you want to export and import images separately and reference them in the HTML using a URI such as a relative path to the image. As HTML is a text-based format, one could implement this functionality in a quite straightforward way.
When it comes to the PdfExportSettings, as you have noticed in the ticket you opened, the InlineUIContainersExportMode setting is not applied, i.e. InlineUIContainers are always exported as images. We will fix this behavior, but providing a customization option for images is not considered at this point. You can, however, remove the images from the document before export. Please, refer to the sample application attached in the ticket, which performs the same operation for InlineUIContainers.

Greetings,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Dustin
Top achievements
Rank 1
answered on 01 Mar 2012, 02:28 PM
But if I remove the Images from the document before exporting then they are removed from the original document and if I make a copy of the document (via export to xaml and then import into a new document that just makes the export process longer which is not an option). If there a way to remove the images without affecting the original or reversing/unding those removals after exporting?
0
Iva Toteva
Telerik team
answered on 06 Mar 2012, 02:46 PM
Hi Dustin,

There are two ways to accomplish the export of the document without the images.

The first one is to create a copy of the document, iterate through it deleting the images and export the result. Using this approach, you can remove the images from the paragraph using the document collection like this:

image.Parent.Children.Remove(image);

The second option is not to create a copy of the document and delete the images in the editor. The time for copying the document will be spared, but you will have to delete the images using the Delete method of RadRichTextBox in order to preserve the history. This can be done like this:
IEnumerable<FloatingImageBlock> floatingImageBlocks = this.AssociatedRichTextBox.Document.EnumerateChildrenOfType<FloatingImageBlock>();
foreach (var imageBlock in floatingImageBlocks)
{
    DocumentPosition start = new DocumentPosition(this.AssociatedRichTextBox.Document);
    DocumentPosition end = new DocumentPosition(this.AssociatedRichTextBox.Document);
 
    InlineLayoutBox inlineLayoutBox = imageBlock.FirstLayoutBox as InlineLayoutBox;
    InlineLayoutBox nextLayoutBox = inlineLayoutBox.AssociatedInline.NextSibling.FirstLayoutBox as InlineLayoutBox;
 
    start.MoveToInline(inlineLayoutBox, 0);
    end.MoveToInline(nextLayoutBox, 0);
 
    this.AssociatedRichTextBox.Document.Selection.SetSelectionStart(start);
    this.AssociatedRichTextBox.Document.Selection.AddSelectionEnd(end);
    this.AssociatedRichTextBox.Delete(false);
    deletedImages++;
}

You can execute this code in a save command you have created and wired the UI to work with. After the export is complete, you can undo the changes:

for (int i = 0; i < deletedImages; i++)
{
    this.AssociatedRichTextBox.Undo();
}

This method for deleting the images is slower because RadRichTextBox creates contexts for the execution of the commands in order to be able to undo and redo the changes to the document. Furthermore, the 

You can choose which method will be more appropriate in your application depending on the size of the documents and the number of floating images that will normally be present in the document. All the best,
Iva Toteva
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
RichTextBox
Asked by
Sergey
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Sergey
Top achievements
Rank 1
Dustin
Top achievements
Rank 1
Share this question
or