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() {