コード例 #1
0
 public string GetSignature(
     string FamilyName,
     float size,
     System.Drawing.FontStyle theStyle)
 {
     return(FamilyName + size.ToString() + theStyle.ToString());
 }
コード例 #2
0
        // 重载:设置字形
        private void SetFont(FontStyle style, char c)
        {
            Font ft;

            inputTextBox.Text = mainRichTextBox.SelectionStart.ToString();
            int start = mainRichTextBox.SelectionStart;
            int end   = mainRichTextBox.SelectionStart + mainRichTextBox.SelectionLength - 1;

            for (int i = start; i <= end; i++)
            {
                mainRichTextBox.Select(i, 1);
                ft = mainRichTextBox.SelectionFont;
                System.Drawing.FontStyle fs = ft.Style;

                if (c == '+')
                {
                    fs = (System.Drawing.FontStyle)(fs | style);
                }
                else
                {
                    fs = (System.Drawing.FontStyle)(fs - style);
                }

                if (fs.ToString().IndexOf("Strikeout") >= 0)
                {
                    fs = (System.Drawing.FontStyle)(fs - FontStyle.Strikeout);
                }

                ft = new Font(ft.Name, ft.Size, fs);
                mainRichTextBox.SelectionFont = ft;
            }
            mainRichTextBox.Select(start, end - start + 1);
            mainRichTextBox.Focus();
        }