diff --git a/ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs b/ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs new file mode 100644 index 0000000..00c52b1 --- /dev/null +++ b/ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs @@ -0,0 +1,21 @@ +using System.Drawing; +using System.Windows.Forms; + +namespace BulePointLilac.Methods +{ + public static class TextBoxExtension + { + /// TextBox仿RichTextBox按住Ctrl加鼠标滚轮放缩字体 + public static void CanResizeFont(this TextBox box) + { + box.MouseWheel += (sender, e) => + { + if(Control.ModifierKeys != Keys.Control) return; + float size = box.Font.Size; + if(size < 8F && e.Delta < 0) return; + if(size > 40F && e.Delta > 0) return; + box.Font = new Font(box.Font.FontFamily, size + (e.Delta > 0 ? 1 : -1)); + }; + } + } +} \ No newline at end of file