Beispiel #1
0
		protected void InternalConstruct(TabbedGroups tabbedGroups, TabGroupBase parent)
		{
		    // Assign initial values
		    _tabbedGroups = tabbedGroups;
		    _parent = parent;
		    _unique = _count++;
		    
		    // Defaults
		    _tag = null;
		    _space = 100m;
		    _minSize = new Size(_tabbedGroups.DefaultGroupMinimumWidth,
		                        _tabbedGroups.DefaultGroupMinimumHeight);
		}
Beispiel #2
0
        public TabGroupLeaf(TabbedGroups tabbedGroups, TabGroupBase parent)
            : base(tabbedGroups, parent)
        {
            // Create our managed tab control instance
            _tabControl = new Controls.TabControl();

            // We need page drag to begin when mouse dragged a small distance
            _tabControl.DragFromControl = false;

            // We need to monitor attempts to drag into the tab control
            _dragEntered = false;
            _tabControl.AllowDrop = true;
            _tabControl.DragDrop += new DragEventHandler(OnControlDragDrop);
            _tabControl.DragEnter += new DragEventHandler(OnControlDragEnter);
            _tabControl.DragLeave += new EventHandler(OnControlDragLeave);

            // Need notification when page drag begins
            _tabControl.PageDragStart += new MouseEventHandler(OnPageDragStart);
            _tabControl.PageDragMove += new MouseEventHandler(OnPageDragMove);
            _tabControl.PageDragEnd += new MouseEventHandler(OnPageDragEnd);
            _tabControl.PageDragQuit += new MouseEventHandler(OnPageDragQuit);

            // Hook into tab page collection events
            _tabControl.TabPages.Cleared += new CollectionClear(OnTabPagesCleared);
            _tabControl.TabPages.Inserted += new CollectionChange(OnTabPagesInserted);
            _tabControl.TabPages.Removed += new CollectionChange(OnTabPagesRemoved);

            // Hook into page level events
            _tabControl.GotFocus += new EventHandler(OnGainedFocus);
            _tabControl.PageGotFocus += new EventHandler(OnGainedFocus);
            _tabControl.ClosePressed += new EventHandler(OnClose);

            // Manager only created at start of drag operation
            _targetManager = null;

            //            DefinePopupMenuForControl(_tabControl);

            // Setup the correct 'HideTabsMode' for the control
            Notify(TabGroupBase.NotifyCode.DisplayTabMode);

            // Define the default setup of TabControl and allow developer to customize
            _tabbedGroups.OnTabControlCreated(_tabControl);
        }
Beispiel #3
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);
	        }
	    }
Beispiel #4
0
        public TabGroupBase(TabbedGroups tabbedGroups, TabGroupBase parent)
		{
		    InternalConstruct(tabbedGroups, parent);
		}
        protected void CompactRemoveEmptyTabLeafs(TabbedGroups.CompactFlags flags)
        {
            // Should we check for empty leaf nodes?
            if ((flags & Controls.TabbedGroups.CompactFlags.RemoveEmptyTabLeaf) != 0)
            {
                int count = _children.Count;

                for(int index=0; index<count; index++)
                {
                    // Only interested in leaf entries
                    if (_children[index].IsLeaf)
                    {
                        TabGroupLeaf tgl = (TabGroupLeaf)_children[index];

                        // Is this an empty leaf node?
                        if (tgl.Count == 0)
                        {
                            // Update active leaf setting
                            if (_tabbedGroups.ActiveLeaf == tgl)
                            {
                                TabGroupLeaf newLeaf = _tabbedGroups.NextLeaf(tgl);

                                if (newLeaf == null)
                                    newLeaf = _tabbedGroups.PreviousLeaf(tgl);

                                _tabbedGroups.ActiveLeaf = newLeaf;
                            }

                            // Need to remove the redundant entry
                            RemoveAt(index);

                            // Reduce number of entries left to check
                            count--;

                            // Move backwards so the next increment stays on same index
                            index--;

                            // Mark layout as dirty
                            if (_tabbedGroups.AutoCalculateDirty)
                                _tabbedGroups.Dirty = true;
                        }
                    }
                }
            }
        }
Beispiel #6
0
 public TabGroupBase(TabbedGroups tabbedGroups)
 {
     InternalConstruct(tabbedGroups, null);
 }
        protected void CompactReduceSameDirection(TabbedGroups.CompactFlags flags)
        {
            bool changed = false;

            // Should we check for same direction sub-sequences?
            if ((flags & Controls.TabbedGroups.CompactFlags.ReduceSameDirection) != 0)
            {
                int count = _children.Count;

                for(int index=0; index<count; index++)
                {
                    // Only interested in sequence entries
                    if (_children[index].IsSequence)
                    {
                        TabGroupSequence tgs = (TabGroupSequence)_children[index];

                        // Does it run in same direction as ourself?
                        if (_direction == tgs.Direction)
                        {
                            // Remember how much space the base entry occupies
                            Decimal temp = tgs.RealSpace;

                            // Find the child control to be replaced
                            int childPos = _control.Controls.IndexOf(tgs.GroupControl);

                            // Need to remove a resize bar before the control?
                            if (childPos > 0)
                                ControlHelper.RemoveAt(_control.Controls, childPos);

                            // Remove the actual control
                            ControlHelper.RemoveAt(_control.Controls, childPos);

                            // Remove the intermediate group
                            _children.RemoveAt(index);

                            // Reflect change in size
                            count--;

                            Decimal totalAllocated = 0m;

                            // Add in each sub group in turn
                            int subCount = tgs.Count;

                            bool firstInsert = true;

                            for(int subIndex=0; subIndex<subCount; subIndex++)
                            {
                                TabGroupBase tgb = tgs[subIndex];

                                // What percentage of original space did it have?
                                Decimal orig = tgb.RealSpace;

                                // Give it the same proportion of new space
                                Decimal update = Decimal.Round(temp / 100 * orig, SPACE_PRECISION);

                                // Keep total actually allocated
                                totalAllocated += update;

                                // Use new proportion
                                tgb.RealSpace = update;

                                // Update parentage
                                tgb.SetParent(this);

                                // Does new child control need a resizing bar?
                                if ((childPos > 0) && !firstInsert)
                                {
                                    // Create a resizing bar
                                    ResizeBar bar = new ResizeBar(_direction, this);

                                    _control.Controls.Add(bar);
                                    _control.Controls.SetChildIndex(bar, childPos++);
                                }

                                // Add new child control in its place
                                _control.Controls.Add(tgb.GroupControl);
                                _control.Controls.SetChildIndex(tgb.GroupControl, childPos++);

                                // Insert at current position
                                _children.Insert(index, tgb);

                                // Adjust variables to reflect increased size
                                index++;
                                count++;
                                firstInsert = false;
                            }

                            // Assign any remainder to last group
                            _children[index-1].RealSpace +=  temp - totalAllocated;

                            // Need controls repositioned
                            changed = true;

                            // Mark layout as dirty
                            if (_tabbedGroups.AutoCalculateDirty)
                                _tabbedGroups.Dirty = true;
                        }
                    }
                }
            }

            // Change in contents requires entries to be repositioned
            if (changed)
                RepositionChildren();
        }
        protected void CompactReduceSingleEntries(TabbedGroups.CompactFlags flags)
        {
            bool changed = false;

            // Should we check for single instance nodes?
            if ((flags & Controls.TabbedGroups.CompactFlags.ReduceSingleEntries) != 0)
            {
                int count = _children.Count;

                for(int index=0; index<count; index++)
                {
                    // Only interested in sequence entries
                    if (_children[index].IsSequence)
                    {
                        TabGroupSequence tgs = (TabGroupSequence)_children[index];

                        // Does this entry only have a single child
                        if (tgs.Count == 1)
                        {
                            // Remember how much space the base entry occupies
                            Decimal temp = tgs.RealSpace;

                            // Get reference to only child
                            TabGroupBase child = tgs[0];

                            // Update parentage
                            child.SetParent(this);

                            // Find the child control to be replaced
                            int childPos = _control.Controls.IndexOf(tgs.GroupControl);

                            // Remove it
                            ControlHelper.RemoveAt(_control.Controls, childPos);

                            // Add new child control in its place
                            _control.Controls.Add(child.GroupControl);
                            _control.Controls.SetChildIndex(child.GroupControl, childPos);

                            // Replace the middle object with the child
                            _children.RemoveAt(index);
                            _children.Insert(index, child);

                            // Restore its correct spacing
                            child.RealSpace = temp;

                            // Need controls repositioned
                            changed = true;

                            // Mark layout as dirty
                            if (_tabbedGroups.AutoCalculateDirty)
                                _tabbedGroups.Dirty = true;
                        }
                    }
                }
            }

            // Change in contents requires entries to be repositioned
            if (changed)
                RepositionChildren();
        }
 public TabGroupSequence(TabbedGroups tabbedGroups, TabGroupBase parent, Direction direction)
     : base(tabbedGroups, parent)
 {
     InternalConstruct(null, direction);
 }
 public TabGroupSequence(TabbedGroups tabbedGroups, TabGroupBase parent)
     : base(tabbedGroups, parent)
 {
     InternalConstruct(null, Direction.Horizontal);
 }
 public TabGroupSequence(TabbedGroups tabbedGroups)
     : base(tabbedGroups)
 {
     // Root instance always defaults to being horizontal
     InternalConstruct(tabbedGroups, Direction.Horizontal);
 }
        public void Compact(TabbedGroups.CompactFlags flags)
        {
            // Compact each child sequence
            foreach(TabGroupBase tgb in _children)
                if (tgb.IsSequence)
                    (tgb as TabGroupSequence).Compact(flags);

            // Remove dangling entries
            CompactRemoveEmptyTabLeafs(flags);
            CompactRemoveEmptyTabSequences(flags);

            // Integrate single entries
            CompactReduceSingleEntries(flags);

            // Integrate sub-sequences which run in same direction
            CompactReduceSameDirection(flags);
        }
        protected void CompactRemoveEmptyTabSequences(TabbedGroups.CompactFlags flags)
        {
            // Should we check for empty sequence nodes?
            if ((flags & Controls.TabbedGroups.CompactFlags.RemoveEmptyTabSequence) != 0)
            {
                int count = _children.Count;

                for(int index=0; index<count; index++)
                {
                    // Only interested in sequence entries
                    if (_children[index].IsSequence)
                    {
                        TabGroupSequence tgs = (TabGroupSequence)_children[index];

                        // Is this an empty sequence node?
                        if (tgs.Count == 0)
                        {
                            // Need to remove the redundant entry
                            RemoveAt(index);

                            // Reduce number of entries left to check
                            count--;

                            // Move backwards so the next increment stays on same index
                            index--;

                            // Mark layout as dirty
                            if (_tabbedGroups.AutoCalculateDirty)
                                _tabbedGroups.Dirty = true;
                        }
                    }
                }
            }
        }