private void AddStyle_Click(object sender, EventArgs e) { var _f = new FormInput(); _f.Message = "Enter name for style"; var _r = _f.ShowDialog(); if (_r == DialogResult.OK) { var _style = new RtfControlStyle(); if (rtf.SelectionColor != null) { _style.Color = rtf.SelectionColor; } if (rtf.SelectionFont != null) { _style.FontFamily = rtf.SelectionFont.Name; _style.FontSize = rtf.SelectionFont.Size; _style.FontStyle = rtf.SelectionFont.Style; } _style.HorizontalAlignment = rtf.SelectionAlignment; _style.StyleName = _f.InputText; StyleCollection.Instance.Styles.Add(_style); _FontStyleComboBoxHelper.Add(_style); SetButtons(); } }
private void RemoveStyle_Click(object sender, EventArgs e) { if (!_FontStyleComboBoxHelper.HasSelection()) { return; } RtfControlStyle _style = _FontStyleComboBoxHelper.GetSelected(); _FontStyleComboBoxHelper.Remove(_style); StyleCollection.Instance.Styles.Remove(_style); SetButtons(); }
private void _FontStyleComboBoxHelper_ManualSelectedIndexChanged(object sender, EventArgs e) { RtfControlStyle _item = cbStyles.SelectedItem as RtfControlStyle; if (_item == null) { return; } Font _f = new Font(_item.FontFamily, _item.FontSize, _item.FontStyle); rtf.SelectionFont = _f; if (_item.Color.HasValue) { rtf.SelectionColor = _item.Color.Value; } rtf.SelectionAlignment = _item.HorizontalAlignment; }