Copy/Paste Custome Annotations

5 posts, 1 answers
  1. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 07 May 2012 Link to this post

    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 ***
  2. Answer
    Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 08 May 2012 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Anselmo
    Anselmo  avatar
    5 posts
    Member since:
    Aug 2012

    Posted 29 Aug 2012 Link to this post

    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
  5. Robert
    Robert avatar
    271 posts
    Member since:
    Mar 2011

    Posted 30 Aug 2012 Link to this post

    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.
  6. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 03 Sep 2012 Link to this post

    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.

Back to Top
UI for WPF is Visual Studio 2017 Ready