修复设计模式下控件仍连接设备并更新图像的问题:修改DeviceManager的ConnectDevice和Initialize方法,在设计模式下不设置连接成功状态
This commit is contained in:
@@ -508,13 +508,13 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
{
|
{
|
||||||
Log($"[{DateTime.Now:HH:mm:ss.fff}] [线程:{Thread.CurrentThread.ManagedThreadId}] Initialize() - 开始执行初始化");
|
Log($"[{DateTime.Now:HH:mm:ss.fff}] [线程:{Thread.CurrentThread.ManagedThreadId}] Initialize() - 开始执行初始化");
|
||||||
|
|
||||||
// 在设计模式下,跳过实际初始化,直接返回成功
|
// 在设计模式下,跳过实际初始化,不设置连接成功状态
|
||||||
if (IsDesignMode)
|
if (IsDesignMode)
|
||||||
{
|
{
|
||||||
Log("设计模式下跳过实际初始化,模拟初始化成功");
|
Log("设计模式下跳过实际初始化");
|
||||||
_isInitialized = true;
|
_isInitialized = true; // 仍然标记为已初始化,避免重复初始化
|
||||||
_connectionStatus = ConnectionStatus.Connected;
|
_connectionStatus = ConnectionStatus.Disconnected; // 设置为断开状态,避免触发图像接收
|
||||||
return true;
|
return false; // 返回false,避免Camera认为初始化成功
|
||||||
}
|
}
|
||||||
|
|
||||||
// 双重检查锁定模式,确保线程安全的初始化
|
// 双重检查锁定模式,确保线程安全的初始化
|
||||||
@@ -2965,14 +2965,15 @@ namespace JoyD.Windows.CS.Toprie
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 在设计模式下,跳过实际连接,直接模拟连接成功
|
// 在设计模式下,跳过实际连接,不设置真实的连接状态
|
||||||
if (IsDesignMode)
|
if (IsDesignMode)
|
||||||
{
|
{
|
||||||
Log("设计模式下跳过实际设备连接,模拟连接成功");
|
Log("设计模式下跳过实际设备连接");
|
||||||
|
// 不设置真实的连接状态,避免触发图像接收
|
||||||
_currentDeviceId = deviceId;
|
_currentDeviceId = deviceId;
|
||||||
_isConnected = true;
|
_isConnected = false;
|
||||||
_connectionStatus = ConnectionStatus.Connected;
|
_connectionStatus = ConnectionStatus.Disconnected;
|
||||||
UpdateConnectionStatus(ConnectionStatus.Connected, "设计模式:设备模拟连接成功");
|
UpdateConnectionStatus(ConnectionStatus.Disconnected, "设计模式:跳过设备连接");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user