예제 #1
0
        private void format_formatCodeButton_Click(object sender, EventArgs e)
        {
            if (activeRichTextBox == null)
            {
                return;
            }

            Font f;

            if (MainContent.GetFontFromStyleString("Code Fragment", out f))
            {
                if (activeRichTextBox.SelectedText != "" && format_languageSelector.SelectedItem != null)
                {
                    activeRichTextBox.SelectionFont = f;

                    int s = activeRichTextBox.SelectionStart;
                    int l = activeRichTextBox.SelectionLength;
                    activeRichTextBox.SelectedText = activeRichTextBox.SelectedText.Replace("\t", "   ");
                    RtfCodeFormatter.FormatCodeFragment(format_languageSelector.SelectedItem.ToString(), ref activeRichTextBox, s, s + l);

                    activeRichTextBox.SelectionStart  = activeRichTextBox.SelectionStart + activeRichTextBox.SelectionLength;
                    activeRichTextBox.SelectionLength = 0;
                    activeRichTextBox.SelectionFont   = activeRichTextBox.Font;
                }
            }
        }
예제 #2
0
        private void format_textStyleSelector_SelectedIndexChanged(object sender, EventArgs e)
        {
            Font f;

            if (MainContent.GetFontFromStyleString(format_textStyleSelector.SelectedItem.ToString(), out f))
            {
                if (activeRichTextBox != null)
                {
                    activeRichTextBox.SelectionFont = f;
                }
            }
        }