From aca5e163c189e9b700fffd0249f3eff5ebacfdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Tue, 24 Nov 2020 05:14:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86TextBox=E9=BC=A0=E6=A0=87=E6=BB=9A?= =?UTF-8?q?=E8=BD=AE=E7=BC=A9=E6=94=BE=E5=AD=97=E4=BD=93=E5=86=99=E4=B8=BA?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TextBoxExtension.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs 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