InsertCustomAnnotationRange

6 posts, 0 answers
  1. Anand
    Anand avatar
    30 posts
    Member since:
    Jul 2014

    Posted 06 Aug 2014 Link to this post

    How  can I add an custom annotation in the Header and footer ? Is there a way to do it ?

    Document.CaretPosition doesnt get the Header position. I dont find any move functions to move in to the Header as well ?.

    I added custom annotation on the document as below :

    Document.InsertCustomAnnotationRange(position, position, new RangeStart(id),  new RangeEnd());

    Didn't find any functions to add custom annotations in the Header or move in to the Header  ? Could you help me in this please ?

    Thanks
    Anand

  2. Anand
    Anand avatar
    30 posts
    Member since:
    Jul 2014

    Posted 07 Aug 2014 in reply to Anand Link to this post

    Hi All, 
    I worked out my way to get the Headers and footers as below.Document.section[0].Headers.Default.Body

    But weirdly, in Header, I found always the cursor position points to the starting first word of the Header. It doesnt seems to get updated even when I move the cursor around. 
    I get the cursor by Document.section[0].Headers.First.Body.CaretPosition

    Not sure am I missing something ?


  3. UI for WPF is Visual Studio 2017 Ready
  4. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 08 Aug 2014 Link to this post

    Hello Anand,

     When you work with headers, footers or comments you need to use the ActiveDocumentEditor of RadRichTextBox in order to manipulate the correct part of the document.
    Here is how you can get the correct caret position:
    DocumentPosition carretPosition = this.radRichTextBox.ActiveDocumentEditor.Document.CaretPosition;

    I would also suggest you to use the InsertAnnotationRange of ActiveDocumentEditor, which will insert the start and end annotations in the start and end position of the selection of ActiveDocumentEditor.Document. Here is example on how to do it:
    this.radRichTextBox.FocusHeader();
     
    this.radRichTextBox.ActiveDocumentEditor.Document.Selection.AddSelectionStart(startPosition);
    this.radRichTextBox.ActiveDocumentEditor.Document.Selection.AddSelectionEnd(endPosition);
    this.radRichTextBox.ActiveDocumentEditor.InsertAnnotationRange(annotationStart, annotationEnd);
     
    this.radRichTextBox.ActiveDocumentEditor.Document.Selection.Clear();


    I hope this information answer your question. In case you have additional questions feel free to contact us again.

    Regards,
    Mihail
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  5. Anand
    Anand avatar
    30 posts
    Member since:
    Jul 2014

    Posted 13 Aug 2014 in reply to Mihail Link to this post

    Hi Mihail,
    Thanks for the reply. Yes , this way I could get the current cursor position in the document ,across the Headers and Footers.
    But I couldn't work out a way whether the active document (this.radRichTextBox.ActiveDocumentEditor.Document) is the Header or Footer ?
    I am in a scenario, where I dont want to do few operations when I am on footer. Could you help me in finding the active document that I am in is a Header or Footer ? 

    Thanks 
    Anand






  6. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 18 Aug 2014 Link to this post

    Hello Anand,

     In order to determine what will be edited with the ActiveDocumentEditor you could subscribe to the RadRichTextBox.ActiveDocumentEditorChanged event. The argument of this event ActiveDocumentEditorChangedEventArgs contains the property DocumentEditorType, which specifies the part of the edited document: Header, Footer, Comment etc.

    Here is example: 
    private void RadRichTextBox_ActiveDocumentEditorChanged(object sender, ActiveDocumentEditorChangedEventArgs e)
    {
        if (e.DocumentEditorType == DocumentEditorType.Header)
        {
            MessageBox.Show("In Header");
        }
        else if (e.DocumentEditorType == DocumentEditorType.Footer)
        {
            MessageBox.Show("In Footer");
        }
    }

    I hope this information answer your question.

    Regards,
    Mihail
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  7. Anand
    Anand avatar
    30 posts
    Member since:
    Jul 2014

    Posted 19 Aug 2014 in reply to Mihail Link to this post

    Hi Mihail, 

    Thanks for the reply. That works fine and I found another way of getting it.
    var presenter = (IDocumentEditorPresenterContainer)this.radRichTextBox;
    presenter.HeaderFooterUIContext.IsHeaderFocused

    Regards
    A





Back to Top
UI for WPF is Visual Studio 2017 Ready