From 8432703382e0b2d0bbe9e5ea3e2c6fea1ba735cd Mon Sep 17 00:00:00 2001 From: tylearymf Date: Wed, 6 Jan 2021 22:53:05 +0800 Subject: [PATCH] =?UTF-8?q?Update=20#16=20=E6=94=AF=E6=8C=81=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E9=BC=A0=E6=A0=87=E6=8C=87=E9=92=88=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SETUNA/Main/CaptureForm.cs | 16 ++++-- SETUNA/Main/Common/WindowsAPI.cs | 34 ++++++++++++ SETUNA/Main/Option/OptionForm.Designer.cs | 65 +++++++++++++++++++++++ SETUNA/Main/Option/OptionForm.cs | 22 ++++++++ SETUNA/Main/Option/SetunaOption.cs | 4 ++ SETUNA/Properties/AssemblyInfo.cs | 2 +- 6 files changed, 139 insertions(+), 4 deletions(-) diff --git a/SETUNA/Main/CaptureForm.cs b/SETUNA/Main/CaptureForm.cs index ca3c6e4..9870aee 100644 --- a/SETUNA/Main/CaptureForm.cs +++ b/SETUNA/Main/CaptureForm.cs @@ -152,7 +152,7 @@ public void ShowCapture(SetunaOption.SetunaOptionData opt) { return; } - Cursor.Current = Cursors.Cross; + //Cursor.Current = Cursors.Cross; targetScreen = GetCurrentScreen(); if (targetScreen.Bounds.Width != CaptureForm.imgSnap.Width || targetScreen.Bounds.Height != CaptureForm.imgSnap.Height) { @@ -255,6 +255,7 @@ private void ThreadTask() var flag = CaptureForm.CopyFromScreen(CaptureForm.imgSnap, new Point(targetScreen.Bounds.X, targetScreen.Bounds.Y)); if (flag) { + Cursor.Current = Cursors.Cross; base.Invoke(new CaptureForm.ShowFormDelegate(ShowForm)); return; } @@ -266,19 +267,26 @@ public static bool CopyFromScreen(Image img, Point location) { var result = true; var intPtr = IntPtr.Zero; + Graphics graphics = null; try { intPtr = CaptureForm.GetDC(IntPtr.Zero); - using (var graphics = Graphics.FromImage(img)) + graphics = Graphics.FromImage(img); { var intPtr2 = IntPtr.Zero; try { intPtr2 = graphics.GetHdc(); CaptureForm.BitBlt(intPtr2, 0, 0, img.Width, img.Height, intPtr, location.X, location.Y, 1087111200); + + if (Mainform.Instance.optSetuna.Setuna.CursorEnabled) + { + WindowsAPI.DrawCursorImageToScreenImage(intPtr2); + } } catch (Exception ex) { + Console.WriteLine(ex); throw ex; } finally @@ -292,11 +300,13 @@ public static bool CopyFromScreen(Image img, Point location) } catch (Exception ex2) { - Console.WriteLine(ex2.Message); + Console.WriteLine(ex2); result = false; } finally { + graphics.Dispose(); + if (intPtr != IntPtr.Zero) { CaptureForm.DeleteDC(intPtr); diff --git a/SETUNA/Main/Common/WindowsAPI.cs b/SETUNA/Main/Common/WindowsAPI.cs index 1984303..4be5eee 100644 --- a/SETUNA/Main/Common/WindowsAPI.cs +++ b/SETUNA/Main/Common/WindowsAPI.cs @@ -1,5 +1,6 @@  using System; +using System.Drawing; using System.Runtime.InteropServices; using System.Text; @@ -123,6 +124,29 @@ public static IntPtr GetTopMostWindow(IntPtr hWnd_mainFrm) [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr hwnd, ref Rect rectangle); + + + + private const int CURSOR_SHOWING = 0x00000001; + [DllImport("user32.dll")] + static extern bool GetCursorInfo(out CURSORINFO pci); + [DllImport("user32.dll")] + static extern bool DrawIcon(IntPtr hDC, int X, int Y, IntPtr hIcon); + + /// + /// 将鼠标指针形状绘制到屏幕截图上 + /// + /// + public static void DrawCursorImageToScreenImage(IntPtr hDC) + { + CURSORINFO vCurosrInfo; + vCurosrInfo.cbSize = Marshal.SizeOf(typeof(CURSORINFO)); + GetCursorInfo(out vCurosrInfo); + if (vCurosrInfo.flags == CURSOR_SHOWING) + { + DrawIcon(hDC, vCurosrInfo.ptScreenPos.X, vCurosrInfo.ptScreenPos.Y, vCurosrInfo.hCursor); + } + } } public struct Rect @@ -132,4 +156,14 @@ public struct Rect public int Right { get; set; } public int Bottom { get; set; } } + + + [StructLayout(LayoutKind.Sequential)] + struct CURSORINFO + { + public int cbSize; + public int flags; + public IntPtr hCursor; + public Point ptScreenPos; + } } diff --git a/SETUNA/Main/Option/OptionForm.Designer.cs b/SETUNA/Main/Option/OptionForm.Designer.cs index 78cbe8a..874bbc9 100644 --- a/SETUNA/Main/Option/OptionForm.Designer.cs +++ b/SETUNA/Main/Option/OptionForm.Designer.cs @@ -110,7 +110,11 @@ private void InitializeComponent() this.listScrapMenuItems = new SETUNA.Main.SetunaListBox(); this.groupBox8 = new System.Windows.Forms.GroupBox(); this.listScrapMenuStyles = new SETUNA.Main.SetunaListBox(); + this.pageMisc = new System.Windows.Forms.TabPage(); + this.groupBox14 = new System.Windows.Forms.GroupBox(); + this.checkBox_cursor = new System.Windows.Forms.CheckBox(); this.panel1 = new System.Windows.Forms.Panel(); + this.lblMenuMisc = new System.Windows.Forms.Label(); this.lblMenuStyle = new System.Windows.Forms.Label(); this.lblMenuCapture = new System.Windows.Forms.Label(); this.lblMenuMenu = new System.Windows.Forms.Label(); @@ -149,6 +153,8 @@ private void InitializeComponent() this.groupBox10.SuspendLayout(); this.groupBox9.SuspendLayout(); this.groupBox8.SuspendLayout(); + this.pageMisc.SuspendLayout(); + this.groupBox14.SuspendLayout(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); @@ -228,6 +234,7 @@ private void InitializeComponent() this.tabControl1.Controls.Add(this.pageScrap); this.tabControl1.Controls.Add(this.pageStyle); this.tabControl1.Controls.Add(this.pageScrapMenu); + this.tabControl1.Controls.Add(this.pageMisc); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); this.tabControl1.Margin = new System.Windows.Forms.Padding(0); @@ -1298,9 +1305,45 @@ private void InitializeComponent() this.listScrapMenuStyles.Enter += new System.EventHandler(this.listScrapMenuStyles_Enter); this.listScrapMenuStyles.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listScrapMenuStyles_MouseDoubleClick); // + // pageMisc + // + this.pageMisc.BackColor = System.Drawing.Color.White; + this.pageMisc.Controls.Add(this.groupBox14); + this.pageMisc.Location = new System.Drawing.Point(4, 28); + this.pageMisc.Name = "pageMisc"; + this.pageMisc.Padding = new System.Windows.Forms.Padding(3); + this.pageMisc.Size = new System.Drawing.Size(588, 413); + this.pageMisc.TabIndex = 5; + this.pageMisc.Text = "杂项设置"; + // + // groupBox14 + // + this.groupBox14.Controls.Add(this.checkBox_cursor); + this.groupBox14.Location = new System.Drawing.Point(7, 7); + this.groupBox14.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.groupBox14.Name = "groupBox14"; + this.groupBox14.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.groupBox14.Size = new System.Drawing.Size(574, 92); + this.groupBox14.TabIndex = 12; + this.groupBox14.TabStop = false; + this.groupBox14.Text = "样式"; + // + // checkBox_cursor + // + this.checkBox_cursor.AutoSize = true; + this.checkBox_cursor.Location = new System.Drawing.Point(38, 38); + this.checkBox_cursor.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.checkBox_cursor.Name = "checkBox_cursor"; + this.checkBox_cursor.Size = new System.Drawing.Size(89, 19); + this.checkBox_cursor.TabIndex = 6; + this.checkBox_cursor.Text = "显示鼠标"; + this.toolTip1.SetToolTip(this.checkBox_cursor, "截图时是否显示鼠标"); + this.checkBox_cursor.UseVisualStyleBackColor = true; + // // panel1 // this.panel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(81)))), ((int)(((byte)(163)))), ((int)(((byte)(236))))); + this.panel1.Controls.Add(this.lblMenuMisc); this.panel1.Controls.Add(this.lblMenuStyle); this.panel1.Controls.Add(this.lblMenuCapture); this.panel1.Controls.Add(this.lblMenuMenu); @@ -1314,6 +1357,21 @@ private void InitializeComponent() this.panel1.Size = new System.Drawing.Size(172, 450); this.panel1.TabIndex = 1; // + // lblMenuMisc + // + this.lblMenuMisc.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(46)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); + this.lblMenuMisc.Cursor = System.Windows.Forms.Cursors.Hand; + this.lblMenuMisc.ForeColor = System.Drawing.Color.White; + this.lblMenuMisc.Location = new System.Drawing.Point(16, 138); + this.lblMenuMisc.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.lblMenuMisc.Name = "lblMenuMisc"; + this.lblMenuMisc.Size = new System.Drawing.Size(133, 17); + this.lblMenuMisc.TabIndex = 6; + this.lblMenuMisc.Text = "杂项设置"; + this.lblMenuMisc.Click += new System.EventHandler(this.lblMenuMisc_Click); + this.lblMenuMisc.MouseEnter += new System.EventHandler(this.lblMenuMisc_MouseEnter); + this.lblMenuMisc.MouseLeave += new System.EventHandler(this.lblMenuMisc_MouseLeave); + // // lblMenuStyle // this.lblMenuStyle.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(46)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -1466,6 +1524,9 @@ private void InitializeComponent() this.groupBox10.ResumeLayout(false); this.groupBox9.ResumeLayout(false); this.groupBox8.ResumeLayout(false); + this.pageMisc.ResumeLayout(false); + this.groupBox14.ResumeLayout(false); + this.groupBox14.PerformLayout(); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); @@ -1760,5 +1821,9 @@ private void InitializeComponent() private System.Windows.Forms.Button button2; private HotkeyControl hotkeyControl2; private System.Windows.Forms.Label label17; + private System.Windows.Forms.TabPage pageMisc; + private System.Windows.Forms.Label lblMenuMisc; + private System.Windows.Forms.CheckBox checkBox_cursor; + private System.Windows.Forms.GroupBox groupBox14; } } diff --git a/SETUNA/Main/Option/OptionForm.cs b/SETUNA/Main/Option/OptionForm.cs index f09f008..71943e6 100644 --- a/SETUNA/Main/Option/OptionForm.cs +++ b/SETUNA/Main/Option/OptionForm.cs @@ -72,6 +72,7 @@ private void LoadSetunaOption() checkBox_topMost.Checked = _so.Setuna.TopMostEnabled; checkBox_autoStartup.Checked = Startup.AutoStartup.IsSetup(); + checkBox_cursor.Checked = _so.Setuna.CursorEnabled; } // Token: 0x060002D5 RID: 725 RVA: 0x00013908 File Offset: 0x00011B08 @@ -138,6 +139,7 @@ private void WriteSetunaOption() _so.Setuna.TopMostEnabled = checkBox_topMost.Checked; Startup.AutoStartup.Set(checkBox_autoStartup.Checked); + _so.Setuna.CursorEnabled = checkBox_cursor.Checked; } // Token: 0x060002D6 RID: 726 RVA: 0x00013D84 File Offset: 0x00011F84 @@ -197,6 +199,7 @@ private void tabControl1_TabIndexChanged(object sender, EventArgs e) lblMenuScrap.Font = new Font(lblMenuScrap.Font, FontStyle.Regular); lblMenuStyle.Font = new Font(lblMenuStyle.Font, FontStyle.Regular); lblMenuMenu.Font = new Font(lblMenuMenu.Font, FontStyle.Regular); + lblMenuMisc.Font = new Font(lblMenuMisc.Font, FontStyle.Regular); if (tabControl1.SelectedTab == pageAll) { lblMenuAll.Font = new Font(lblMenuAll.Font, FontStyle.Bold); @@ -219,6 +222,10 @@ private void tabControl1_TabIndexChanged(object sender, EventArgs e) RefreshScrapMenuStyleList_Menu(); RefreshScrapMenuList_Menu(GetStyleIDList_Menu()); } + if (tabControl1.SelectedTab == pageMisc) + { + lblMenuMisc.Font = new Font(lblMenuMisc.Font, FontStyle.Bold); + } } // Token: 0x060002D9 RID: 729 RVA: 0x00014108 File Offset: 0x00012308 @@ -764,5 +771,20 @@ private void button2_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start(Cache.CacheManager.Path); } + + private void lblMenuMisc_Click(object sender, EventArgs e) + { + tabControl1.SelectedTab = pageMisc; + } + + private void lblMenuMisc_MouseEnter(object sender, EventArgs e) + { + lblComment.Text = "鼠标样式设置等等。"; + } + + private void lblMenuMisc_MouseLeave(object sender, EventArgs e) + { + lblComment.Text = ""; + } } } diff --git a/SETUNA/Main/Option/SetunaOption.cs b/SETUNA/Main/Option/SetunaOption.cs index 64f9042..60c6466 100644 --- a/SETUNA/Main/Option/SetunaOption.cs +++ b/SETUNA/Main/Option/SetunaOption.cs @@ -42,6 +42,7 @@ public static SetunaOption GetDefaultOption() setunaOption.Setuna.TopMostEnabled = false; + setunaOption.Setuna.CursorEnabled = false; var cstyle = new CStyle @@ -1020,6 +1021,7 @@ public SetunaOptionData() ClickCapture2 = false; ClickCapture3 = false; TopMostEnabled = false; + CursorEnabled = false; } // Token: 0x17000072 RID: 114 @@ -1098,6 +1100,8 @@ public SetunaOptionData() public bool TopMostEnabled; + public bool CursorEnabled; + // Token: 0x02000052 RID: 82 public enum ApplicationType { diff --git a/SETUNA/Properties/AssemblyInfo.cs b/SETUNA/Properties/AssemblyInfo.cs index bdcc75b..33b3d7e 100644 --- a/SETUNA/Properties/AssemblyInfo.cs +++ b/SETUNA/Properties/AssemblyInfo.cs @@ -13,4 +13,4 @@ [assembly: AssemblyDescription("")] [assembly: AssemblyCompany("clearup")] [assembly: NeutralResourcesLanguage("zh-CN")] -[assembly: AssemblyVersion("3.0.0.2")] +[assembly: AssemblyVersion("3.0.0.3")]