public static void Add(this TableLayoutStyleCollection collection, TableLayoutStyle style, int count)
 {
     for (int i = 0; i < count; i++)
     {
         collection.Add(style);
     }
 }
        public void TableLayoutStyleCollection_Insert_Null_ThrowsArgumentNullException(int index)
        {
            using var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            Assert.Throws <ArgumentNullException>("style", () => ((IList)collection).Insert(index, null));
        }
Example #3
0
        public void TableLayoutStyleCollection_Insert_Null_ThrowsNullReferenceException()
        {
            var toolStrip = new ToolStrip {
                LayoutStyle = ToolStripLayoutStyle.Table
            };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            Assert.Throws <NullReferenceException>(() => ((IList)collection).Insert(0, null));
        }
        public void TableLayoutStyleCollection_Item_SetNull_ThrowsArgumentNullException(int index)
        {
            using var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            collection.Add(new RowStyle());
            Assert.Throws <ArgumentNullException>("value", () => collection[index]          = null);
            Assert.Throws <ArgumentNullException>("value", () => ((IList)collection)[index] = null);
        }
        public void TableLayoutStyleCollection_Insert_StyleAlreadyAdded_ThrowsArgumentException()
        {
            using var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;
            var style = new RowStyle();

            collection.Add(style);
            Assert.Throws <ArgumentException>("style", () => ((IList)collection).Insert(0, style));
        }
        public void TableLayoutStyleCollection_Add_Null_ThrowsArgumentNullException()
        {
            var toolStrip = new ToolStrip {
                LayoutStyle = ToolStripLayoutStyle.Table
            };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            Assert.Throws <ArgumentNullException>("style", () => collection.Add(null));
            Assert.Throws <ArgumentNullException>("style", () => ((IList)collection).Add(null));
        }
        public void TableLayoutStyleCollection_Add_TableLayoutStyle_Success()
        {
            using var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            var style = new RowStyle();

            collection.Add(style);
            Assert.Equal(style, Assert.Single(collection));
        }
Example #8
0
        public void TableLayoutStyleCollection_Item_SetNull_ThrowsNullReferenceException()
        {
            var toolStrip = new ToolStrip {
                LayoutStyle = ToolStripLayoutStyle.Table
            };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            collection.Add(new RowStyle());
            Assert.Throws <NullReferenceException>(() => collection[0]          = null);
            Assert.Throws <NullReferenceException>(() => ((IList)collection)[0] = null);
        }
        public void TableLayoutStyleCollection_Item_SetTableLayoutStyle_GetReturnsExpected()
        {
            using var toolStrip = new ToolStrip { LayoutStyle = ToolStripLayoutStyle.Table };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            collection.Add(new RowStyle());

            var style = new RowStyle();

            collection[0] = style;
            Assert.Single(collection);
            Assert.Equal(style, collection[0]);
        }
Example #10
0
 static void SetStyles(TableLayoutStyleCollection styles, IReadOnlyList <TableLayoutStyle> builderStyles, int count, Func <TableLayoutStyle> defaultStyle)
 {
     if (builderStyles.Count > 0)
     {
         foreach (var style in builderStyles)
         {
             styles.Add(style);
         }
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             styles.Add(defaultStyle());
         }
     }
 }
        public static void Add(this TableLayoutStyleCollection collection, SizeType sizeType, float?height, int count)
        {
            object[] parameters = height.HasValue ? new object[] { sizeType, height.Value } : new object[] { sizeType };

            if (collection.GetType() == typeof(TableLayoutRowStyleCollection))
            {
                for (int i = 0; i < count; i++)
                {
                    collection.Add(Activator.CreateInstance(typeof(RowStyle), parameters) as RowStyle);
                }
            }
            else
            {
                for (int i = 0; i < count; i++)
                {
                    collection.Add(Activator.CreateInstance(typeof(ColumnStyle), parameters) as ColumnStyle);
                }
            }
        }