예제 #1
0
        protected void InternalConstruct(VisualStyle style, Direction direction, bool zoneMinMax)
        {
            // Remember initial state
            _style = style;
            _direction = direction;
            _maximizedWindow = null;
			_suppressReposition = false;
			_zoneMinMax = zoneMinMax;

            // Create the control used to resize the whole Zone
            _resizeBar = new ResizeBar(_direction, this);

            // Place last in the list of child Controls
            Controls.Add(_resizeBar);

            // Start of very small and let first content determine new size
            this.Size = new Size(0,0);		

			// Do not inherit the parent BackColor, we want the .Control color as 
			// this blends in with the way all the docking windows are drawn
			this.BackColor = SystemColors.Control;
			this.ForeColor = SystemColors.ControlText;
        }
예제 #2
0
        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();
        }
예제 #3
0
        protected TabGroupBase Add(TabGroupBase group)
        {
            // Remember reference
            _children.Add(group);

            // First group added to sequence?
            if (_children.Count == 1)
            {
                // Add new child control
                _control.Controls.Add(group.GroupControl);
            }
            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(group.GroupControl);
            }

            if (!_tabbedGroups.Initializing)
            {
                // Allocate space for the new child
                AllocateSpace(group);

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

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

            return group;
        }
예제 #4
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;
        }
예제 #5
0
        public bool StartResizeOperation(ResizeBar bar, ref Rectangle screenBoundary)
        {
            // Find position of this ResizeBar in the Controls collection
            int barIndex = _control.Controls.IndexOf(bar);

            // Convert from control to children indexing
            int beforeIndex = (barIndex - 1) / 2;

            // Get groups before and after the resize bar
            TabGroupBase before = _children[beforeIndex];
            TabGroupBase after = _children[beforeIndex + 1];

            // Resizing boundary is defaulted to whole control area
            screenBoundary = _control.RectangleToScreen(_control.ClientRectangle);

            // Find screen rectangle for the groups either side of the bar
            Rectangle rectBefore = before.GroupControl.RectangleToScreen(before.GroupControl.ClientRectangle);
            Rectangle rectAfter = after.GroupControl.RectangleToScreen(after.GroupControl.ClientRectangle);

            // Reduce the boundary in the appropriate direction
            if (_direction == Direction.Vertical)
            {
                screenBoundary.Y = rectBefore.Y + before.MinimumSize.Height;
                screenBoundary.Height -= screenBoundary.Bottom - rectAfter.Bottom;
                screenBoundary.Height -= after.MinimumSize.Height;
            }
            else
            {
                screenBoundary.X = rectBefore.X + before.MinimumSize.Width;
                screenBoundary.Width -= screenBoundary.Right - rectAfter.Right;
                screenBoundary.Width -= after.MinimumSize.Width;
            }

            // Allow resize operation to occur
            return true;
        }
예제 #6
0
        public void EndResizeOperation(ResizeBar bar, int delta)
        {
            // Find position of this ResizeBar in the Controls collection
            int barIndex = _control.Controls.IndexOf(bar);

            // Convert from control to children indexing
            int beforeIndex = (barIndex - 1) / 2;

            // The Window relating to this bar must be the one before it in the collection
            TabGroupBase before = _children[beforeIndex];

            // Is the Window being expanded
            DeltaGroupSpace(before, delta);
        }
예제 #7
0
        public bool CanResize(ResizeBar bar)
        {
            // Cannot resize when in prominent mode
            if (!_tabbedGroups.ResizeBarLock && (_tabbedGroups.ProminentLeaf == null))
            {
                // Find position of this ResizeBar in the Controls collection
                int barIndex = _control.Controls.IndexOf(bar);

                // Convert from control to children indexing
                int beforeIndex = (barIndex - 1) / 2;

                TabGroupBase before = _children[beforeIndex];
                TabGroupBase after = _children[beforeIndex + 1];

                // If groups on both sides have no space then cannot resize there relative positions
                if (((before.Space <= 0m) && (after.Space <= 0m)))
                    return false;
                else
                    return true;
            }
            else
            {
                // Must exit prominent mode before resize can occur
                return false;
            }
        }
예제 #8
0
        protected TabGroupBase Insert(int index, TabGroupBase group)
        {
            // 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");

            // Remember reference
            _children.Insert(index, group);

            // 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(group.GroupControl);

            // Inserting at start of collection?
            if (index == 0)
            {
                // Reposition the bar and group to start of collection
                _control.Controls.SetChildIndex(bar, 0);
                _control.Controls.SetChildIndex(group.GroupControl, 0);
            }
            else
            {
                // Find correct index taking into account number of resize bars
                int	pos = index * 2 - 1;

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

            // Allocate space for the new child
            AllocateSpace(group);

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

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

            return group;
        }
예제 #9
0
        protected override void OnWindowInserted(int index, object value)
        {
            base.OnWindowInserted(index, value);

            Window w = value as Window;

            // Is this the first Window entry?
            if (_windows.Count == 1)
            {
                // Use size of the Window to determine our new size
                Size wSize = w.Size;

                // Adjust to account for the ResizeBar
                switch(this.Dock)
                {
                    case DockStyle.Left:
                    case DockStyle.Right:
                        wSize.Width += _resizeBar.Width;
                        break;
                    case DockStyle.Top:
                    case DockStyle.Bottom:
                        wSize.Height += _resizeBar.Height;
                        break;
                }

                this.Size = wSize;

                // Add the Window to the appearance
                Controls.Add(w);

                // Reposition to the start of the collection
                Controls.SetChildIndex(w, 0);
            }
            else
            {
                ResizeBar bar = new ResizeBar(_direction, this);

                // Add the bar and Window
                Controls.Add(bar);
                Controls.Add(w);

                // Adding at start of collection?
                if (index == 0)
                {
                    // Reposition the bar and Window to start of collection
                    Controls.SetChildIndex(bar, 0);
                    Controls.SetChildIndex(w, 0);
                }
                else
                {
                    int	pos = index * 2 - 1;

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

            // Allocate space for the new Window from other Windows
            AllocateWindowSpace(w);

            // Recalculate the size and position of each Window and resize bar
            RepositionControls();

            // Inform all interested parties of possible change in maximized state
            OnRefreshMaximize(EventArgs.Empty);
        }
예제 #10
0
        public void EndResizeOperation(ResizeBar bar, int delta)
        {
            // Is this the Zone level resize bar?
            if (bar == _resizeBar)
            {
                switch(this.Dock)
                {
                    case DockStyle.Left:
                        this.Width += delta;
                        break;
                    case DockStyle.Right:
                        this.Width -= delta;
                        break;
                    case DockStyle.Top:
                        this.Height += delta;
                        break;
                    case DockStyle.Bottom:
                        this.Height -= delta;
                        break;
                }
            }
            else
            {
                // Find position of this ResizeBar in the Controls collection
                int barIndex = Controls.IndexOf(bar);

                // The Window relating to this bar must be the one before it in the collection
                Window w = Controls[barIndex - 1] as Window;

                // Is the Window being expanded
                ModifyWindowSpace(w, delta);
            }
        }
예제 #11
0
        public bool StartResizeOperation(ResizeBar bar, ref Rectangle screenBoundary)
        {
            // Is this the Zone level resize bar?
            if (bar == _resizeBar)
            {
                // Define resize boundary as the inner area of the Form containing the Zone
                screenBoundary = this.Parent.RectangleToScreen(_manager.InnerResizeRectangle(this));

                // Find the screen limits of this Zone
                Rectangle zoneBoundary = RectangleToScreen(this.ClientRectangle);

                int minHeight = this.MinimumHeight;
                int minWidth = this.MinimumWidth;

                // Restrict resize based on which edge we are attached against
                switch(_state)
                {
                    case State.DockTop:
                        {
                            // Restrict Zone being made smaller than its minimum height
                            int diff = zoneBoundary.Top - screenBoundary.Top + minHeight;
                            screenBoundary.Y += diff;
                            screenBoundary.Height -= diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Height;
                            screenBoundary.Height -= innerMinimumWidth;
                        }
                        break;
                    case State.DockBottom:
                        {
                            // Restrict Zone being made smaller than its minimum height
                            int diff = zoneBoundary.Bottom - screenBoundary.Bottom - minHeight;
                            screenBoundary.Height += diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Height;
                            screenBoundary.Y += innerMinimumWidth;
                            screenBoundary.Height -= innerMinimumWidth;
                        }
                        break;
                    case State.DockLeft:
                        {
                            // Restrict Zone being made smaller than its minimum width
                            int diff = zoneBoundary.Left - screenBoundary.Left + minWidth;
                            screenBoundary.X += diff;
                            screenBoundary.Width -= diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Width;
                            screenBoundary.Width -=	innerMinimumWidth;
                        }
                        break;
                    case State.DockRight:
                        {
                            // Restrict Zone being made smaller than its minimum width
                            int diff = zoneBoundary.Right - screenBoundary.Right - minWidth;
                            screenBoundary.Width += diff;

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Width;
                            screenBoundary.X += innerMinimumWidth;
                            screenBoundary.Width -=	innerMinimumWidth;
                        }
                        break;
                }
            }
            else
            {
                // Find position of this ResizeBar in the Controls collection
                int barIndex = Controls.IndexOf(bar);

                // Define resize boundary as the client area of the Zone
                screenBoundary = RectangleToScreen(this.ClientRectangle);

                // The Window before this bar must be the one before it in the collection
                Window wBefore = Controls[barIndex - 1] as Window;

                // The Window after this bar must be the one after it in the Window collection
                Window wAfter = _windows[_windows.IndexOf(wBefore) + 1];
				
                // Find screen rectangle for the Windows either side of the bar
                Rectangle rectBefore = wBefore.RectangleToScreen(wBefore.ClientRectangle);
                Rectangle rectAfter = wAfter.RectangleToScreen(wAfter.ClientRectangle);

                // Reduce the boundary in the appropriate direction
                if (_direction == Direction.Vertical)
                {
                    screenBoundary.Y = rectBefore.Y + wBefore.MinimalSize.Height;
                    screenBoundary.Height -= screenBoundary.Bottom - rectAfter.Bottom;
                    screenBoundary.Height -= wAfter.MinimalSize.Height;
                }
                else
                {
                    screenBoundary.X = rectBefore.X + wBefore.MinimalSize.Width;
                    screenBoundary.Width -= screenBoundary.Right - rectAfter.Right;
                    screenBoundary.Width -= wAfter.MinimalSize.Width;
                }
            }

            // Allow resize operation to occur
            return true;
        }
예제 #12
0
        public bool CanResize(ResizeBar bar)
        {
            // Is this the Window resize bar?
            if (bar != _resizeBar)
            {
                // Find position of this ResizeBar in the Controls collection
                int barIndex = Controls.IndexOf(bar);

                // The Window before this bar must be the one before it in the collection
                Window wBefore = Controls[barIndex - 1] as Window;

                // The Window after this bar must be the one after it in the Window collection
                Window wAfter = _windows[_windows.IndexOf(wBefore) + 1];

                // If Windows either side of the bar have no space then cannot resize there relative positions
                if (((wBefore.ZoneArea <= 0m) && (wAfter.ZoneArea <= 0m)))
                    return false;

                // If in maximized state and the bar is not connected to the maximized window
                if ((_maximizedWindow != null) && (_maximizedWindow != wBefore) && (_maximizedWindow != wAfter))
                    return false;
            }

            return true;
        }
예제 #13
0
 public void EndResizeOperation(ResizeBar bar, int delta)
 {
     switch(_borderEdge)
     {
         case Edge.Right:
             Controls[1].Width += delta;
             this.Width += delta;
             _autoHidePanel.UpdateContentSize(Controls[1].Width, true);
             break;
         case Edge.Left:
             Controls[1].Width -= delta;
             this.Width -= delta;
             this.Left += delta;
             _autoHidePanel.UpdateContentSize(Controls[1].Width, true);
             break;
         case Edge.Bottom:
             Controls[1].Height += delta;
             this.Height += delta;
             _autoHidePanel.UpdateContentSize(Controls[1].Height, false);
             break;
         case Edge.Top:
             Controls[1].Height -= delta;
             this.Height -= delta;
             this.Top += delta;
             _autoHidePanel.UpdateContentSize(Controls[1].Height, false);
             break;
     }
     
     _autoHidePanel.DefineRectangles();
 }
예제 #14
0
            public bool StartResizeOperation(ResizeBar bar, ref Rectangle screenBoundary)
            {
                // Set focus into the WCT to prevent it siding away during resize
                _autoHidePanel.SetFocusToWCT();    
            
                // Define resize boundary as the inner area of the Form containing the Zone
                screenBoundary = this.Parent.RectangleToScreen(_manager.InnerResizeRectangle(this));

                // Find the screen limits of this Zone
                Rectangle panelBoundary = RectangleToScreen(this.ClientRectangle);

                int minHeight = this.MinimumHeight;
                int minWidth = this.MinimumWidth;

                // Restrict resize based on which edge we are attached against
                switch(_borderEdge)
                {
                    case Edge.Bottom:
                        {
                            // Restrict Zone being made smaller than its minimum height
                            int diff = panelBoundary.Top - screenBoundary.Top + minHeight;
                            screenBoundary.Y += diff;
                            screenBoundary.Height -= diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Height;
                            screenBoundary.Height -= innerMinimumWidth;
                        }
                        break;
                    case Edge.Top:
                        {
                            // Restrict Zone being made smaller than its minimum height
                            int diff = panelBoundary.Bottom - screenBoundary.Bottom - minHeight;
                            screenBoundary.Height += diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Height;
                            screenBoundary.Y += innerMinimumWidth;
                            screenBoundary.Height -= innerMinimumWidth;
                        }
                        break;
                    case Edge.Right:
                        {
                            // Restrict Zone being made smaller than its minimum width
                            int diff = panelBoundary.Left - screenBoundary.Left + minWidth;
                            screenBoundary.X += diff;
                            screenBoundary.Width -= diff;					

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Width;
                            screenBoundary.Width -=	innerMinimumWidth;
                        }
                        break;
                    case Edge.Left:
                        {
                            // Restrict Zone being made smaller than its minimum width
                            int diff = panelBoundary.Right - screenBoundary.Right - minWidth;
                            screenBoundary.Width += diff;

                            // Restrict Zone from making inner control smaller than minimum allowed
                            int innerMinimumWidth = _manager.InnerMinimum.Width;
                            screenBoundary.X += innerMinimumWidth;
                            screenBoundary.Width -=	innerMinimumWidth;
                        }
                        break;
                }

                return true;
            }
예제 #15
0
 public bool CanResize(ResizeBar bar)
 {
     return true;
 }