Activate DockWindow by dragging over tabstrip

5 posts, 0 answers
  1. Steffen
    Steffen avatar
    3 posts
    Member since:
    Jul 2012

    Posted 02 May 2013 Link to this post

    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
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 07 May 2013 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. scottw
    scottw avatar
    21 posts
    Member since:
    Oct 2010

    Posted 21 May 2014 in reply to Nikolay Link to this post

    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. 
  5. scottw
    scottw avatar
    21 posts
    Member since:
    Oct 2010

    Posted 21 May 2014 in reply to scottw Link to this post

    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();
  6. George
    Admin
    George avatar
    500 posts

    Posted 26 May 2014 Link to this post

    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.
     
Back to Top
UI for WinForms is Visual Studio 2017 Ready