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

List of DocumentWindows visible after DocumentWindow drag

3 Answers 140 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Aug 2009, 12:45 PM
I have two documents in one TabStrip.  I drag one out. Just right after the drag is over I need the information on what Documents (from entire RadDock control) are actually visible (drawn on the screen; not Class-property-wise visible)  and which are hidden beneth the others. This only concerns DocumentWindows.

3 Answers, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 07 Aug 2009, 06:20 PM
Hey Paul,

This probably isn't the most efficient way to accomplish what are you trying to do, but it should be a good workaround for your problem. These two functions do exactly what you need, they return lists of hidden or front(in view) document windows.

List<DocumentWindow> GetFrontDocumentWindows() 
        { 
            List<DocumentWindow> frontWindows = new List<DocumentWindow>(); 
 
            List<DocumentTabStrip> tabStrips = new List<DocumentTabStrip>() ; 
            GetTabStrips(documentContainer1.Controls, tabStrips); 
 
            foreach (DocumentTabStrip tabStrip in tabStrips) 
            { 
                DocumentWindow docWindow = (DocumentWindow)tabStrip.Controls[tabStrip.SelectedIndex]; 
                frontWindows.Add(docWindow); 
                MessageBox.Show(docWindow.Text); 
            } 
 
            return frontWindows; 
        } 
 
        List<DocumentWindow> GetHiddenDocumentWindows() 
        { 
            List<DocumentWindow> hiddenWindows = new List<DocumentWindow>(); 
 
            List<DocumentTabStrip> tabStrips = new List<DocumentTabStrip>(); 
            GetTabStrips(documentContainer1.Controls, tabStrips); 
 
            foreach (DocumentTabStrip tabStrip in tabStrips) 
            { 
                foreach (Control ctrl in tabStrip.Controls) 
                { 
                    DocumentWindow docWindow = ctrl as DocumentWindow; 
 
                    if (docWindow != null && docWindow != tabStrip.Controls[tabStrip.SelectedIndex]) 
                    { 
                        hiddenWindows.Add(docWindow); 
                        MessageBox.Show(docWindow.Text); 
                    } 
                } 
            } 
 
            return hiddenWindows; 
        } 
 
        void GetTabStrips(Control.ControlCollection controls, List<DocumentTabStrip> tabStrips) 
        { 
            foreach (Control ctrl in controls) 
            { 
                if (ctrl.Controls.Count > 0) 
                    GetTabStrips(ctrl.Controls, tabStrips); 
 
                if (ctrl is DocumentTabStrip) 
                    tabStrips.Add((DocumentTabStrip)ctrl); 
            } 
        } 

I hope this helps.

- Robert
0
Accepted
Georgi
Telerik team
answered on 10 Aug 2009, 09:15 AM
Hi Robert,

Thank you for your input, this is one way to get all currently visible (displayed) windows. There is another simpler one. RadDock uses a helper class since Q2 2009 SP1 - DocumentManager - which track all documents in the docking framework (a document is either a DocumentWindow or a ToolWindow whose DockState is TabbedDocument). So, you may use the DocumentManager functionality:

private List<DockWindow> GetDisplayedDocuments()  
{  
    List<DockWindow> documents = new List<DockWindow>();  
    foreach (DockWindow window in this.radDock1.DocumentManager.DocumentEnumerator)  
    {  
        DockTabStrip parentStrip = window.DockTabStrip;  
        //check whether the window is currently displayed  
        if (parentStrip != null && window == parentStrip.ActiveWindow)  
        {  
            documents.Add(window);  
        }  
    }  
 
    return documents;  

Greetings,
Georgi
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Paul
Top achievements
Rank 1
answered on 10 Aug 2009, 11:29 AM
Thanks for a reply, that works great =)
Tags
Dock
Asked by
Paul
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Georgi
Telerik team
Paul
Top achievements
Rank 1
Share this question
or