Restore tool focus by picking context

This commit is contained in:
tian 2026-04-02 22:35:58 +08:00
parent 4ec4cf77ee
commit 9be5d250e8
2 changed files with 28 additions and 1 deletions

View File

@ -49,7 +49,7 @@ namespace NavisworksTransport
if (currentTool != Tool.CustomToolPlugin)
{
LogManager.Info($"[InputMonitor] 用户按空格键,当前工具为{currentTool}强制恢复ToolPlugin焦点");
bool restored = pathManager.ForceReinitializeToolPlugin(subscribeToEvents: false);
bool restored = pathManager.RestoreToolPluginFocusForCurrentContext();
if (restored)
{
return true;

View File

@ -4562,6 +4562,33 @@ namespace NavisworksTransport
}
}
/// <summary>
/// 根据当前业务上下文恢复 ToolPlugin 焦点。
/// 普通手动建/编辑路径应恢复 PathPlanningManager 主链;
/// 自动路径、装配拾取、多层吊装等外部自管拾取模式则保持外部事件处理。
/// </summary>
public bool RestoreToolPluginFocusForCurrentContext()
{
try
{
bool shouldSubscribeToManagerEvents = !IsInAutoPathMode;
string contextLabel = shouldSubscribeToManagerEvents
? "普通手动取点"
: "外部自管拾取";
LogManager.Info(
$"[工具插件恢复] 按当前上下文恢复焦点: 模式={contextLabel}, " +
$"PathEditState={PathEditState}, 订阅PathPlanningManager事件={shouldSubscribeToManagerEvents}");
return ForceReinitializeToolPlugin(shouldSubscribeToManagerEvents);
}
catch (Exception ex)
{
LogManager.Error($"[工具插件恢复] 按当前上下文恢复焦点失败: {ex.Message}", ex);
return false;
}
}
#endregion
#region