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

Disable rotating of images

5 Answers 102 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kirk Quinbar
Top achievements
Rank 1
Kirk Quinbar asked on 04 Jan 2012, 02:56 PM
Is there anyway to completely disable rotating of images, or for that matter anything else that would not be supported in html? we are using the richtextbox as an html editor to make nice email templates for our product and dont want the users to be able to do functions that arent available in html.

5 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 06 Jan 2012, 11:40 AM
Hi Kirk,

Thank you for the feedback. We understand the case and you point makes a lot of sense. However currently we do not have option to turn off all HTML unfriendly features. I will add an item in our to-do list for consideration.

One way to solve this specific issue related to rotation of images is to create a custom UI layer builder and remove the AdornerLayer which contains the borders for rotate. The following demo: http://demos.telerik.com/silverlight/#RichTextBox/CustomizePresentation

shows how to make custom UI layers. You need only custom layer builder where you can remove the mentioned layer:

uiLayerContainer.UILayers.Remove(DefaultUILayers.AdornerLayer);

However this would not enough as when selecting a image a Mini toolbar appears, that allows the users to rotate the image.
You need to set the property IsImageMiniToolBarEnabled of the RichTextBox to False in order to disable it.

Disabling this features would also have impact on some other features you might actually need thus we leave to your consideration whether this solution is appropriate for you.

Let us know if we can help further.

All the best,
Martin
the Telerik team

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

0
Kirk Quinbar
Top achievements
Rank 1
answered on 06 Jan 2012, 04:16 PM
would removing that adornerlayer also remove the ability to resize the picture, or is there someway to only remove the rotating part?

Kirk
0
Martin Ivanov
Telerik team
answered on 09 Jan 2012, 05:57 PM
Hi Kirk,

Unfortunately currently there is no way to disable only this specific feature of the layer to rotate the image. However, you can remove the whole layer and add another layer which includes only the logic for resizing the image.
You can download the source code and see how ImageAdornerUI has been implemented, strip the logic for rotating the image and plug the new UI layer as described in this article.
If you need further assistance, do not hesitate to contact us again.

Kind regards,
Martin
the Telerik team

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

0
Brian Peacock
Top achievements
Rank 1
answered on 12 Apr 2012, 08:32 AM
Hi,

Is it possible that you could provide a working example of the rotate switched off?

I have basically copied the source from the ImageAdornerUI, followed the implementation from the DocumentPagePresenter class, have inlcuded a copy of the SelectionUILayer, and yet I'm still not getting the box up on the screen.

If I perform a RegisterInlineSelectionHandler to an object of Nothing (for Image and floating image), then I can see a blue filled box over the actual image (using windows7theme).

As soon as I Register to the copy of ImageAdornerUI then I do not see anything at all - it's as if it is hidden, or the layer is not showing correctly?

Have I done something wrong, can you provide me with any clues?

Cheers
Brian


Protected Overrides Sub BuildUILayersOverride(uiLayerContainer As Telerik.Windows.Documents.UI.IUILayerContainer)
    Dim tmpImg As ImageAdornerUI = Activator.CreateInstance(Of ImageAdornerUI)()
    AddHandler tmpImg.ImageResized, AddressOf adornerUI_ImageResized
    AddHandler tmpImg.ImageRotated, AddressOf adornerUI_ImageRotated
    AddHandler tmpImg.BlockMoved, AddressOf adornerUI_BlockMoved
    tmpImg.HideSelection()
 
    Dim adornerLayer As UIElementsLayer = uiLayerContainer.UILayers.GetLayerByName(DefaultUILayers.AdornerLayer)
 
    If Not IsNothing(adornerLayer) Then
        adornerLayer.AddChild(tmpImg)
    End If
 
    Dim selLayer As New mySelectionUILayer(uiLayerContainer.Owner)
    If Not IsNothing(selLayer) Then
        selLayer.RegisterInlineSelectionHandler(GetType(Telerik.Windows.Documents.Model.ImageInline), tmpImg)
        selLayer.RegisterInlineSelectionHandler(GetType(Telerik.Windows.Documents.Model.FloatingImageBlock), tmpImg)
    End If
 
    Dim x As New List(Of IUILayer)
    For Each layer In uiLayerContainer.UILayers
        If layer.Name = DefaultUILayers.SelectionLayer Then
            x.Add(selLayer)
        ElseIf layer.Name = DefaultUILayers.AdornerLayer Then
            x.Add(adornerLayer)
        Else
            x.Add(layer)
        End If
 
    Next
 
    uiLayerContainer.UILayers.Clear()
 
    For Each layer In x
        uiLayerContainer.UILayers.AddLast(layer)
    Next
0
Vesko
Telerik team
answered on 16 Apr 2012, 09:47 AM
Hello Brian,

As the solution below does not seem very easy to be implemented, we have decided to provide an out of the box setting for enabling/disabling the features of ImageAdornerUI. We will do our best to provide it in some of the upcoming LIBs (Latest Internal Builds) and it also will be included in our next major release Q2.
Hope this helps!

Regards,
Vesko
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
RichTextBox
Asked by
Kirk Quinbar
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Kirk Quinbar
Top achievements
Rank 1
Brian Peacock
Top achievements
Rank 1
Vesko
Telerik team
Share this question
or