Exemplo n.º 1
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));
                }
            }
        }
Exemplo n.º 2
0
        protected void DrawDragIndicator()
        {
            // Create client rectangle
            Rectangle clientRect = new Rectangle(new Point(0, 0), _tabControl.ClientSize);

            // Draw drag indicator around whole control
            TargetManager.DrawDragRectangle(_tabControl.RectangleToScreen(clientRect));
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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));
            }
        }