Exemple #1
0
 public Target(Rectangle hotRect, Rectangle drawRect, TabGroupLeaf leaf, TargetActions action)
 {
     // Define state
     _hotRect = hotRect;
     _drawRect = drawRect;
     _leaf = leaf;
     _action = action;
 }
 public TGCloseRequestEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp)
 {
     // Definie initial state
     _tgl = tgl;
     _tc = tc;
     _tp = tp;
     _cancel = false;
 }
        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();
        }
        internal void NewVerticalGroup(TabGroupLeaf sourceLeaf, bool before)
        {
            TabGroupSequence tgs = this.Parent as TabGroupSequence;

            // We must have a parent sequence!
            if (tgs != null)
            {
                tgs.Direction = Direction.Vertical;
                AddGroupToSequence(tgs, sourceLeaf, before);
            }
        }
        internal void MovePageToLeaf(TabGroupLeaf leaf)
        {
            // Remember original auto compact mode
            bool autoCompact = _tabbedGroups.AutoCompact;

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

            // Get the requested tab page to be moved to new leaf
            TabPage tp = _tabControl.SelectedTab;

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

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

            // Make new leaf the active one
            _tabbedGroups.ActiveLeaf = leaf;

            TabControl tc = leaf.GroupControl as Controls.TabControl;

            // Select the newly added page
            tc.SelectedTab = tp;

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

            // Do we need to compact?
            if (_tabbedGroups.AutoCompact)
                _tabbedGroups.Compact();
        }
Exemple #6
0
	    public TargetManager(TabbedGroups host, TabGroupLeaf leaf, Controls.TabControl source)
	    {
	        // Define state
	        _host = host;
	        _leaf = leaf;
	        _source = source;
	        _lastTarget = null;
	    
	        // Create collection to hold generated targets
	        _targets = new TargetCollection();
	        
	        // Process each potential leaf in turn
	        TabGroupLeaf tgl = host.FirstLeaf();
	        
	        while(tgl != null)
	        {
	            // Create all possible targets for this leaf
	            CreateTargets(tgl);
	        
	            // Enumerate all leafs
	            tgl = host.NextLeaf(tgl);
	        }
	    }
Exemple #7
0
	    protected void CreateTargets(TabGroupLeaf leaf)
	    {
	        // Grab the underlying tab control
	        Controls.TabControl tc = leaf.GroupControl as Controls.TabControl;

            // Get the total size of the tab control itself in screen coordinates
            Rectangle totalSize = tc.RectangleToScreen(tc.ClientRectangle);

            // We do not allow a page to be transfered to its own leaf!
            if (leaf != _leaf)
            {
                Rectangle tabsSize = tc.RectangleToScreen(tc.TabsAreaRect);

                // Give priority to the tabs area being used to transfer page
                _targets.Add(new Target(tabsSize, totalSize, leaf, Target.TargetActions.Transfer));
            }
	        
            // Can only create new groups if moving relative to a new group 
	        // or we have more than one page in the originating group
	        if ((leaf != _leaf) || ((leaf == _leaf) && _leaf.TabPages.Count > 1))
	        {
	            int horzThird = totalSize.Width / 3;
	            int vertThird = totalSize.Height / 3;
	        
                // Create the four spacing rectangle
                Rectangle leftRect = new Rectangle(totalSize.X, totalSize.Y, horzThird, totalSize.Height);
                Rectangle rightRect = new Rectangle(totalSize.Right - horzThird, totalSize.Y, horzThird, totalSize.Height);
                Rectangle topRect = new Rectangle(totalSize.X, totalSize.Y, totalSize.Width, vertThird);
                Rectangle bottomRect = new Rectangle(totalSize.X, totalSize.Bottom - vertThird, totalSize.Width, vertThird);

                TabGroupSequence tgs = _leaf.Parent as TabGroupSequence;

                // Can only create new groups in same direction, unless this is the only leaf
                if (tgs.Count <= 1)
                {
                    // Add each new target
                    _targets.Add(new Target(leftRect, leftRect, leaf, Target.TargetActions.GroupLeft));
                    _targets.Add(new Target(rightRect, rightRect, leaf, Target.TargetActions.GroupRight));
                    _targets.Add(new Target(topRect, topRect, leaf, Target.TargetActions.GroupTop));
                    _targets.Add(new Target(bottomRect, bottomRect, leaf, Target.TargetActions.GroupBottom));
                }
                else
                {
                    if (tgs.Direction == Direction.Vertical)
                    {
                        _targets.Add(new Target(topRect, topRect, leaf, Target.TargetActions.GroupTop));
                        _targets.Add(new Target(bottomRect, bottomRect, leaf, Target.TargetActions.GroupBottom));
                    }
                    else
                    {
                        _targets.Add(new Target(leftRect, leftRect, leaf, Target.TargetActions.GroupLeft));
                        _targets.Add(new Target(rightRect, rightRect, leaf, Target.TargetActions.GroupRight));
                    }
                }
            }
	        
            // We do not allow a page to be transfered to its own leaf!
            if (leaf != _leaf)
            {
                // Any remaining space is used to 
                _targets.Add(new Target(totalSize, totalSize, leaf, Target.TargetActions.Transfer));
            }
        }
        internal void EnforceAtLeastOneLeaf()
        {
            // Should not add items during compacting operation
            if (!_compacting)
            {
                // Ensure we enfore policy of at least one leaf
                if (_atLeastOneLeaf)
                {
                    // Is there at least one?
                    if (_numLeafs == 0)
                    {
                        // No, create a default entry for the root sequence
                        _root.AddNewLeaf();

                        // Update the active leaf
                        _activeLeaf = FirstLeaf();

                        // Mark layout as dirty
                        if (_autoCalculateDirty)
                            _dirty = true;
                    }
                }
            }
        }
        public TabGroupLeaf PreviousLeaf(TabGroupLeaf current)
        {
            // Get parent of the provided leaf
            TabGroupSequence tgs = current.Parent as TabGroupSequence;

            // Must have a valid parent sequence
            if (tgs != null)
                return RecursiveFindLeafInSequence(tgs, current, false);
            else
                return null;
        }
 public virtual void OnExternalDrop(TabGroupLeaf tgl, Controls.TabControl tc, DragProvider dp)
 {
     // Has anyone registered for the event?
     if (ExternalDrop != null)
         ExternalDrop(this, tgl, tc, dp);
 }
        public TabGroupLeaf InsertNewLeaf(int index)
        {
            // Range check index
            if (index < 0)
                throw new ArgumentOutOfRangeException("index", index, "Insert index must be at least 0");

            if (index >= _children.Count)
                throw new ArgumentOutOfRangeException("index", index, "Cannot insert after end of current entries");

            // Create a new leaf instance with correct back references
            TabGroupLeaf tgl = new TabGroupLeaf(_tabbedGroups, this);

            // Insert into correct collection position
            Insert(index, tgl);

            // Return its position in collection
            return tgl;
        }
        public TabGroupLeaf AddNewLeaf()
        {
            // Create a new leaf instance with correct back references
            TabGroupLeaf tgl = new TabGroupLeaf(_tabbedGroups, this);

            // Add into the collection
            Add(tgl);

            // Return its position in collection
            return tgl;
        }
Exemple #13
0
 public void ResetActiveLeaf()
 {
     ActiveLeaf = null;
 }
Exemple #14
0
 public void ResetProminentLeaf()
 {
     ProminentLeaf = null;
 }