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

Activate DockWindow by dragging over tabstrip

4 Answers 82 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Steffen
Top achievements
Rank 1
Steffen asked on 02 May 2013, 11:24 AM
Hello,

I would like to activate a dockwindow by dragging something over the tabstrip.

Could this be achieved by a simple property or do I have to code it?

Regards,
Steffen

4 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 07 May 2013, 03:46 PM
Hello Steffen,

RadDock has his own drag and drop mechanisms that determine the drag and drop behavior within the control itself. However, this architecture does not allow for implementing the scenario that you have where something outside RadDock would cause the activation of a window on DragEnter.

Let us know if you have other questions.

Greetings,
Nikolay
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Check out all of the latest highlights.
0
scottw
Top achievements
Rank 1
answered on 21 May 2014, 06:52 PM
Am I to take it that this means it is 100% impossible to do this? Is there any kind of a work around? This doesn't seem like a far-fetched scenario. My scenario is dragging a data item within the application to any one of several open dock windows. I simply want to activate the window (bring it to the front) when the item is dragged over the tab strip item for that window. 
0
scottw
Top achievements
Rank 1
answered on 21 May 2014, 07:11 PM
Actually, I found a work around that seems to work. It involves using the Dock's DockTabStripNeeded and the DockTabStrips's DragOver events. 

Firstly, use DockTabStripNeeded to attach the DragOver event handler to any tab strips created by the dock
void rdMainDock_DockTabStripNeeded(object sender, DockTabStripNeededEventArgs e)
        {
            DockTabStrip strip;
            if (e.DockType == DockType.Document)
                strip = new DocumentTabStrip();
            else
                strip = new ToolTabStrip();

            strip.AllowDrop = true;
            strip.DragOver += DockTabStrip_DragOver;
            e.Strip = strip;
        }

then in the DragOver event, loop through the TabStripItems until you find the one that contains the pointer's X and Y coordinates and find the associated DockWindow by the text property. This assumes that your windows / tabs have unique text.

void DockTabStrip_DragOver(object sender, DragEventArgs e)
        {
            DockTabStrip strip = sender as DockTabStrip;
            if (strip != null)
            {
                foreach(TabStripItem tab in strip.TabStripElement.Items)
                {
                    if (tab.RectangleToScreen(tab.Bounds).Contains(new Point(e.X, e.Y)))
                    {
                        DockWindow dragOverWindow = rdMainDock.DockWindows.FirstOrDefault(w => w.Text == tab.Text);
                        if (dragOverWindow != null && dragOverWindow != rdMainDock.ActiveWindow)
                            rdMainDock.ActivateWindow(dragOverWindow);
                    }
                }
            }
        }

This seems a little hacky, in particular, finding the window based on the text. I'd love to see the Telerik guys provide a better way to do this that's cleaner, but this works and will activate ToolWindows or DockWindows the same.






gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
            gvSelectedFields.GridBehavior = new NoWrapGridBehavior();







gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
            gvSelectedFields.GridBehavior = new NoWrapGridBehavior();






gvAvailableFields.GridBehavior = new NoWrapGridBehavior();
            gvSelectedFields.GridBehavior = new NoWrapGridBehavior();
0
George
Telerik team
answered on 26 May 2014, 01:15 PM
Hello Scott,

Thank you for replying.

I am glad that you have found a way to activate a window according to your requirements, also the solution seems perfectly fine.

Do not hesitate to let us know, should you have any questions.

Regards,
George
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.
 
Tags
Dock
Asked by
Steffen
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
scottw
Top achievements
Rank 1
George
Telerik team
Share this question
or