Example #1
0
        protected override void OnControlAdded(ControlEventArgs e)
        {
            TTBXDockablePanel dockpanel = e.Control as TTBXDockablePanel;

            if (dockpanel != null)
            {
                dockpanel.InsideControlAdded = true;
            }
            try
            {
                base.OnControlAdded(e);
            }
            finally
            {
                if (dockpanel != null)
                {
                    dockpanel.InsideControlAdded = false;
                }
            }
        }
            public override Size GetPreferredSize(Size constrainingSize)
            {
                constrainingSize = ConvertZeroToUnbounded(constrainingSize);

                constrainingSize -= Padding.Size;

                ToolStrip parent = this.Parent;

                if (parent == null)
                {
                    parent = this.Owner;
                }

                if (parent == null)
                {
                    return(this.Size);
                }

                TTBXDockablePanel dockPanel = parent as TTBXDockablePanel;
                Size result;

                if (parent.Orientation == Orientation.Horizontal)
                {
                    result = new Size(dockPanel.DisplayRectangle.Width, dockPanel.DockedHeight);
                }
                else
                {
                    result = new Size(dockPanel.DockedWidth, dockPanel.DisplayRectangle.Height);
                }

                result -= Margin.Size;

                result.Width  = Math.Min(constrainingSize.Width, result.Width);
                result.Height = Math.Min(constrainingSize.Height, result.Height);

                return(result + Padding.Size);
            }