public ConfigStyles() { originalStyles = new Dictionary <int, Styler.StyleCopy>(); indexToName = new Dictionary <int, string>(); foreach (string name in styler.GetStyleNameIndex().Keys) { Styler.StyleCopy copy = styler.GetStyle(name); originalStyles.Add(styler.GetStyleIndex(name), copy); indexToName.Add(styler.GetStyleIndex(name), name); } InitializeComponent(); }
public static Font GetFont(Styler.StyleCopy style) { FontStyle fs = FontStyle.Regular; if (style.Italic) { fs = FontStyle.Italic; } else if (style.Bold) { fs = FontStyle.Bold; } else if (style.Underline) { fs = FontStyle.Underline; } return(new Font(style.Font, style.Size, fs)); }
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(); }