From 0f8382576d827d2c803f41dab40de658ff4d0b33 Mon Sep 17 00:00:00 2001 From: zqm Date: Thu, 30 Oct 2025 09:58:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=9A=82=E5=81=9C=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=97=B6=E5=9C=A8InfoImage=E4=B8=AD=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=9A=82=E5=81=9C=E5=AD=97=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CS/Framework4.0/Toprie/Toprie/Camera.cs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs index 08b3a55..67c7a7d 100644 --- a/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs +++ b/Windows/CS/Framework4.0/Toprie/Toprie/Camera.cs @@ -93,12 +93,75 @@ namespace JoyD.Windows.CS.Toprie { pauseImageUpdateToolStripMenuItem.Text = "恢复图像更新"; Console.WriteLine("图像更新已暂停"); + + // 在InfoImage中绘制暂停字样 + lock (_infoImageLock) + { + // 释放之前的InfoImage资源 + if (_infoImage != null) + { + try + { + _infoImage.Dispose(); + } + catch (Exception ex) + { + Console.WriteLine($"释放InfoImage资源异常: {ex.Message}"); + } + } + + // 创建新的InfoImage并绘制暂停字样 + _infoImage = new Bitmap(BUFFER_WIDTH, BUFFER_HEIGHT); + using (Graphics g = Graphics.FromImage(_infoImage)) + { + // 设置半透明背景 + using (SolidBrush brush = new SolidBrush(Color.FromArgb(128, Color.Black))) + { + g.FillRectangle(brush, 0, 0, BUFFER_WIDTH, BUFFER_HEIGHT); + } + + // 绘制暂停字样 + using (Font font = new Font("Arial", 48, FontStyle.Bold)) + using (SolidBrush textBrush = new SolidBrush(Color.Red)) + { + StringFormat format = new StringFormat(); + format.Alignment = StringAlignment.Center; + format.LineAlignment = StringAlignment.Center; + g.DrawString("暂停", font, textBrush, new RectangleF(0, 0, BUFFER_WIDTH, BUFFER_HEIGHT), format); + } + } + } + + // 设置显示信息标志并更新UI + _isDisplayingInfo = true; + UpdateImageOnUI(); } else { pauseImageUpdateToolStripMenuItem.Text = "暂停图像更新"; Console.WriteLine("图像更新已恢复"); + // 清除InfoImage和显示标志 + lock (_infoImageLock) + { + if (_infoImage != null) + { + try + { + _infoImage.Dispose(); + _infoImage = null; + } + catch (Exception ex) + { + Console.WriteLine($"释放InfoImage资源异常: {ex.Message}"); + } + } + } + _isDisplayingInfo = false; + + // 立即更新UI + UpdateImageOnUI(); + // 恢复时,立即停止并重新开始图像接收,确保获取最新图像 if (_isReceivingImage && _deviceManager != null) {