Exemplo n.º 1
0
        void fontButton_Click(object sender, EventArgs e)
        {
            Button     thisControl = sender as Button;
            FontDialog fontDlg     = new FontDialog();
            int        styleIndex  = (int)thisControl.Tag;

            var style = styler.GetStyle(styleIndex);

            fontDlg.Font = SciStyleFont.GetFont(style);

            if (fontDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
            {
                style.Font      = fontDlg.Font.Name;
                style.Size      = fontDlg.Font.Size;
                style.Bold      = fontDlg.Font.Bold;
                style.Italic    = fontDlg.Font.Italic;
                style.Underline = fontDlg.Font.Underline;
                styler.SetStyle(styleIndex, style);
                foreach (Control ctrl in flowLayoutPanel.Controls)
                {
                    if ((int)ctrl.Tag == styleIndex)
                    {
                        ctrl.Font = fontDlg.Font;
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ConfigColor_Load(object sender, EventArgs e)
        {
            Label  styleLabel;
            Button foreButton, backButton, fontButton;

            flowLayoutPanel.SuspendLayout();

            foreach (string name in styler.GetStyleNameIndex().Keys)
            {
                int thisIndex = styler.GetStyleIndex(name);
                Styler.StyleCopy thisStyle = styler.GetStyle(name);

                styleLabel           = new Label();
                styleLabel.Text      = name;
                styleLabel.Tag       = thisIndex;
                styleLabel.Font      = SciStyleFont.GetFont(thisStyle);
                styleLabel.ForeColor = thisStyle.ForeColor;
                styleLabel.BackColor = thisStyle.BackColor;
                styleLabel.Margin    = new Padding(0, 3, 0, 0);
                styleLabel.Size      = new System.Drawing.Size(170, styleLabel.Size.Height);
                flowLayoutPanel.Controls.Add(styleLabel);

                fontButton           = new Button();
                fontButton.Text      = "Font";
                fontButton.FlatStyle = FlatStyle.Popup;
                fontButton.Size      = new Size(40, 20);
                fontButton.Tag       = thisIndex;
                fontButton.Click    += new EventHandler(fontButton_Click);
                flowLayoutPanel.Controls.Add(fontButton);

                foreButton           = new Button();
                foreButton.Text      = "Text Color";
                foreButton.FlatStyle = FlatStyle.Popup;
                foreButton.Size      = new Size(70, 20);
                foreButton.Tag       = thisIndex;
                foreButton.Click    += new EventHandler(foreButton_Click);
                flowLayoutPanel.Controls.Add(foreButton);

                backButton           = new Button();
                backButton.Text      = "Background";
                backButton.FlatStyle = FlatStyle.Popup;
                backButton.Size      = new Size(80, 20);
                backButton.Tag       = thisIndex;
                backButton.Click    += new EventHandler(backButton_Click);
                flowLayoutPanel.Controls.Add(backButton);

                flowLayoutPanel.SetFlowBreak(backButton, true);
            }

            flowLayoutPanel.Controls.Remove(btnCancel);
            flowLayoutPanel.Controls.Remove(btnDone);

            flowLayoutPanel.Controls.Add(btnCancel);
            flowLayoutPanel.Controls.Add(btnDone);

            Size preferSize = flowLayoutPanel.PreferredSize;

            preferSize.Width  += 20;
            preferSize.Height += 40;
            this.Size          = preferSize;

            flowLayoutPanel.ResumeLayout();
        }