public void TableLayoutStyleCollection_Add_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", () => collection.Add(style));
            Assert.Throws <ArgumentException>("style", () => ((IList)collection).Add(style));
        }
        public void TableLayoutStyleCollection_RemoveAt_Invoke_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);
            collection.RemoveAt(0);
            Assert.Empty(collection);

            collection.Add(style);
            Assert.Equal(style, Assert.Single(collection));
        }
 public static void Add(this TableLayoutStyleCollection collection, TableLayoutStyle style, int count)
 {
     for (int i = 0; i < count; i++)
     {
         collection.Add(style);
     }
 }
Esempio n. 4
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 void TableLayoutStyleCollection_Add_Null_ThrowsArgumentNullException()
        {
            using 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 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);
                }
            }
        }
        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);
        }
Esempio n. 8
0
        public void TableLayoutStyleCollection_Add_Null_ThrowsNullReferenceException()
        {
            var toolStrip = new ToolStrip {
                LayoutStyle = ToolStripLayoutStyle.Table
            };
            TableLayoutSettings        settings   = Assert.IsType <TableLayoutSettings>(toolStrip.LayoutSettings);
            TableLayoutStyleCollection collection = settings.RowStyles;

            Assert.Throws <NullReferenceException>(() => collection.Add(null));
            Assert.Throws <NullReferenceException>(() => ((IList)collection).Add(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]);
        }