Esempio n. 1
0
 public TGContextMenuEventArgs(TabGroupLeaf tgl, Controls.TabControl tc,
                               Controls.TabPage tp, PopupMenu contextMenu)
     : base(tgl, tc, tp)
 {
     // Definie initial state
     _contextMenu = contextMenu;
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the TargetManagerZones class.
 /// </summary>
 /// <param name="squares">Show as squares or diamonds.</param>
 /// <param name="host">Control that is requesting target management.</param>
 /// <param name="leaf">Source leaf causing drag operation.</param>
 /// <param name="source">Source TabControl of drag operation.</param>
 public TargetManagerZones(bool squares,
                           TabbedGroups host,
                           TabGroupLeaf leaf,
                           Controls.TabControl source)
     : base(squares, host, leaf, source)
 {
 }
Esempio n. 3
0
		public virtual void OnTabControlCreated(Controls.TabControl tc) {
			// Only modify leaf count when not suspended
			if (_suspendLeafCount == 0) {
				// Remember how many leafs there are
				_numLeafs++;
			}
			
			// Define default values
			tc.Appearance = Magic.Controls.TabControl.VisualAppearance.MultiDocument;
			tc.BoldSelectedPage = false;
			tc.DragOverSelect = false;
			tc.IDEPixelBorder = true;
			tc.ImageList = _imageList;
			tc.Style = _style;

			// Apply the current display tab mode setting            
			switch(_displayTabMode) {
				case TabbedGroups.DisplayTabModes.ShowAll:
					tc.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.ShowAlways;
					break;
				case TabbedGroups.DisplayTabModes.HideAll:
					tc.HideTabsMode = Magic.Controls.TabControl.HideTabsModes.HideAlways;
					break;
			}
            
			// Has anyone registered for the event?
			if (TabControlCreated != null)
				TabControlCreated(this, tc);
		}
Esempio n. 4
0
		protected bool SelectPreviousTab() {
			// If no active leaf...
			if (_activeLeaf == null)
				SelectLastPage();
			else {
				bool selectLast = false;
				TabGroupLeaf startLeaf = _activeLeaf;
				TabGroupLeaf thisLeaf = startLeaf;
                
				do {
					// Access to the embedded tab control
					Controls.TabControl tc = thisLeaf.GroupControl as Controls.TabControl;
                
					// Does it have any pages?
					if (tc.TabPages.Count > 0) {
						// Are we allowed to select the last page?
						if (selectLast) {
							// Do it and exit loop
							tc.SelectedIndex = tc.TabPages.Count - 1;
                            
							// Must ensure this becomes the active leaf
							if (thisLeaf != _activeLeaf)
								ActiveLeaf = thisLeaf;
                                
							break;
						}
						else {
							// Is there another page before the selected one?
							if (tc.SelectedIndex > 0) {
								// Select previous page and exit loop
								tc.SelectedIndex = tc.SelectedIndex - 1;
								break;
							}         
						}           
					}
                    
					selectLast = true;
                    
					// Find the previous leaf in sequence
					thisLeaf = PreviousLeaf(thisLeaf);
                    
					// No more leafs, wrap back to first
					if (thisLeaf == null)
						thisLeaf = LastLeaf();

					// Back at starting leaf?
					if (thisLeaf == startLeaf) {
						// If it was not the first page that we started from
						if (tc.SelectedIndex == 0) {
							// Then we have circles all the way around, select last page
							tc.SelectedIndex = tc.TabPages.Count - 1;
						}
					}

				} while(thisLeaf != startLeaf);
			}
            
			return true;
		}
 public TGCloseRequestEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp)
 {
     // Definie initial state
     _tgl = tgl;
     _tc = tc;
     _tp = tp;
     _cancel = false;
 }
Esempio n. 6
0
 public TGCloseRequestEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp)
 {
     // Definie initial state
     _tgl    = tgl;
     _tc     = tc;
     _tp     = tp;
     _cancel = false;
 }
Esempio n. 7
0
        private void CreateLeafTargets(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)
            {
                // Is the destination leaf allowed to accept a drop?
                if (leaf.AllowDrop)
                {
                    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);

                // 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));
            }

            // We do not allow a page to be transfered to its own leaf!
            if (leaf != Leaf)
            {
                // Is the destination leaf allowed to accept a drop?
                if (leaf.AllowDrop)
                {
                    // Any remaining space is used to
                    _targets.Add(new Target(totalSize, totalSize, leaf, Target.TargetActions.Transfer));
                }
            }
        }
Esempio n. 8
0
        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();
            }
        }
Esempio n. 9
0
        protected void OnDoubleClickTab(Controls.TabControl tc, Controls.TabPage page)
        {
            Content c = (Content)page.Tag;

            // Make Content record its current position and remember it for the future
            c.RecordRestore();

            // Invert docked status
            c.Docked = (c.Docked == false);

            // Remove from current WindowContent and restore its position
            _manager.HideContent(c, false, true);
            _manager.ShowContent(c);
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the TargetManager class.
        /// </summary>
        /// <param name="squares">Show as squares or diamonds.</param>
        /// <param name="host">Control that is requesting target management.</param>
        /// <param name="leaf">Source leaf causing drag operation.</param>
        /// <param name="source">Source TabControl of drag operation.</param>
        public TargetManager(bool squares,
                             TabbedGroups host,
                             TabGroupLeaf leaf,
                             Controls.TabControl source)
        {
            // Define state
            _squares    = squares;
            _host       = host;
            _leaf       = leaf;
            _source     = source;
            _lastTarget = null;

            // Setup targets
            Initialize();
        }
Esempio n. 11
0
        /// <summary>
        /// Initialize a new instance of the TargetAreaLeaf class.
        /// </summary>
        /// <param name="squares">Showing as squares or diamonds.</param>
        /// <param name="source">Leaf that is being dragged.</param>
        /// <param name="leaf">Leaf that is a potential target.</param>
        public TargetAreaLeaf(bool squares, TabGroupLeaf source, TabGroupLeaf leaf)
        {
            // Remember host for later
            _squares = squares;

            // 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
            _screenRect = tc.RectangleToScreen(tc.ClientRectangle);

            // 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 != source) || ((leaf == source) && source.TabPages.Count > 1))
            {
                int horzThird = _screenRect.Width / 3;
                int vertThird = _screenRect.Height / 3;

                // Create the four spacing rectangle
                Rectangle leftRect   = new Rectangle(_screenRect.X, _screenRect.Y, horzThird, _screenRect.Height);
                Rectangle rightRect  = new Rectangle(_screenRect.Right - horzThird, _screenRect.Y, horzThird, _screenRect.Height);
                Rectangle topRect    = new Rectangle(_screenRect.X, _screenRect.Y, _screenRect.Width, vertThird);
                Rectangle bottomRect = new Rectangle(_screenRect.X, _screenRect.Bottom - vertThird, _screenRect.Width, vertThird);

                // Add each new target
                _left   = new Target(leftRect, leftRect, leaf, Target.TargetActions.GroupLeft);
                _right  = new Target(rightRect, rightRect, leaf, Target.TargetActions.GroupRight);
                _top    = new Target(topRect, topRect, leaf, Target.TargetActions.GroupTop);
                _bottom = new Target(bottomRect, bottomRect, leaf, Target.TargetActions.GroupBottom);
            }

            // We do not allow a page to be transfered to its own leaf!
            if (leaf != source)
            {
                // Is the destination leaf allowed to accept a drop?
                if (leaf.AllowDrop)
                {
                    // Any remaining space is used to
                    _tabbed = new Target(_screenRect, _screenRect, leaf, Target.TargetActions.Transfer);
                }
            }

            // Not currently inside the hot area
            _hotInside = false;
        }
Esempio n. 12
0
        public override void Dispose()
        {
            // Must unhook from the menu related events
            _mcClose.Click -= new EventHandler(OnClose);
            _mcProm.Click  -= new EventHandler(OnToggleProminent);
            _mcReba.Click  -= new EventHandler(OnRebalance);
            _mcHorz.Click  -= new EventHandler(OnNewVertical);
            _mcVert.Click  -= new EventHandler(OnNewHorizontal);
            _mcNext.Click  -= new EventHandler(OnMoveNext);
            _mcPrev.Click  -= new EventHandler(OnMovePrevious);

            // If the tab control was created
            if (_tabControl != null)
            {
                // Unhook drag related events
                _tabControl.DragDrop  -= new DragEventHandler(OnControlDragDrop);
                _tabControl.DragEnter -= new DragEventHandler(OnControlDragEnter);
                _tabControl.DragLeave -= new EventHandler(OnControlDragLeave);

                // Unhook custom drag related events
                _tabControl.PageDragStart -= new MouseEventHandler(OnPageDragStart);
                _tabControl.PageDragMove  -= new MouseEventHandler(OnPageDragMove);
                _tabControl.PageDragEnd   -= new MouseEventHandler(OnPageDragEnd);
                _tabControl.PageDragQuit  -= new MouseEventHandler(OnPageDragQuit);

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

                // Unhook tab page level events
                _tabControl.GotFocus         -= new EventHandler(OnGainedFocus);
                _tabControl.PageGotFocus     -= new EventHandler(OnGainedFocus);
                _tabControl.ClosePressed     -= new EventHandler(OnClose);
                _tabControl.PopupMenuDisplay -= new CancelEventHandler(OnPopupMenuDisplay);

                // Remove it without hitting close form bug
                ControlHelper.RemoveAll(_tabControl);

                // Dispose of the tab control
                _tabControl.Dispose();
                _tabControl = null;
            }
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
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);
            }
        }
Esempio n. 16
0
        protected void DefinePopupMenuForControl(Controls.TabControl tabControl)
        {
            PopupMenu pm = new PopupMenu();

            // Add all the standard menus we manage
            _mcClose = new MenuCommand("", new EventHandler(OnClose));
            _mcSep1  = new MenuCommand("-");
            _mcProm  = new MenuCommand("", new EventHandler(OnToggleProminent));
            _mcReba  = new MenuCommand("", new EventHandler(OnRebalance));
            _mcSep2  = new MenuCommand("-");
            _mcHorz  = new MenuCommand("", _internalImages, _imageHorzSplit, new EventHandler(OnNewVertical));
            _mcVert  = new MenuCommand("", _internalImages, _imageVertSplit, new EventHandler(OnNewHorizontal));
            _mcNext  = new MenuCommand("", new EventHandler(OnMoveNext));
            _mcPrev  = new MenuCommand("", new EventHandler(OnMovePrevious));

            // Prominent is a radio checked item
            _mcProm.RadioCheck = true;

            // Use the provided context menu
            tabControl.ContextPopupMenu = pm;

            // Update command states when shown
            tabControl.PopupMenuDisplay += new CancelEventHandler(OnPopupMenuDisplay);
        }
Esempio n. 17
0
        public override void Dispose()
        {
            // Must unhook from the menu related events
            _mcClose.Click -= new EventHandler(OnClose);
            _mcProm.Click -= new EventHandler(OnToggleProminent);
            _mcReba.Click -= new EventHandler(OnRebalance);
            _mcHorz.Click -= new EventHandler(OnNewVertical);
            _mcVert.Click -= new EventHandler(OnNewHorizontal);
            _mcNext.Click -= new EventHandler(OnMoveNext);
            _mcPrev.Click -= new EventHandler(OnMovePrevious);

            // If the tab control was created
            if (_tabControl != null)
            {
                // Unhook drag related events
                _tabControl.DragDrop -= new DragEventHandler(OnControlDragDrop);
                _tabControl.DragEnter -= new DragEventHandler(OnControlDragEnter);
                _tabControl.DragLeave -= new EventHandler(OnControlDragLeave);

                // Unhook custom drag related events
                _tabControl.PageDragStart -= new MouseEventHandler(OnPageDragStart);
                _tabControl.PageDragMove -= new MouseEventHandler(OnPageDragMove);
                _tabControl.PageDragEnd -= new MouseEventHandler(OnPageDragEnd);
                _tabControl.PageDragQuit -= new MouseEventHandler(OnPageDragQuit);

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

                // Unhook tab page level events
                _tabControl.GotFocus -= new EventHandler(OnGainedFocus);
                _tabControl.PageGotFocus -= new EventHandler(OnGainedFocus);
                _tabControl.ClosePressed -= new EventHandler(OnClose);
                _tabControl.PopupMenuDisplay -= new CancelEventHandler(OnPopupMenuDisplay);

                // Remove it without hitting close form bug
                ControlHelper.RemoveAll(_tabControl);

                // Dispose of the tab control
                _tabControl.Dispose();
                _tabControl = null;
            }
        }
Esempio n. 18
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);
	        }
	    }
Esempio n. 19
0
		protected bool TestShortcut(Shortcut sc) {
			bool result = false;
        
			try{
				// Must have an active leaf for shortcuts to operate against
				if (_activeLeaf != null) {
					Controls.TabControl tc = _activeLeaf.GroupControl as Controls.TabControl;
            
					// Must have an active tab for these shortcuts to work against
					if (tc.SelectedTab != null) {
						// Close selected page requested?
						if (sc.Equals(_closeShortcut)) {
							_activeLeaf.OnClose(_activeLeaf, EventArgs.Empty);
							result = true;
						}

						// Toggle the prominence state?
						if (sc.Equals(_prominentShortcut)) {
							_activeLeaf.OnToggleProminent(_activeLeaf, EventArgs.Empty);
							result = true;
						}
                        
						// Move page to the next group?
						if (sc.Equals(_moveNextShortcut)) {
							_activeLeaf.OnMoveNext(_activeLeaf, EventArgs.Empty);
							result = true;
						}
                
						// Move page to the previous group?
						if (sc.Equals(_movePreviousShortcut)) {
							_activeLeaf.OnMovePrevious(_activeLeaf, EventArgs.Empty);
							result = true;
						}
                
						// Cannot split a group unless at least two entries exist                
						if (tc.TabPages.Count > 1) {
							bool allowVert = false;
							bool allowHorz = false;
                        
							if (_root.Count <= 1) {
								allowVert = true;
								allowHorz = true;
							}
							else {
								if (_root.Direction == Direction.Vertical)
									allowVert = true;
								else
									allowHorz = true;
							}
                    
							// Create two vertical groups
							if (allowHorz && sc.Equals(_splitVerticalShortcut)) {
								_activeLeaf.NewHorizontalGroup(_activeLeaf, false);
								result = true;
							}

							// Create two horizontal groups
							if (allowVert && sc.Equals(_splitHorizontalShortcut)) {
								_activeLeaf.NewVerticalGroup(_activeLeaf, false);
								result = true;
							}
						}
					}
                
					// Request to rebalance all spacing
					if (sc.Equals(_rebalanceShortcut)) {
						_activeLeaf.OnRebalance(_activeLeaf, EventArgs.Empty);
						result = true;
					}
				}
			}catch{}

			return result;
		}
Esempio n. 20
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));
            }
        }
Esempio n. 21
0
		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);
		}