Exemple #1
0
        public void AddFontSizeSelector(IEnumerable <int> fontSizes)
        {
            if (fontSizes.Min() < 1 || fontSizes.Max() > 7)
            {
                throw new ArgumentException("Allowable font sizes are 1 through 7");
            }

            var fontSizeBox = new ToolStripComboBox();

            fontSizeBox.Items.AddRange(fontSizes.Select(f => f.ToString()).ToArray());
            fontSizeBox.Name = "fontSizeSelector";
            fontSizeBox.Size = new System.Drawing.Size(25, 25);
            fontSizeBox.SelectedIndexChanged += (sender, o) =>
            {
                var size = ((ToolStripComboBox)sender).SelectedItem;
                _doc.ExecCommand("FontSize", false, size);
            };
            fontSizeBox.DropDownStyle = ComboBoxStyle.DropDownList;

            this.AddToolbarItem(fontSizeBox);
        }