List of DocumentWindows visible after DocumentWindow drag

4 posts, 1 answers
  1. Paul
    Paul avatar
    7 posts
    Member since:
    Jul 2008

    Posted 07 Aug 2009 Link to this post

    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.
  2. Robert
    Robert avatar
    82 posts
    Member since:
    Jun 2009

    Posted 07 Aug 2009 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Georgi
    Admin
    Georgi avatar
    296 posts

    Posted 10 Aug 2009 Link to this post

    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.
  5. Paul
    Paul avatar
    7 posts
    Member since:
    Jul 2008

    Posted 10 Aug 2009 Link to this post

    Thanks for a reply, that works great =)
Back to Top