示例#1
0
 protected TabGroupLeaf RecursiveFindLeafInSequence(TabGroupSequence tgs, TabGroupBase tgb, bool forwards)
 {
     int count = tgs.Count;
     int index = tgs.IndexOf(tgb);
 
     // Are we look for entries after the provided one?
     if (forwards)
     {
         for(int i=index+1; i<count; i++)
         {
             // Is this the needed leaf node?
             if (tgs[i].IsLeaf)
                 return tgs[i] as TabGroupLeaf;
             else
             {
                 TabGroupLeaf leaf = RecursiveFindLeafInSequence(tgs[i] as TabGroupSequence, forwards);
             
                 if (leaf != null)
                     return leaf;
             }
         }
     }
     else
     {
         // Now try each entry before that given
         for(int i=index-1; i>=0; i--)
         {
             // Is this the needed leaf node?
             if (tgs[i].IsLeaf)
                 return tgs[i] as TabGroupLeaf;
             else
             {
                 TabGroupLeaf leaf = RecursiveFindLeafInSequence(tgs[i] as TabGroupSequence, forwards);
             
                 if (leaf != null)
                     return leaf;
             }
         }
     }
                 
     // Still no luck, try our own parent
     if (tgs.Parent != null)
         return RecursiveFindLeafInSequence(tgs.Parent as TabGroupSequence, tgs, forwards);
     else
         return null;
 }
示例#2
0
 protected void MoveActiveInSequence(TabGroupSequence tgs, TabGroupBase child)
 {
     int count = tgs.Count;
     int index = tgs.IndexOf(child);
 
     // First try each entry after that given
     for(int i=index+1; i<count; i++)
     {
         // Is this the needed leaf node?
         if (tgs[i].IsLeaf)
         {
             // Make it active, and finish
             ActiveLeaf = tgs[i] as TabGroupLeaf;
             return;  
         }
         else
         {
             // Need to make a recursive check inside group
             if (RecursiveActiveInSequence(tgs[i] as TabGroupSequence, true))
                 return;
         }
     }
     
     // Now try each entry before that given
     for(int i=index-1; i>=0; i--)
     {
         // Is this the needed leaf node?
         if (tgs[i].IsLeaf)
         {
             // Make it active, and finish
             ActiveLeaf = tgs[i] as TabGroupLeaf;
             return;  
         }
         else
         {
             // Need to make a recursive check inside group
             if (RecursiveActiveInSequence(tgs[i] as TabGroupSequence, false))
                 return;
         }
     }
     
     // Still no luck, try our own parent
     if (tgs.Parent != null)
         MoveActiveInSequence(tgs.Parent as TabGroupSequence, tgs);
 }
        protected void AddGroupToSequence(TabGroupSequence tgs, TabGroupLeaf sourceLeaf, bool before)
        {
            // Remember original auto compact mode
            bool autoCompact = _tabbedGroups.AutoCompact;

            // Turn mode off as it interferes with reorganisation
            _tabbedGroups.AutoCompact = false;

            // Find our index into parent collection
            int pos = tgs.IndexOf(this);

            TabGroupLeaf newGroup = null;

            // New group inserted before existing one?
            if (before)
                newGroup = tgs.InsertNewLeaf(pos);
            else
            {
                // No, are we at the end of the collection?
                if (pos == (tgs.Count - 1))
                    newGroup = tgs.AddNewLeaf();
                else
                    newGroup = tgs.InsertNewLeaf(pos + 1);
            }

            // Get tab control for source leaf
            Controls.TabControl tc = sourceLeaf.GroupControl as Controls.TabControl;

            TabPage tp = tc.SelectedTab;

            // Remove page from ourself
            tc.TabPages.Remove(tp);

            // Add into the new leaf
            newGroup.TabPages.Add(tp);

            // Reset compacting mode as we have updated the structure
            _tabbedGroups.AutoCompact = autoCompact;

            // Do we need to compact?
            if (_tabbedGroups.AutoCompact)
                _tabbedGroups.Compact();
        }