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

Moving Image

7 Answers 117 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Alex Harris
Top achievements
Rank 1
Alex Harris asked on 17 Aug 2010, 09:42 AM
Is there any way after inserting an image into a document I can drag and drop it anywhere within the document?  I am looking at the richtextbox demo and I see you can insert images to where the cursor is, but once an image is there all you can do is resize it and not move it around.

Thanks,

Alex

7 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 18 Aug 2010, 09:03 AM
Hello Alex Harris,

This feature - moving selected text and image around in a document is planed for the next version (Q3 2010).  In the meanwhile you can use cut/paste to move the images/text within the document. Let us know if you have other questions.

Best wishes,
Mike
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex Harris
Top achievements
Rank 1
answered on 18 Aug 2010, 09:41 AM
I seem to be having a problem with the Drop event handler not firing when I am dropping something onto the richtexteditor control.

Thanks,

Alex
0
Alex
Telerik team
answered on 19 Aug 2010, 02:23 PM
Hello Alex Harris,

If you want the Drop event to be fired you will have to set the AllowDrop property of the RadRichTextBox ( actually it is a property of UIElement) to true.
Please let us know if this solves your problem.

All the best,
Alex
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex Harris
Top achievements
Rank 1
answered on 19 Aug 2010, 02:51 PM
You are correct I did forget to put that tag on there!  Is there a way to determine where I placed the image?  Can I set the cursor position based off of the mouse position while dragging the image?

Thank you for all your help,

Alex
0
Alex
Telerik team
answered on 24 Aug 2010, 09:15 AM
Hi Alex Harris,

Currently there is no easy way to get DocumentPosition from mouse position in RadRichTextBox and vice versa. We are now developing the API to support this and it is planned to be available in the next LIB.
Feel free to get back to us if you have more questions.

Greetings,
Alex
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Alex Harris
Top achievements
Rank 1
answered on 24 Aug 2010, 09:28 AM
Is there any sort of hack I can do?  The code doesn't have to be pretty as long as I can move an image around.  Is there an date for this functionality will be available?

Thanks,

Alex
0
Alex
Telerik team
answered on 26 Aug 2010, 11:32 AM
Hi Alex Harris,

Any hackish workaround will be highly unstable and thus not recommended. The good news is that we extended the API by adding GetDocumentPositionFromViewPoint and GetViewPointFromDocumentPosition methods to the IDocumentEditorPresenter interface (available trough ActiveEditorPresenter property of the RadRichTextBox). These changes will be available in the LIB at the end of this week.

Here is how the new methods can be used to implement the desired drag&drop behavior:

private void editor_Drop(object sender, DragEventArgs e)
{
    FileInfo[] droppedFiles = e.Data.GetData(DataFormats.FileDrop) as FileInfo[];
 
    foreach (FileInfo droppedFile in droppedFiles)
    {
        if (this.IsSupportedImageFormat(droppedFile.Extension))
        {
            using (Stream imageStream = droppedFile.OpenRead())
            {
                this.editor.InsertImage(imageStream, droppedFile.Extension);
            }
        }
    }
}
 
private void editor_DragOver(object sender, DragEventArgs e)
{
    Point viewPoint = e.GetPosition(this.editor);
 
    DocumentPosition documentPosition = this.editor.ActiveEditorPresenter.GetDocumentPositionFromViewPoint(viewPoint);
 
    this.editor.Document.CaretPosition.MoveToPosition(documentPosition);
    this.editor.ActiveEditorPresenter.ShowCaret();
}

I hope this was useful. Any additional feedback is appreciated.

All the best,
Alex
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Alex Harris
Top achievements
Rank 1
Answers by
Mike
Telerik team
Alex Harris
Top achievements
Rank 1
Alex
Telerik team
Share this question
or