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

Disable Docking option

5 Answers 197 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Roy
Top achievements
Rank 1
Roy asked on 29 Sep 2013, 03:04 PM
Hi,
How should i disable the docking option in radDock control?

example image attached.

5 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 02 Oct 2013, 02:31 PM
Hello Roy,

Thank you for contacting us.

You can disable the docking option in RadDock by canceling the corresponding transaction. You can subscribe to the TransactionCommitting event of the RadDock:
this.radDock.TransactionCommitting += radDock_TransactionCommitting;

Then in the event handler you can cancel the DragDrop and Float transaction types:
void radDock_TransactionCommitting(object sender, RadDockTransactionCancelEventArgs e)
{
    if (e.Transaction.TransactionType ==  DockTransactionType.DragDrop || e.Transaction.TransactionType ==  DockTransactionType.Float)
    {
        e.Cancel = true;
    }
}

I hope this information is helpful.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Roy
Top achievements
Rank 1
answered on 02 Oct 2013, 06:19 PM
Thanks,
its working great,  but i was wondering if there any option to disable even the arrows of dock when you're trying to drag the tab.
( exactly as in image )

Best regards,
Roy
0
Accepted
George
Telerik team
answered on 07 Oct 2013, 10:52 AM
Hi Roy,

Thank you for writing back.

In this case you would have to create a custom DragDropService. Below you can find the implementation of the class:
public class MyDragDropService : DragDropService
{
    public bool ShouldShowGuides { get; set; }
 
    protected override void Drag(Point mousePos)
    {
        if (this.ShouldShowGuides)
        {
            base.Drag(mousePos);
        }
        else
        {
            this.DragWithoutDockHint(mousePos);
            this.GetMethod("HideGuides").Invoke(this, null);
        }
    }
 
    protected virtual void DragWithoutDockHint(Point mousePos)
    {
        if (this.DragDropBehavior == DragDropBehavior.Auto && NativeMethods.GetCapture() == null)
        {
            this.Stop(false);
            return;
        }
 
        FieldInfo currMouse = this.GetField("currMouse");
        currMouse.SetValue(this, mousePos);
        FieldInfo prevMouse = this.GetField("prevMouse");
 
        if (this.DragDropBehavior == DragDropBehavior.Auto && ((Point)currMouse.GetValue(this)) == ((Point)prevMouse.GetValue(this)))
        {
            return;
        }
 
        prevMouse.SetValue(this, currMouse.GetValue(this));
        FieldInfo draggedWindow = this.GetField("draggedWindow");
 
        if (draggedWindow.GetValue(this) != null)
        {
            ((FloatingWindow)draggedWindow.GetValue(this)).BringToFront();
        }
 
        FieldInfo dropAnchor = this.GetField("dropAnchor");
        SplitPanel dropTarget = this.GetDropTarget();
        dropAnchor.SetValue(this, dropTarget);
 
        FieldInfo dragContext = this.GetField("dragContext");
 
        if (((DragDropContext)dragContext.GetValue(this)) == DragDropContext.DocumentWindow)
        {
            this.GetMethod("UpdateDocumentCursor").Invoke(this, null);
        }
 
        FieldInfo guideHitTest = this.GetField("guideHitTest");
 
        //we are not above a docking guide, move the dragged object
        if (((DockingGuideHitTest)guideHitTest.GetValue(this)) == DockingGuideHitTest.Empty)
        {
            this.GetMethod("MoveDraggedObject").Invoke(this, null);
        }
 
        //raise the Dragging event and check whether we may continue the operation.
        CancelEventArgs args = new CancelEventArgs();
        this.OnDragging(args);
        if (args.Cancel)
        {
            this.Stop(false);
        }
    }
 
    private FieldInfo GetField(string field)
    {
        return this.GetType().BaseType.GetField(field, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
    }
 
    private MethodInfo GetMethod(string method)
    {
        return this.GetType().BaseType.GetMethod(method, BindingFlags.Instance | BindingFlags.NonPublic);
    }
}

The service can be registered as follows:
this.radDock.RegisterService(1, new MyDragDropService());

Let me know if I can be of further assistance.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Roy
Top achievements
Rank 1
answered on 07 Oct 2013, 10:59 AM
Thank you!   its works like a magic.
0
George
Telerik team
answered on 07 Oct 2013, 11:21 AM
Hi Roy,

I am writing you again to let you know that we consider this as a reasonable feature request. That is why I created a new item in our Public Issue Tracking System. You can find it at http://www.telerik.com/support/pits.aspx#/public/winforms/15890.

I have also updated your Telerik Points for the contribution.

Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
Dock
Asked by
Roy
Top achievements
Rank 1
Answers by
George
Telerik team
Roy
Top achievements
Rank 1
Share this question
or