From 2cecf3071e7cded5181430c0f1fc0f36422d09bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Sun, 14 Mar 2021 05:09:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BluePointLilac.Methods/ControlExtension.cs | 14 +++++++++++--- .../BluePointLilac.Methods/ImageExtension.cs | 3 +++ ContextMenuManager/ContextMenuManager.csproj | 4 ++++ ContextMenuManager/Controls/NewShellDialog.cs | 4 +++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs b/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs index 04ad777..8322140 100644 --- a/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs +++ b/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs @@ -8,19 +8,27 @@ namespace BluePointLilac.Methods { [DllImport("user32.dll")] private static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + [DllImport("user32.dll")] private static extern bool ReleaseCapture(); private const int WM_NCLBUTTONDOWN = 0xA1; private const int HT_CAPTION = 0x2; /// 使控件能够移动所属窗体 - /// 副作用:使用此方法将无法触发Click等事件 /// 目标控件 public static void CanMoveForm(this Control ctr) { - ctr.MouseDown += (sender, e) => + DateTime downTime = DateTime.MinValue; + DateTime upTime = DateTime.MinValue; + ctr.MouseDown += (sender, e) => downTime = DateTime.Now; + ctr.MouseUp += (sender, e) => upTime = DateTime.Now; + ctr.MouseMove += (sender, e) => { - if(e.Button == MouseButtons.Left && ctr.FindForm().WindowState == FormWindowState.Normal) + foreach(DateTime time in new[] { downTime, upTime }) + { + if((DateTime.Now - time).TotalMilliseconds < 20) return; + } + if(e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(ctr.FindForm().Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); diff --git a/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs b/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs index f7f0074..a33ea18 100644 --- a/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs +++ b/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs @@ -22,6 +22,7 @@ namespace BluePointLilac.Methods public static Image ResizeImage(this Image image, int width, int height) { + if(image.Width == width && image.Height == height) return image; Bitmap destImage = new Bitmap(width, height); destImage.SetResolution(image.HorizontalResolution, image.VerticalResolution); using(Graphics g = Graphics.FromImage(destImage)) @@ -44,6 +45,7 @@ namespace BluePointLilac.Methods public static Image ResizeImage(this Image image, double scale) { + if(scale == 1) return image; int width = (int)(image.Width * scale); int height = (int)(image.Height * scale); return image.ResizeImage(width, height); @@ -51,6 +53,7 @@ namespace BluePointLilac.Methods public static Image ResizeImage(this Image image, Size newSize) { + if(newSize == image.Size) return image; return image.ResizeImage(newSize.Width, newSize.Height); } diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj index bd0910d..bd31b2e 100644 --- a/ContextMenuManager/ContextMenuManager.csproj +++ b/ContextMenuManager/ContextMenuManager.csproj @@ -114,6 +114,10 @@ + + + Form + Component diff --git a/ContextMenuManager/Controls/NewShellDialog.cs b/ContextMenuManager/Controls/NewShellDialog.cs index 66d4461..06f82d9 100644 --- a/ContextMenuManager/Controls/NewShellDialog.cs +++ b/ContextMenuManager/Controls/NewShellDialog.cs @@ -103,8 +103,9 @@ namespace ContextMenuManager.Controls { using(OpenFileDialog dlg = new OpenFileDialog()) { - dlg.Filter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.pif;*.com;*.vbs;*.vbe;*.js;*.jse;*.wsf"; + dlg.Filter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.vbs;*.vbe;*.js;*.jse;*.wsf"; if(dlg.ShowDialog() != DialogResult.OK) return; + Arguments = string.Empty; ItemText = Path.GetFileNameWithoutExtension(dlg.FileName); string extension = Path.GetExtension(dlg.FileName).ToLower(); switch(extension) @@ -114,6 +115,7 @@ namespace ContextMenuManager.Controls case ".js": case ".jse": case ".wsf": + chkSE.Checked = true; ItemFilePath = "wscript.exe"; Arguments = dlg.FileName; break;