Example #1
0
        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
            River.Orqa.Controls.Controls.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;

            River.Orqa.Controls.Controls.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();
            }
        }
Example #2
0
 public TGContextMenuEventArgs(TabGroupLeaf tgl, Controls.TabControl tc,
                               Controls.TabPage tp, PopupMenu contextMenu)
     : base(tgl, tc, tp)
 {
     // Definie initial state
     _contextMenu = contextMenu;
 }
Example #3
0
 public TGCloseRequestEventArgs(TabGroupLeaf tgl, Controls.TabControl tc, Controls.TabPage tp)
 {
     // Definie initial state
     _tgl    = tgl;
     _tc     = tc;
     _tp     = tp;
     _cancel = false;
 }
Example #4
0
 public Target(Rectangle hotRect, Rectangle drawRect, TabGroupLeaf leaf, TargetActions action)
 {
     // Define state
     _hotRect  = hotRect;
     _drawRect = drawRect;
     _leaf     = leaf;
     _action   = action;
 }
Example #5
0
        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);
        }
Example #6
0
        internal void NewHorizontalGroup(TabGroupLeaf sourceLeaf, bool before)
        {
            TabGroupSequence tgs = this.Parent as TabGroupSequence;

            // We must have a parent sequence!
            if (tgs != null)
            {
                tgs.Direction = Common.Direction.Horizontal;
                AddGroupToSequence(tgs, sourceLeaf, before);
            }
        }
Example #7
0
        internal void OnMoveNext(object sender, EventArgs e)
        {
            // Find the previous leaf node
            TabGroupLeaf next = _tabbedGroups.NextLeaf(this);

            // Must always be valid!
            if (next != null)
            {
                MovePageToLeaf(next);
            }
        }
Example #8
0
        internal void OnMovePrevious(object sender, EventArgs e)
        {
            // Find the previous leaf node
            TabGroupLeaf prev = _tabbedGroups.PreviousLeaf(this);

            // Must always be valid!
            if (prev != null)
            {
                MovePageToLeaf(prev);
            }
        }
Example #9
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;

            River.Orqa.Controls.Controls.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();
            }
        }
Example #10
0
        protected void CompactRemoveEmptyTabLeafs(TabbedGroups.CompactFlags flags)
        {
            // Should we check for empty leaf nodes?
            if ((flags & 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;
                            }
                        }
                    }
                }
            }
        }
Example #11
0
        public override bool ContainsProminent(bool recurse)
        {
            // Cache the currently selected prominent group
            TabGroupLeaf prominent = _tabbedGroups.ProminentLeaf;

            // Valid value to test against?
            if (prominent != null)
            {
                return(this == prominent);
            }
            else
            {
                return(false);
            }
        }
Example #12
0
        public override bool ContainsProminent(bool recurse)
        {
            // Cache the currently selected prominent group
            TabGroupLeaf prominent = _tabbedGroups.ProminentLeaf;

            // If not defined then we cannot contain it!
            if (prominent == null)
            {
                return(false);
            }

            // Check our own leaf nodes first
            foreach (TabGroupBase group in _children)
            {
                if (group.IsLeaf)
                {
                    if (group == prominent)
                    {
                        return(true);
                    }
                }
            }

            // Need to check sub-sequences?
            if (recurse)
            {
                // Check our child sequences
                foreach (TabGroupBase group in _children)
                {
                    if (group.IsSequence)
                    {
                        if (group.ContainsProminent(recurse))
                        {
                            return(true);
                        }
                    }
                }
            }

            // Not found
            return(false);
        }
Example #13
0
        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);
        }
Example #14
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);
            }
        }
Example #15
0
        public override void LoadFromXml(XmlTextReader xmlIn)
        {
            // Grab the expected attributes
            string rawCount     = xmlIn.GetAttribute(0);
            string rawUnique    = xmlIn.GetAttribute(1);
            string rawSpace     = xmlIn.GetAttribute(2);
            string rawDirection = xmlIn.GetAttribute(3);

            // Convert to correct types
            int     count  = Convert.ToInt32(rawCount);
            int     unique = Convert.ToInt32(rawUnique);
            Decimal space  = Convert.ToDecimal(rawSpace);

            Common.Direction direction = (rawDirection == "Horizontal" ? Common.Direction.Horizontal :
                                          Common.Direction.Vertical);

            // Update myself with new values
            _unique    = unique;
            _space     = space;
            _direction = direction;

            // Load each of the children
            for (int i = 0; i < count; i++)
            {
                // Read the next Element
                if (!xmlIn.Read())
                {
                    throw new ArgumentException("An element was expected but could not be read in");
                }

                TabGroupBase newElement = null;

                // Is it another sequence?
                if (xmlIn.Name == "Sequence")
                {
                    newElement = new TabGroupSequence(_tabbedGroups, this);
                }
                else if (xmlIn.Name == "Leaf")
                {
                    newElement = new TabGroupLeaf(_tabbedGroups, this);
                }
                else
                {
                    throw new ArgumentException("Unknown element was encountered");
                }

                bool expectEndElement = !xmlIn.IsEmptyElement;

                // Load its config
                newElement.LoadFromXml(xmlIn);

                // Add new element to the collection
                Add(newElement);

                // Do we expect and end element to occur?
                if (expectEndElement)
                {
                    // Move past the end element
                    if (!xmlIn.Read())
                    {
                        throw new ArgumentException("Could not read in next expected node");
                    }

                    // Check it has the expected name
                    if (xmlIn.NodeType != XmlNodeType.EndElement)
                    {
                        throw new ArgumentException("EndElement expected but not found");
                    }
                }
            }
        }
Example #16
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 == Common.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));
            }
        }