Esempio n. 1
0
            protected internal override int FreeSpaceFromRow(int spaceToFree)
            {
                int requiredSpace = spaceToFree;

                // take a look at the last guy.  if his right edge exceeds
                // the new bounds, then we should go ahead and push him into view.

                if (spaceToFree > 0)
                {
                    // we should shrink the last guy and then move him.
                    ToolStripPanelCell lastCellOnRow = GetNextVisibleCell(Row.Cells.Count - 1, /*forward*/ false);
                    if (lastCellOnRow is null)
                    {
                        return(0);
                    }

                    Padding cellMargin = lastCellOnRow.Margin;

                    // only check margin.left as we are only concerned with getting right edge of
                    // the toolstrip into view. (space after the fact doesnt count).
                    if (cellMargin.Top >= spaceToFree)
                    {
                        cellMargin.Top   -= spaceToFree;
                        cellMargin.Bottom = 0;
                        spaceToFree       = 0;
                    }
                    else
                    {
                        spaceToFree      -= lastCellOnRow.Margin.Top;
                        cellMargin.Top    = 0;
                        cellMargin.Bottom = 0;
                    }

                    lastCellOnRow.Margin = cellMargin;

                    // start moving the toolstrips before this guy.
                    spaceToFree -= MoveUp(Row.Cells.Count - 1, spaceToFree);

                    if (spaceToFree > 0)
                    {
                        spaceToFree -= lastCellOnRow.Shrink(spaceToFree);
                    }
                }

                return(requiredSpace - Math.Max(0, spaceToFree));
            }
Esempio n. 2
0
            protected internal override void OnBoundsChanged(Rectangle oldBounds, Rectangle newBounds)
            {
                base.OnBoundsChanged(oldBounds, newBounds);

                // if our bounds have changed - we should shove the toolbars up so they're in view.
                if (Row.Cells.Count > 0)
                {
                    // take a look at the last guy.  if his right edge exceeds
                    // the new bounds, then we should go ahead and push him into view.
                    ToolStripPanelCell lastCell = GetNextVisibleCell(Row.Cells.Count - 1, /*forward=*/ false);
                    int spaceToFree             = (lastCell != null) ? lastCell.Bounds.Bottom - newBounds.Height : 0;

                    if (spaceToFree > 0)
                    {
                        // we should shrink the last guy and then move him.
                        ToolStripPanelCell lastCellOnRow = GetNextVisibleCell(Row.Cells.Count - 1, /*forward*/ false);

                        Padding cellMargin = lastCellOnRow.Margin;

                        // only check margin.left as we are only concerned with getting bottom edge of
                        // the toolstrip into view. (space after the fact doesnt count).
                        if (cellMargin.Top >= spaceToFree)
                        {
                            cellMargin.Top      -= spaceToFree;
                            cellMargin.Bottom    = 0;
                            lastCellOnRow.Margin = cellMargin;
                            spaceToFree          = 0;
                        }
                        else
                        {
                            spaceToFree         -= lastCellOnRow.Margin.Top;
                            cellMargin.Top       = 0;
                            cellMargin.Bottom    = 0;
                            lastCellOnRow.Margin = cellMargin;
                        }

                        spaceToFree -= lastCellOnRow.Shrink(spaceToFree);
                        // start moving the toolstrips before this guy.
                        MoveUp(Row.Cells.Count - 1, spaceToFree);
                    }
                }
            }