From 798443424342afb9096c4e2702577d5493013177 Mon Sep 17 00:00:00 2001 From: zqm Date: Thu, 30 Oct 2025 08:38:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=9C=A8=E6=9A=82=E5=81=9C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E4=B8=8B=E5=9C=A8=E9=81=AE=E7=BD=A9=E5=B1=82?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=9A=82=E5=81=9C=E5=AD=97=E6=A0=B7=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CS/Framework4.0/Toprie/Toprie/Camera.cs | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs index 5a5d3e8..4352580 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs @@ -77,11 +77,15 @@ namespace JoyD.Windows.CS.Toprie { pauseImageUpdateToolStripMenuItem.Text = "恢复图像更新"; Console.WriteLine("图像更新已暂停"); + // 显示暂停遮罩 + UpdateMaskDisplay(); } else { pauseImageUpdateToolStripMenuItem.Text = "暂停图像更新"; Console.WriteLine("图像更新已恢复"); + // 清除暂停遮罩 + UpdateMaskDisplay(); // 恢复时,立即停止并重新开始图像接收,确保获取最新图像 if (_isReceivingImage && _deviceManager != null) @@ -96,6 +100,72 @@ namespace JoyD.Windows.CS.Toprie Console.WriteLine($"处理暂停/恢复图像更新时出错: {ex.Message}"); } } + + /// + /// 更新遮罩层的显示内容 + /// + private void UpdateMaskDisplay() + { + try + { + if (_isImageUpdatePaused) + { + // 创建一个与maskImageBox大小相同的位图 + Bitmap bitmap = new Bitmap(maskImageBox.Width, maskImageBox.Height); + using (Graphics g = Graphics.FromImage(bitmap)) + { + // 设置半透明背景 + using (Brush brush = new SolidBrush(Color.FromArgb(100, Color.Black))) + { + g.FillRectangle(brush, 0, 0, bitmap.Width, bitmap.Height); + } + + // 设置文本样式 + Font font = new Font("微软雅黑", 36, FontStyle.Bold); + Brush textBrush = new SolidBrush(Color.White); + StringFormat format = new StringFormat(); + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Center; + + // 绘制"暂停"文字 + g.DrawString("暂停", font, textBrush, + new Rectangle(0, 0, bitmap.Width, bitmap.Height), format); + } + + // 在UI线程上更新maskImageBox + if (maskImageBox.InvokeRequired) + { + maskImageBox.Invoke(new Action(() => + { + maskImageBox.Image = bitmap; + })); + } + else + { + maskImageBox.Image = bitmap; + } + } + else + { + // 清除遮罩 + if (maskImageBox.InvokeRequired) + { + maskImageBox.Invoke(new Action(() => + { + maskImageBox.Image = null; + })); + } + else + { + maskImageBox.Image = null; + } + } + } + catch (Exception ex) + { + Console.WriteLine($"更新遮罩显示时出错: {ex.Message}"); + } + } public Camera() {