コード例 #1
0
        private bool ApplyScrollbarChanges(Rectangle display)
        {
            bool      flag            = false;
            bool      horiz           = false;
            bool      vert            = false;
            Rectangle clientRectangle = base.ClientRectangle;
            Rectangle rectangle3      = clientRectangle;

            if (this.HScroll)
            {
                clientRectangle.Height += SystemInformation.HorizontalScrollBarHeight;
            }
            else
            {
                rectangle3.Height -= SystemInformation.HorizontalScrollBarHeight;
            }
            if (this.VScroll)
            {
                clientRectangle.Width += SystemInformation.VerticalScrollBarWidth;
            }
            else
            {
                rectangle3.Width -= SystemInformation.VerticalScrollBarWidth;
            }
            int width  = rectangle3.Width;
            int height = rectangle3.Height;

            if (base.Controls.Count != 0)
            {
                this.scrollMargin = this.requestedScrollMargin;
                if (this.dockPadding != null)
                {
                    this.scrollMargin.Height += base.Padding.Bottom;
                    this.scrollMargin.Width  += base.Padding.Right;
                }
                for (int i = 0; i < base.Controls.Count; i++)
                {
                    Control control = base.Controls[i];
                    if ((control != null) && control.GetState(2))
                    {
                        switch (control.Dock)
                        {
                        case DockStyle.Bottom:
                            this.scrollMargin.Height += control.Size.Height;
                            break;

                        case DockStyle.Right:
                            this.scrollMargin.Width += control.Size.Width;
                            break;
                        }
                    }
                }
            }
            if (!this.userAutoScrollMinSize.IsEmpty)
            {
                width  = this.userAutoScrollMinSize.Width + this.scrollMargin.Width;
                height = this.userAutoScrollMinSize.Height + this.scrollMargin.Height;
                horiz  = true;
                vert   = true;
            }
            bool flag4 = this.LayoutEngine == DefaultLayout.Instance;

            if (!flag4 && CommonProperties.HasLayoutBounds(this))
            {
                Size layoutBounds = CommonProperties.GetLayoutBounds(this);
                if (layoutBounds.Width > width)
                {
                    horiz = true;
                    width = layoutBounds.Width;
                }
                if (layoutBounds.Height > height)
                {
                    vert   = true;
                    height = layoutBounds.Height;
                }
            }
            else if (base.Controls.Count != 0)
            {
                for (int j = 0; j < base.Controls.Count; j++)
                {
                    bool    flag5    = true;
                    bool    flag6    = true;
                    Control control2 = base.Controls[j];
                    if ((control2 == null) || !control2.GetState(2))
                    {
                        continue;
                    }
                    if (flag4)
                    {
                        Control control3 = control2;
                        switch (control3.Dock)
                        {
                        case DockStyle.Top:
                            flag5 = false;
                            goto Label_02DD;

                        case DockStyle.Bottom:
                        case DockStyle.Right:
                        case DockStyle.Fill:
                            flag5 = false;
                            flag6 = false;
                            goto Label_02DD;

                        case DockStyle.Left:
                            flag6 = false;
                            goto Label_02DD;
                        }
                        AnchorStyles anchor = control3.Anchor;
                        if ((anchor & AnchorStyles.Right) == AnchorStyles.Right)
                        {
                            flag5 = false;
                        }
                        if ((anchor & AnchorStyles.Left) != AnchorStyles.Left)
                        {
                            flag5 = false;
                        }
                        if ((anchor & AnchorStyles.Bottom) == AnchorStyles.Bottom)
                        {
                            flag6 = false;
                        }
                        if ((anchor & AnchorStyles.Top) != AnchorStyles.Top)
                        {
                            flag6 = false;
                        }
                    }
Label_02DD:
                    if (flag5 || flag6)
                    {
                        Rectangle bounds = control2.Bounds;
                        int       num5   = ((-display.X + bounds.X) + bounds.Width) + this.scrollMargin.Width;
                        int       num6   = ((-display.Y + bounds.Y) + bounds.Height) + this.scrollMargin.Height;
                        if (!flag4)
                        {
                            num5 += control2.Margin.Right;
                            num6 += control2.Margin.Bottom;
                        }
                        if ((num5 > width) && flag5)
                        {
                            horiz = true;
                            width = num5;
                        }
                        if ((num6 > height) && flag6)
                        {
                            vert   = true;
                            height = num6;
                        }
                    }
                }
            }
            if (width <= clientRectangle.Width)
            {
                horiz = false;
            }
            if (height <= clientRectangle.Height)
            {
                vert = false;
            }
            Rectangle rectangle5 = clientRectangle;

            if (horiz)
            {
                rectangle5.Height -= SystemInformation.HorizontalScrollBarHeight;
            }
            if (vert)
            {
                rectangle5.Width -= SystemInformation.VerticalScrollBarWidth;
            }
            if (horiz && (height > rectangle5.Height))
            {
                vert = true;
            }
            if (vert && (width > rectangle5.Width))
            {
                horiz = true;
            }
            if (!horiz)
            {
                width = rectangle5.Width;
            }
            if (!vert)
            {
                height = rectangle5.Height;
            }
            flag = this.SetVisibleScrollbars(horiz, vert) || flag;
            if (this.HScroll || this.VScroll)
            {
                flag = this.SetDisplayRectangleSize(width, height) || flag;
            }
            else
            {
                this.SetDisplayRectangleSize(width, height);
            }
            this.SyncScrollbars(true);
            return(flag);
        }