Example #1
0
        protected void CompactReduceSameDirection(TabbedGroups.CompactFlags flags)
        {
            bool changed = false;

            // Should we check for same direction sub-sequences?
            if ((flags & 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();
            }
        }
Example #2
0
        internal void Replace(TabGroupBase orig, TabGroupBase replace)
        {
            // Find array position of old item
            int origPos = _children.IndexOf(orig);

            // Transfer across the space occupied
            replace.RealSpace = orig.RealSpace;

            // Is this the only Window entry?
            if (_children.Count == 1)
            {
                // Remove Window from appearance

                // Use helper method to circumvent form Close bug
                ControlHelper.RemoveAt(_control.Controls, 0);
            }
            else
            {
                int pos = 0;

                // Calculate position of Window to remove
                if (origPos != 0)
                {
                    pos = origPos * 2 - 1;
                }

                // Remove Window and bar

                // Use helper method to circumvent form Close bug
                ControlHelper.RemoveAt(_control.Controls, pos);
                ControlHelper.RemoveAt(_control.Controls, pos);
            }

            // Inserting at start of collection?
            if (origPos == 0)
            {
                if (_children.Count > 1)
                {
                    // Create a resizing bar
                    ResizeBar bar = new ResizeBar(_direction, this);

                    // Append resize bar between existing entries and new entry
                    _control.Controls.Add(bar);

                    // Reposition the bar and group to start of collection
                    _control.Controls.SetChildIndex(bar, 0);
                }

                // Append new group control
                _control.Controls.Add(replace.GroupControl);

                // Reposition the bar and group to start of collection
                _control.Controls.SetChildIndex(replace.GroupControl, 0);
            }
            else
            {
                // Create a resizing bar
                ResizeBar bar = new ResizeBar(_direction, this);

                // Append resize bar between existing entries and new entry
                _control.Controls.Add(bar);

                // Append new group control
                _control.Controls.Add(replace.GroupControl);

                // Find correct index taking into account number of resize bars
                int pos = origPos * 2 - 1;

                // Reposition the bar and Window to correct relative ordering
                _control.Controls.SetChildIndex(bar, pos++);
                _control.Controls.SetChildIndex(replace.GroupControl, pos);
            }

            // Update parentage
            replace.SetParent(this);

            // Replace the entry
            _children[origPos] = replace;

            // Update child layout to reflect new proportional spacing values
            RepositionChildren();

            // Mark layout as dirty
            if (_tabbedGroups.AutoCalculateDirty)
            {
                _tabbedGroups.Dirty = true;
            }
        }
Example #3
0
        protected void CompactReduceSingleEntries(TabbedGroups.CompactFlags flags)
        {
            bool changed = false;

            // Should we check for single instance nodes?
            if ((flags & 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();
            }
        }