public void DockPaddingScroll()
        {
            ScrollableControl scrollable = new ScrollableControl();

            scrollable.Padding    = new Padding(10);
            scrollable.Size       = new Size(50, 50);
            scrollable.AutoScroll = true;

            Control c = new Control();

            c.Size   = scrollable.Size;           // Same size as parent, shouldn' need scrollbars
            c.Parent = scrollable;

            Form f = new Form();

            f.Controls.Add(scrollable);

            f.Show();

            Assert.AreEqual(false, scrollable.VerticalScroll.Visible, "#A0");

            ScrollableControl.DockPaddingEdges dock_padding = scrollable.DockPadding;
            Assert.IsTrue(dock_padding != null, "#B0");

            // Refresh the layout, now that is affected by the creation of DockPadding
            scrollable.PerformLayout();

            Assert.AreEqual(true, scrollable.VerticalScroll.Visible, "#C0");
        }
 public void DockPaddingEdges_Equals_Invoke_ReturnsExpected(ScrollableControl.DockPaddingEdges padding, object other, bool expected)
 {
     if (other is ScrollableControl.DockPaddingEdges)
     {
         Assert.Equal(expected, padding.GetHashCode().Equals(other.GetHashCode()));
     }
     Assert.Equal(expected, padding.Equals(other));
 }
Example #3
0
 public void DockPaddingEdges_ToString_InvokeWithOwner_ReturnsExpected()
 {
     using var owner = new ScrollableControl
           {
               Padding = new Padding(1, 2, 3, 4)
           };
     ScrollableControl.DockPaddingEdges padding = owner.DockPadding;
     Assert.Equal("{Left=1,Top=2,Right=3,Bottom=4}", padding.ToString());
 }
Example #4
0
 public void DockPaddingEdges_GetHashCode_InvokeWithOwner_ReturnsExpected()
 {
     using var owner = new ScrollableControl
           {
               Padding = new Padding(1, 2, 3, 4)
           };
     ScrollableControl.DockPaddingEdges padding = owner.DockPadding;
     Assert.NotEqual(0, padding.GetHashCode());
     Assert.Equal(padding.GetHashCode(), padding.GetHashCode());
 }
        public void DockPaddingEdges_ToString_InvokeWithoutOwner_ReturnsExpected()
        {
            var owner = new ScrollableControl
            {
                Padding = new Padding(1, 2, 3, 4)
            };
            ICloneable original = owner.DockPadding;

            ScrollableControl.DockPaddingEdges padding = (ScrollableControl.DockPaddingEdges)original.Clone();
            Assert.Equal("{Left=1,Top=2,Right=3,Bottom=4}", padding.ToString());
        }
        public void DockPaddingEdges_GetHashCode_InvokeWithoutOwner_ReturnsExpected()
        {
            var owner = new ScrollableControl
            {
                Padding = new Padding(1, 2, 3, 4)
            };
            ICloneable original = owner.DockPadding;

            ScrollableControl.DockPaddingEdges padding = (ScrollableControl.DockPaddingEdges)original.Clone();
            Assert.NotEqual(0, padding.GetHashCode());
            Assert.Equal(padding.GetHashCode(), padding.GetHashCode());
        }
Example #7
0
 public void DockPaddingEdges_Properties_Get_ReturnsExpected(int left, int top, int right, int bottom, int expectedAll, int expectedLeft, int expectedTop, int expectedRight, int expectedBottom)
 {
     using var owner = new ScrollableControl
           {
               Padding = new Padding(left, top, right, bottom)
           };
     ScrollableControl.DockPaddingEdges padding = owner.DockPadding;
     Assert.Equal(expectedAll, padding.All);
     Assert.Equal(expectedLeft, padding.Left);
     Assert.Equal(expectedTop, padding.Top);
     Assert.Equal(expectedRight, padding.Right);
     Assert.Equal(expectedBottom, padding.Bottom);
 }
        public void DockPaddingEdges_Clone_InvokeWithOwner_ReturnsExpected()
        {
            var owner = new ScrollableControl
            {
                Padding = new Padding(1, 2, 3, 4)
            };
            ICloneable original = owner.DockPadding;

            ScrollableControl.DockPaddingEdges padding = (ScrollableControl.DockPaddingEdges)original.Clone();
            Assert.Equal(0, padding.All);
            Assert.Equal(1, padding.Left);
            Assert.Equal(2, padding.Top);
            Assert.Equal(3, padding.Right);
            Assert.Equal(4, padding.Bottom);
        }
        public void DockPaddingEdges_All_SetWithoutOwner_GetReturnsExpected(int value)
        {
            var owner = new ScrollableControl
            {
                Padding = new Padding(1, 2, 3, 4)
            };
            ICloneable original = owner.DockPadding;

            ScrollableControl.DockPaddingEdges padding = (ScrollableControl.DockPaddingEdges)original.Clone();
            padding.All = value;
            Assert.Equal(value, padding.All);
            Assert.Equal(value, padding.Left);
            Assert.Equal(value, padding.Top);
            Assert.Equal(value, padding.Right);
            Assert.Equal(value, padding.Bottom);
        }
Example #10
0
 public void DockPaddingEdges_All_SetWithOwner_GetReturnsExpected(int value, int expectedValue, int expectedPaddingAll)
 {
     using var owner = new ScrollableControl();
     ScrollableControl.DockPaddingEdges padding = owner.DockPadding;
     padding.All = value;
     Assert.Equal(expectedValue, padding.All);
     Assert.Equal(expectedValue, padding.Left);
     Assert.Equal(expectedValue, padding.Top);
     Assert.Equal(expectedValue, padding.Right);
     Assert.Equal(expectedValue, padding.Bottom);
     Assert.Equal(expectedPaddingAll, owner.Padding.All);
     Assert.Equal(expectedValue, owner.Padding.Left);
     Assert.Equal(expectedValue, owner.Padding.Top);
     Assert.Equal(expectedValue, owner.Padding.Right);
     Assert.Equal(expectedValue, owner.Padding.Bottom);
 }
Example #11
0
 public void DockPaddingEdges_Left_SetWithOwner_GetReturnsExpected(int value, int expectedLeft)
 {
     using var owner = new ScrollableControl
           {
               Padding = new Padding(1, 2, 3, 4)
           };
     ScrollableControl.DockPaddingEdges padding = owner.DockPadding;
     padding.Left = value;
     Assert.Equal(0, padding.All);
     Assert.Equal(expectedLeft, padding.Left);
     Assert.Equal(2, padding.Top);
     Assert.Equal(3, padding.Right);
     Assert.Equal(4, padding.Bottom);
     Assert.Equal(-1, owner.Padding.All);
     Assert.Equal(expectedLeft, owner.Padding.Left);
     Assert.Equal(2, owner.Padding.Top);
     Assert.Equal(3, owner.Padding.Right);
     Assert.Equal(4, owner.Padding.Bottom);
 }
Example #12
0
        public void DockPaddingEdges_BottomPropertyDescriptor_ResetValue_SetsToZero()
        {
            using var owner = new ScrollableControl
                  {
                      Padding = new Padding(1, 2, 3, 4)
                  };
            ScrollableControl.DockPaddingEdges padding    = owner.DockPadding;
            PropertyDescriptorCollection       properties = TypeDescriptor.GetProperties(padding);
            PropertyDescriptor property = properties[nameof(ScrollableControl.DockPaddingEdges.Bottom)];

            Assert.True(property.CanResetValue(padding));
            Assert.True(property.ShouldSerializeValue(padding));
            property.ResetValue(padding);

            Assert.Equal(0, padding.All);
            Assert.Equal(1, padding.Left);
            Assert.Equal(2, padding.Top);
            Assert.Equal(3, padding.Right);
            Assert.Equal(0, padding.Bottom);
        }
Example #13
0
        public static Size GetFitToContentsSize(Control control)
        {
            if (control.HasChildren)
            {
                int  num   = int.MinValue;
                int  num2  = int.MinValue;
                int  num3  = 0;
                int  num4  = 0;
                bool flag  = false;
                bool flag2 = true;
                bool flag3 = true;
                for (int i = 0; i < control.Controls.Count; i++)
                {
                    Control control2 = control.Controls[i];
                    if (control2.Visible)
                    {
                        flag = true;
                        switch (control2.Dock)
                        {
                        case DockStyle.None:
                        {
                            flag2 = false;
                            flag3 = false;
                            Size size = control2.Size;
                            num  = Math.Max(num, control2.Left + size.Width);
                            num2 = Math.Max(num2, control2.Top + size.Height);
                            break;
                        }

                        case DockStyle.Top:
                        case DockStyle.Bottom:
                            flag3 = false;
                            num4 += control2.Height;
                            break;

                        case DockStyle.Left:
                        case DockStyle.Right:
                            flag2 = false;
                            num3 += control2.Width;
                            break;

                        case DockStyle.Fill:
                            num3 += control2.Width;
                            num4 += control2.Height;
                            break;
                        }
                    }
                }
                ScrollableControl scrollableControl = control as ScrollableControl;
                if (scrollableControl != null)
                {
                    ScrollableControl.DockPaddingEdges dockPadding = scrollableControl.DockPadding;
                    num  += dockPadding.Right;
                    num2 += dockPadding.Bottom;
                    num3 += dockPadding.Left + dockPadding.Right;
                    num4 += dockPadding.Top + dockPadding.Bottom;
                }
                num  = Math.Max(num, num3);
                num2 = Math.Max(num2, num4);
                if (!flag || !AutoSizePanel.CanAutoSizeWidth(control) || flag2)
                {
                    num = control.Size.Width;
                }
                if (!flag || !AutoSizePanel.CanAutoSizeHeight(control) || flag3)
                {
                    num2 = control.Size.Height;
                }
                return(AutoSizePanel.GetAutoSizeModeSize(control, new Size(num, num2)));
            }
            return(control.Size);
        }