添加在暂停状态下在遮罩层显示暂停字样的功能
This commit is contained in:
@@ -77,11 +77,15 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
{
|
{
|
||||||
pauseImageUpdateToolStripMenuItem.Text = "恢复图像更新";
|
pauseImageUpdateToolStripMenuItem.Text = "恢复图像更新";
|
||||||
Console.WriteLine("图像更新已暂停");
|
Console.WriteLine("图像更新已暂停");
|
||||||
|
// 显示暂停遮罩
|
||||||
|
UpdateMaskDisplay();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pauseImageUpdateToolStripMenuItem.Text = "暂停图像更新";
|
pauseImageUpdateToolStripMenuItem.Text = "暂停图像更新";
|
||||||
Console.WriteLine("图像更新已恢复");
|
Console.WriteLine("图像更新已恢复");
|
||||||
|
// 清除暂停遮罩
|
||||||
|
UpdateMaskDisplay();
|
||||||
|
|
||||||
// 恢复时,立即停止并重新开始图像接收,确保获取最新图像
|
// 恢复时,立即停止并重新开始图像接收,确保获取最新图像
|
||||||
if (_isReceivingImage && _deviceManager != null)
|
if (_isReceivingImage && _deviceManager != null)
|
||||||
@@ -97,6 +101,72 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新遮罩层的显示内容
|
||||||
|
/// </summary>
|
||||||
|
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()
|
public Camera()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|||||||
Reference in New Issue
Block a user