Example #1
0
        protected override void SetBoundsCore(Rectangle bounds, BoundsSpecified specified)
        {
            _currentlySizing = true;
            CachedBounds     = bounds;
            try
            {
                if (DraggedControl.IsCurrentlyDragging)
                {
                    if (ToolStripPanelRow.Cells[ToolStripPanelRow.Cells.Count - 1] == this)
                    {
                        Rectangle displayRectangle = ToolStripPanelRow.DisplayRectangle;
                        if (ToolStripPanelRow.Orientation == Orientation.Horizontal)
                        {
                            int spaceToFree = bounds.Right - displayRectangle.Right;
                            if (spaceToFree > 0 && bounds.Width > spaceToFree)
                            {
                                bounds.Width -= spaceToFree;
                            }
                        }
                        else
                        {
                            int spaceToFree = bounds.Bottom - displayRectangle.Bottom;
                            if (spaceToFree > 0 && bounds.Height > spaceToFree)
                            {
                                bounds.Height -= spaceToFree;
                            }
                        }
                    }

                    Debug.WriteLineIf(ToolStripPanelRow.ToolStripPanelMouseDebug.TraceVerbose, "[CELL] DRAGGING calling SetBounds " + bounds.ToString());
                    base.SetBoundsCore(bounds, specified);
                    InnerElement.SetBounds(bounds, specified);
                }
                else
                {
                    if (!ToolStripPanelRow.CachedBoundsMode)
                    {
                        Debug.WriteLineIf(ToolStripPanelRow.ToolStripPanelMouseDebug.TraceVerbose, "[CELL] NOT DRAGGING calling SetBounds " + bounds.ToString());
                        base.SetBoundsCore(bounds, specified);
                        InnerElement.SetBounds(bounds, specified);
                    }
                }
            }
            finally
            {
                _currentlySizing = false;
            }
        }