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

Copy/Paste Custome Annotations

4 Answers 139 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 07 May 2012, 04:34 PM
I had issues when trying to copy and paste custom annotations, where the first annotation being copied wouldn't copy its properties.
This was answered by Iva the telerik Admin in one of my support tickets, so I thought I would share the code so that others can benefit from it.


Please use this code in your semantic range start class if you need to copy custom annotations (you will need to change Product & Name to whatever suits your custom annotation properties). Leave CopyContentFromOverride empty.

protected override void CopyContentFromOverride(DocumentElement fromElement)
{
}
  
  
  
protected override void CopyPropertiesFromOverride(DocumentElement fromElement)
{
    base.CopyPropertiesFromOverride(fromElement);
 
    //Your properties to copy here
    this.Name = ((SemanticRangeStart)fromElement).Name;
    this.Product = ((SematicRangeStart)fromElement).Product;
}

I hope this helps you as it did me.

Thanks,

Rob

*** Sorry for the typo. The title should be custom not custome ***

4 Answers, 1 is accepted

Sort by
0
Accepted
Iva Toteva
Telerik team
answered on 08 May 2012, 08:22 AM
Hi Rob,

Thank you for sharing this information with the community. We will also make sure to update the documentation accordingly in the next upload (probably later this week).

Kind regards,
Iva Toteva
the Telerik team

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

0
Anselmo
Top achievements
Rank 1
answered on 30 Aug 2012, 03:29 AM
Hi Iva,

I tried to highlight a section which has an annotationmarker (Ive created a custom one named SectionAnnotationStart and SectionAnnotationEnd) and clicked Copy. And I then Paste it to the end of the document, but it doesnt include the annotations as part of the pasted section. Ive implemented the codes below in my SectionAnnotationStart class, but still cant get the AnnotationMarkers from "ClipboardEx.GetDocument();". Am I missing something here?

BTW - this is how I'm intercepting the PasteCommand under CommandExecuting event

            if (e.Command is PasteCommand)
            {
                DocumentFragment fragment = ClipboardEx.GetDocument();
                if (fragment != null)
                {
                    (sender as RadRichTextBox).InsertFragment(fragment);
                    e.Cancel = true;
                }
            }

Thanks,
Selmo
0
Robert
Top achievements
Rank 1
answered on 30 Aug 2012, 03:03 PM
It's a shame you can't upload files on this forum. I would share with you my Annotation Ranges so that you can compare it with yours.


********** EDIT *************

I've uploaded my Custom Annotations to a web server. You can download my annotations by clicking here .

The best file to look at in the folder is called SemanticRangeStart.
0
Iva Toteva
Telerik team
answered on 03 Sep 2012, 07:07 AM
Hello Selmo,

Basically, you should set the IsCopyable property of your custom annotation start and end to true, and implement the copying logic in the CopyPropertiesFromOverride method. You can find more information here. Overriding the CommandExecuting event is not needed, as the copy and paste command use the code from CopyPropertiesFromOverride.

You can also check the custom annotations example that Rob has linked to see how he has implemented them.

Kind regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

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