增加关闭方法
This commit is contained in:
@@ -213,6 +213,92 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭相机并完全释放所有资源
|
||||||
|
/// </summary>
|
||||||
|
[Category("控制")]
|
||||||
|
[DisplayName("关闭相机")]
|
||||||
|
[Description("关闭相机并完全释放所有资源")]
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 停止相机并释放相关资源
|
||||||
|
StopCamera();
|
||||||
|
|
||||||
|
// 关闭设置窗口
|
||||||
|
Setting.Form.Close();
|
||||||
|
|
||||||
|
// 取消注册事件并释放设备管理器
|
||||||
|
if (_deviceManager != null)
|
||||||
|
{
|
||||||
|
// 移除所有事件监听
|
||||||
|
_deviceManager.ImageReceived -= DeviceManager_ImageReceived;
|
||||||
|
_deviceManager.ConnectionStatusChanged -= DeviceManager_ConnectionStatusChanged;
|
||||||
|
_deviceManager.ConnectionException -= DeviceManager_ConnectionException;
|
||||||
|
|
||||||
|
// 释放设备管理器资源
|
||||||
|
_deviceManager.Dispose();
|
||||||
|
_deviceManager = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放Ping定时器
|
||||||
|
if (_pingTimer != null)
|
||||||
|
{
|
||||||
|
_pingTimer.Dispose();
|
||||||
|
_pingTimer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放图像控件资源
|
||||||
|
if (imageBox != null && !imageBox.IsDisposed && imageBox.Image != null)
|
||||||
|
{
|
||||||
|
imageBox.Image.Dispose();
|
||||||
|
imageBox.Image = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放图像缓冲区资源
|
||||||
|
if (_imageBuffer != null)
|
||||||
|
{
|
||||||
|
_imageBuffer.Dispose();
|
||||||
|
_imageBuffer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放LastImage资源
|
||||||
|
lock (_lastImageLock)
|
||||||
|
{
|
||||||
|
if (_lastImage != null)
|
||||||
|
{
|
||||||
|
_lastImage.Dispose();
|
||||||
|
_lastImage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放InfoImage资源
|
||||||
|
lock (_infoImageLock)
|
||||||
|
{
|
||||||
|
if (_infoImage != null)
|
||||||
|
{
|
||||||
|
_infoImage.Dispose();
|
||||||
|
_infoImage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 释放DisplayImage资源
|
||||||
|
lock (_displayImageLock)
|
||||||
|
{
|
||||||
|
if (_displayImage != null)
|
||||||
|
{
|
||||||
|
_displayImage.Dispose();
|
||||||
|
_displayImage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"关闭相机时出错: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取指定测温区的温度值
|
/// 获取指定测温区的温度值
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -33,6 +33,6 @@ using System.Runtime.InteropServices;
|
|||||||
//通过使用 "*",如下所示:
|
//通过使用 "*",如下所示:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.2.0")]
|
[assembly: AssemblyVersion("1.0.2.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.2.3")]
|
[assembly: AssemblyFileVersion("1.0.2.4")]
|
||||||
|
|
||||||
// NuGet包相关信息已在项目文件中配置
|
// NuGet包相关信息已在项目文件中配置
|
||||||
|
|||||||
Reference in New Issue
Block a user