将“分层管理”的消息提示和进度条迁移到状态栏
This commit is contained in:
parent
ba01624152
commit
3341ef82b7
@ -90,7 +90,8 @@ NavisworksTransport 主控制面板 - 采用与其他视图一致的Navisworks 2
|
||||
<!-- 左侧:状态信息 -->
|
||||
<Grid Grid.Column="0" Margin="8,6,20,6">
|
||||
<ProgressBar Height="20"
|
||||
IsIndeterminate="{Binding IsProcessing}"
|
||||
Value="{Binding ProgressPercentage}"
|
||||
IsIndeterminate="{Binding IsIndeterminateProgress}"
|
||||
Visibility="{Binding IsProcessing, Converter={StaticResource BoolToVisConverter}}"/>
|
||||
|
||||
<TextBlock Text="{Binding StatusText}"
|
||||
|
||||
@ -55,8 +55,8 @@ namespace NavisworksTransport.UI.WPF
|
||||
{
|
||||
LogManager.Info("开始初始化子视图");
|
||||
|
||||
// 创建分层管理视图
|
||||
_layerManagementView = new LayerManagementView();
|
||||
// 创建分层管理视图,传入主ViewModel以启用统一状态栏
|
||||
_layerManagementView = new LayerManagementView(ViewModel);
|
||||
|
||||
// 将分层管理视图添加到主界面
|
||||
LayerManagementContent.Content = _layerManagementView;
|
||||
|
||||
@ -43,6 +43,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private readonly ModelSplitterManager _modelSplitterManager;
|
||||
private readonly AttributeGrouper _attributeGrouper;
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
// 选择事件订阅管理器
|
||||
@ -59,8 +60,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private bool _needsManualFloorSetup;
|
||||
private bool _showPreviewResults;
|
||||
private bool _showPreviewPrompt = true;
|
||||
private bool _showPreviewInfo;
|
||||
private string _previewInfoMessage = "";
|
||||
private string _floorAnalysisResult = "点击[分析楼层]开始检测";
|
||||
private Brush _floorAnalysisResultColor = Brushes.Gray;
|
||||
private string _selectedFloorAttribute;
|
||||
@ -69,7 +68,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private string _outputDirectory = "";
|
||||
private string _currentSelectionText = "未选择项目";
|
||||
private string _currentOperationText = "";
|
||||
private string _progressDetailText = "";
|
||||
private double _progressPercentage;
|
||||
private string _selectedSplitStrategy = "智能检测楼层";
|
||||
private string _selectedCustomLayerOption = "按楼层";
|
||||
@ -395,23 +393,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
set => SetPropertyThreadSafe(ref _showPreviewPrompt, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示预览信息
|
||||
/// </summary>
|
||||
public bool ShowPreviewInfo
|
||||
{
|
||||
get => _showPreviewInfo;
|
||||
set => SetPropertyThreadSafe(ref _showPreviewInfo, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预览信息提示消息
|
||||
/// </summary>
|
||||
public string PreviewInfoMessage
|
||||
{
|
||||
get => _previewInfoMessage;
|
||||
set => SetPropertyThreadSafe(ref _previewInfoMessage, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前选择文本
|
||||
@ -489,15 +470,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
set => SetPropertyThreadSafe(ref _currentOperationText, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度详细文本
|
||||
/// </summary>
|
||||
public string ProgressDetailText
|
||||
{
|
||||
get => _progressDetailText;
|
||||
set => SetPropertyThreadSafe(ref _progressDetailText, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度百分比
|
||||
/// </summary>
|
||||
@ -829,6 +801,56 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数 - 支持统一状态栏
|
||||
/// </summary>
|
||||
/// <param name="mainViewModel">主ViewModel,用于统一状态栏</param>
|
||||
public LayerManagementViewModel(LogisticsControlViewModel mainViewModel) : base()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存主ViewModel引用
|
||||
_mainViewModel = mainViewModel;
|
||||
|
||||
// 获取UI状态管理器实例
|
||||
_uiStateManager = UIStateManager.Instance;
|
||||
// 验证关键组件是否正常初始化
|
||||
if (_uiStateManager == null)
|
||||
{
|
||||
LogManager.Error("UIStateManager初始化失败");
|
||||
throw new InvalidOperationException("UIStateManager初始化失败");
|
||||
}
|
||||
|
||||
// 初始化业务逻辑组件
|
||||
_floorDetector = new FloorDetector();
|
||||
_modelSplitterManager = new ModelSplitterManager();
|
||||
_attributeGrouper = new AttributeGrouper();
|
||||
|
||||
// 初始化命令 - 使用异步Command Pattern
|
||||
InitializeCommands();
|
||||
|
||||
// 订阅事件
|
||||
_modelSplitterManager.ProgressChanged += OnProgressChanged;
|
||||
_modelSplitterManager.StatusChanged += OnStatusChanged;
|
||||
|
||||
// 订阅Navisworks选择变化事件 - 使用新的选择管理服务
|
||||
SubscribeToSelectionEvents();
|
||||
|
||||
// 异步初始化
|
||||
InitializeAsync();
|
||||
|
||||
LogManager.Info("LayerManagementViewModel构造函数执行完成 - 支持统一状态栏");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"LayerManagementViewModel构造函数异常: {ex.Message}", ex);
|
||||
|
||||
// 在构造函数中尽量保证对象处于可用状态
|
||||
CurrentOperationText = "初始化失败,请检查日志";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 命令初始化 - 统一的Command Pattern
|
||||
@ -944,12 +966,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
IsProcessing = true;
|
||||
ShowCancelButton = false; // 分析楼层操作不支持取消
|
||||
CurrentOperationText = "正在分析楼层...";
|
||||
ProgressDetailText = "检测模型中的楼层属性";
|
||||
ProgressPercentage = 0;
|
||||
|
||||
// 初始化预览状态
|
||||
ShowPreviewInfo = true;
|
||||
PreviewInfoMessage = "正在使用智能遍历模式快速生成预览,仅显示关键节点...";
|
||||
UpdateMainStatus("检测模型中的楼层属性", -1, true);
|
||||
});
|
||||
|
||||
try
|
||||
@ -965,12 +982,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
SetFloorAnalysisResult(result.Message, result.StatusColor);
|
||||
NeedsManualFloorSetup = result.NeedsManualSetup;
|
||||
ProgressDetailText = "楼层分析完成";
|
||||
UpdateMainStatus("楼层分析完成");
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFloorAnalysisResult(result.ErrorMessage, Brushes.Red);
|
||||
ProgressDetailText = "楼层分析失败";
|
||||
UpdateMainStatus("楼层分析失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -982,7 +999,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
SetFloorAnalysisResult($"分析失败: {ex.Message}", Brushes.Red);
|
||||
ProgressDetailText = "操作异常";
|
||||
UpdateMainStatus("操作异常");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1008,7 +1025,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在刷新属性列表...";
|
||||
ProgressDetailText = "获取模型属性";
|
||||
UpdateMainStatus("获取模型属性");
|
||||
});
|
||||
|
||||
try
|
||||
@ -1027,11 +1044,11 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
AvailableAttributes.Add(attr);
|
||||
}
|
||||
ProgressDetailText = $"成功获取 {result.Attributes.Count} 个属性";
|
||||
UpdateMainStatus($"成功获取 {result.Attributes.Count} 个属性");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgressDetailText = result.ErrorMessage ?? "获取属性失败";
|
||||
UpdateMainStatus(result.ErrorMessage ?? "获取属性失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1043,7 +1060,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
AvailableAttributes.Clear();
|
||||
ProgressDetailText = $"刷新失败: {ex.Message}";
|
||||
UpdateMainStatus($"刷新失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1067,7 +1084,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在获取选中节点...";
|
||||
ProgressDetailText = "检查当前选择";
|
||||
UpdateMainStatus("检查当前选择");
|
||||
});
|
||||
|
||||
try
|
||||
@ -1082,14 +1099,14 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
SelectedNodesText = NavisworksSelectionHelper.FormatSelectionText(result.Count, result.SelectedItems, "个节点");
|
||||
ProgressDetailText = result.Count > 0
|
||||
UpdateMainStatus(result.Count > 0
|
||||
? $"获取到 {result.Count} 个选中节点"
|
||||
: "当前没有选中的节点";
|
||||
: "当前没有选中的节点");
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedNodesText = "获取节点失败";
|
||||
ProgressDetailText = result.ErrorMessage ?? "选择节点操作失败";
|
||||
UpdateMainStatus(result.ErrorMessage ?? "选择节点操作失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1101,7 +1118,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
SelectedNodesText = "获取节点异常";
|
||||
ProgressDetailText = $"操作失败: {ex.Message}";
|
||||
UpdateMainStatus($"操作失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1126,7 +1143,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在应用楼层属性...";
|
||||
FloorAttributeStatus = "处理中...";
|
||||
ProgressDetailText = "为选中节点设置楼层属性";
|
||||
UpdateMainStatus("为选中节点设置楼层属性");
|
||||
});
|
||||
|
||||
try
|
||||
@ -1141,12 +1158,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
FloorAttributeStatus = $"成功为 {result.Count} 个节点设置楼层属性";
|
||||
ProgressDetailText = $"属性设置完成,影响 {result.Count} 个节点";
|
||||
UpdateMainStatus($"属性设置完成,影响 {result.Count} 个节点");
|
||||
}
|
||||
else
|
||||
{
|
||||
FloorAttributeStatus = result.ErrorMessage ?? "楼层属性设置失败";
|
||||
ProgressDetailText = "属性设置操作失败";
|
||||
UpdateMainStatus("属性设置操作失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1158,7 +1175,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
FloorAttributeStatus = $"设置失败: {ex.Message}";
|
||||
ProgressDetailText = "属性设置异常";
|
||||
UpdateMainStatus("属性设置异常");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1184,7 +1201,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
ShowCancelButton = false; // 预览操作不支持取消
|
||||
CurrentOperationText = "正在生成分层预览...";
|
||||
ProgressPercentage = 0;
|
||||
ProgressDetailText = "准备分层配置";
|
||||
UpdateMainStatus("准备分层配置");
|
||||
|
||||
// 清空旧的预览结果
|
||||
SplitPreviewResults.Clear();
|
||||
@ -1192,8 +1209,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 显示加载状态
|
||||
ShowPreviewResults = false;
|
||||
ShowPreviewPrompt = false;
|
||||
ShowPreviewInfo = true;
|
||||
PreviewInfoMessage = "正在使用智能遍历模式快速生成预览...";
|
||||
|
||||
// 添加加载提示项
|
||||
var loadingItem = new SplitPreviewItem
|
||||
@ -1245,18 +1260,14 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
|
||||
ShowPreviewResults = true;
|
||||
ShowPreviewPrompt = false;
|
||||
ShowPreviewInfo = true;
|
||||
PreviewInfoMessage = $"预览完成:共检测到 {SplitPreviewResults.Count} 个分层(智能遍历仅显示关键节点)";
|
||||
ProgressDetailText = $"预览完成,共 {SplitPreviewResults.Count} 个分层";
|
||||
UpdateMainStatus($"预览完成:共检测到 {SplitPreviewResults.Count} 个分层(智能遍历仅显示关键节点)");
|
||||
}
|
||||
else
|
||||
{
|
||||
// 预览失败或无结果,不在列表中显示错误项,而是隐藏结果列表并显示提示
|
||||
ShowPreviewResults = false;
|
||||
ShowPreviewPrompt = true; // 显示提示信息
|
||||
ShowPreviewInfo = true; // 显示预览信息提示
|
||||
PreviewInfoMessage = result.ErrorMessage ?? "未找到任何分层属性,请先设置模型的分层属性(楼层、区域或子系统)";
|
||||
ProgressDetailText = result.ErrorMessage ?? "未找到任何分层属性,请先设置模型的分层属性(楼层、区域或子系统)";
|
||||
UpdateMainStatus(result.ErrorMessage ?? "未找到任何分层属性,请先设置模型的分层属性(楼层、区域或子系统)");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1272,9 +1283,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
|
||||
ShowPreviewResults = false;
|
||||
ShowPreviewPrompt = true; // 显示提示信息
|
||||
ShowPreviewInfo = true; // 显示预览信息提示
|
||||
PreviewInfoMessage = $"预览异常: {ex.Message}";
|
||||
ProgressDetailText = $"预览异常: {ex.Message}";
|
||||
UpdateMainStatus($"预览异常: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1325,7 +1334,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "没有选中任何分层进行保存";
|
||||
ProgressDetailText = "请勾选需要保存的分层";
|
||||
UpdateMainStatus("请勾选需要保存的分层");
|
||||
});
|
||||
return;
|
||||
}
|
||||
@ -1338,7 +1347,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
IsProcessing = true;
|
||||
ShowCancelButton = true; // 分层保存支持取消
|
||||
CurrentOperationText = "正在执行分层保存...";
|
||||
ProgressDetailText = $"准备保存到: {selectedDirectory}";
|
||||
UpdateMainStatus($"准备保存到: {selectedDirectory}");
|
||||
});
|
||||
|
||||
_cancellationTokenSource = new CancellationTokenSource();
|
||||
@ -1378,7 +1387,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "分层保存完成";
|
||||
ProgressDetailText = $"文件已保存到: {selectedDirectory}";
|
||||
UpdateMainStatus($"文件已保存到: {selectedDirectory}");
|
||||
// 更新OutputDirectory显示(可选)
|
||||
OutputDirectory = selectedDirectory;
|
||||
});
|
||||
@ -1391,7 +1400,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "分层保存异常";
|
||||
ProgressDetailText = $"保存失败: {ex.Message}";
|
||||
UpdateMainStatus($"保存失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -1441,8 +1450,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = $"正在处理分层: {preview.LayerName} ({i + 1}/{previewResultsForSave.Count})";
|
||||
ProgressPercentage = (double)(i + 1) * 100 / previewResultsForSave.Count;
|
||||
ProgressDetailText = $"处理分层 {i + 1}/{previewResultsForSave.Count}: {preview.LayerName}";
|
||||
double percentage = (double)(i + 1) * 100 / previewResultsForSave.Count;
|
||||
UpdateMainStatus($"处理分层 {i + 1}/{previewResultsForSave.Count}: {preview.LayerName}", percentage);
|
||||
});
|
||||
|
||||
try
|
||||
@ -1461,7 +1470,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
// 继续处理其他分层,不因单个失败而中断整个进程
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
ProgressDetailText = errorMsg;
|
||||
UpdateMainStatus(errorMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1480,7 +1489,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
ProgressDetailText = finalMessage;
|
||||
UpdateMainStatus(finalMessage);
|
||||
});
|
||||
|
||||
// 如果所有分层都失败,抛出异常
|
||||
@ -2116,7 +2125,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在进行环境诊断...";
|
||||
ProgressDetailText = "检查Navisworks API环境和线程状态";
|
||||
UpdateMainStatus("检查Navisworks API环境和线程状态");
|
||||
});
|
||||
|
||||
// 2. 纯业务逻辑执行(后台线程)
|
||||
@ -2129,7 +2138,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "环境诊断完成";
|
||||
ProgressDetailText = "环境诊断报告已生成";
|
||||
UpdateMainStatus("环境诊断报告已生成");
|
||||
});
|
||||
|
||||
// 显示诊断结果
|
||||
@ -2145,7 +2154,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "环境诊断异常";
|
||||
ProgressDetailText = $"诊断失败: {ex.Message}";
|
||||
UpdateMainStatus($"诊断失败: {ex.Message}");
|
||||
});
|
||||
|
||||
ShowDiagnosticResult($"诊断过程中发生异常: {ex.Message}");
|
||||
@ -2679,7 +2688,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
_uiStateManager.QueueUIUpdate(() =>
|
||||
{
|
||||
ProgressPercentage = e.ProgressPercentage;
|
||||
ProgressDetailText = e.UserState?.ToString() ?? "";
|
||||
UpdateMainStatus(e.UserState?.ToString() ?? "");
|
||||
}, UIUpdatePriority.Normal);
|
||||
}
|
||||
|
||||
@ -3183,7 +3192,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
IsProcessing = true;
|
||||
ShowCancelButton = false; // 清除楼层属性不支持取消
|
||||
CurrentOperationText = "正在清除楼层属性...";
|
||||
ProgressDetailText = "正在清除选中模型的楼层属性";
|
||||
UpdateMainStatus("正在清除选中模型的楼层属性");
|
||||
});
|
||||
|
||||
try
|
||||
@ -3238,9 +3247,9 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = result.Message;
|
||||
ProgressDetailText = result.Success ?
|
||||
UpdateMainStatus(result.Success ?
|
||||
$"楼层属性清除完成,成功清除 {result.Count}/{result.TotalCount} 个模型项" :
|
||||
"楼层属性清除失败";
|
||||
"楼层属性清除失败");
|
||||
|
||||
if (result.Success)
|
||||
{
|
||||
@ -3267,7 +3276,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "清除楼层属性异常";
|
||||
ProgressDetailText = $"清除失败: {ex.Message}";
|
||||
UpdateMainStatus($"清除失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -3625,7 +3634,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在准备单独显示...";
|
||||
ProgressDetailText = $"隐藏除'{SelectedPreviewResult.LayerName}'之外的其他分层";
|
||||
UpdateMainStatus($"隐藏除'{SelectedPreviewResult.LayerName}'之外的其他分层");
|
||||
});
|
||||
|
||||
// 2. 在UI线程执行Navisworks API调用
|
||||
@ -3666,12 +3675,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
if (isolateResult)
|
||||
{
|
||||
CurrentOperationText = $"已单独显示: {SelectedPreviewResult.LayerName}";
|
||||
ProgressDetailText = "其他分层已隐藏,您可以预览选中的分层内容";
|
||||
UpdateMainStatus("其他分层已隐藏,您可以预览选中的分层内容");
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentOperationText = "单独显示失败";
|
||||
ProgressDetailText = resultMessage ?? "请检查日志了解详细信息";
|
||||
UpdateMainStatus(resultMessage ?? "请检查日志了解详细信息");
|
||||
}
|
||||
});
|
||||
|
||||
@ -3685,7 +3694,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "单独显示异常";
|
||||
ProgressDetailText = $"操作失败: {ex.Message}";
|
||||
UpdateMainStatus($"操作失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -3712,7 +3721,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
IsProcessing = true;
|
||||
CurrentOperationText = "正在恢复显示...";
|
||||
ProgressDetailText = "恢复所有分层的可见性";
|
||||
UpdateMainStatus("恢复所有分层的可见性");
|
||||
});
|
||||
|
||||
// 2. 在UI线程执行Navisworks API调用
|
||||
@ -3744,12 +3753,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
if (restoreResult)
|
||||
{
|
||||
CurrentOperationText = "已恢复所有分层显示";
|
||||
ProgressDetailText = "所有分层内容都已可见";
|
||||
UpdateMainStatus("所有分层内容都已可见");
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentOperationText = "恢复显示失败";
|
||||
ProgressDetailText = resultMessage ?? "请检查日志了解详细信息";
|
||||
UpdateMainStatus(resultMessage ?? "请检查日志了解详细信息");
|
||||
}
|
||||
});
|
||||
|
||||
@ -3763,7 +3772,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
await _uiStateManager.ExecuteUIUpdateAsync(() =>
|
||||
{
|
||||
CurrentOperationText = "恢复显示异常";
|
||||
ProgressDetailText = $"操作失败: {ex.Message}";
|
||||
UpdateMainStatus($"操作失败: {ex.Message}");
|
||||
});
|
||||
}
|
||||
finally
|
||||
@ -3777,5 +3786,66 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 统一状态栏方法
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏(简单版本,不显示进度条)
|
||||
/// </summary>
|
||||
private void UpdateMainStatus(string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有主ViewModel引用,更新统一状态栏
|
||||
if (_mainViewModel != null)
|
||||
{
|
||||
_mainViewModel.UpdateStatus(message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"更新统一状态栏失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏(支持百分比进度)
|
||||
/// </summary>
|
||||
private void UpdateMainStatus(string message, double percentage)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有主ViewModel引用,更新统一状态栏
|
||||
if (_mainViewModel != null)
|
||||
{
|
||||
_mainViewModel.UpdateStatus(message, percentage);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"更新统一状态栏失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏(完整版本,支持不确定进度)
|
||||
/// </summary>
|
||||
private void UpdateMainStatus(string message, double progress = -1, bool? isProcessing = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有主ViewModel引用,更新统一状态栏
|
||||
if (_mainViewModel != null)
|
||||
{
|
||||
_mainViewModel.UpdateStatus(message, progress, isProcessing);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"更新统一状态栏失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -202,6 +202,26 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
set => SetProperty(ref _isProcessing, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 进度百分比(0-100,-1表示不确定进度)
|
||||
/// </summary>
|
||||
public double ProgressPercentage
|
||||
{
|
||||
get => _animationProgress;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _animationProgress, value))
|
||||
{
|
||||
OnPropertyChanged(nameof(IsIndeterminateProgress));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否使用不确定进度模式
|
||||
/// </summary>
|
||||
public bool IsIndeterminateProgress => ProgressPercentage < 0;
|
||||
|
||||
#region 动画控制属性
|
||||
|
||||
/// <summary>
|
||||
@ -1002,7 +1022,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
StatusText = message ?? "就绪";
|
||||
if (progress >= 0)
|
||||
{
|
||||
AnimationProgress = Math.Max(0, Math.Min(100, progress));
|
||||
ProgressPercentage = Math.Max(0, Math.Min(100, progress));
|
||||
}
|
||||
if (isProcessing.HasValue)
|
||||
{
|
||||
@ -1011,6 +1031,21 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}, "更新统一状态栏", runOnUIThread: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏信息(支持百分比进度)
|
||||
/// </summary>
|
||||
/// <param name="message">状态消息</param>
|
||||
/// <param name="percentage">进度百分比 (0-100)</param>
|
||||
public void UpdateStatus(string message, double percentage)
|
||||
{
|
||||
SafeExecute(() =>
|
||||
{
|
||||
StatusText = message ?? "就绪";
|
||||
ProgressPercentage = Math.Max(0, Math.Min(100, percentage));
|
||||
IsProcessing = true; // 有百分比进度时显示进度条
|
||||
}, "更新统一状态栏(百分比模式)", runOnUIThread: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置状态栏到默认状态
|
||||
/// </summary>
|
||||
|
||||
@ -286,16 +286,6 @@ NavisworksTransport 分层管理页签视图 - 重构优化版本
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</GroupBox>
|
||||
|
||||
<!-- 预览信息提示区域 -->
|
||||
<StackPanel Margin="0,5,0,0"
|
||||
Visibility="{Binding ShowPreviewInfo, Converter={StaticResource BoolToVisConverter}}">
|
||||
<TextBlock Text="{Binding PreviewInfoMessage}"
|
||||
Style="{StaticResource StatusTextStyle}"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="5,0,5,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
@ -336,26 +326,6 @@ NavisworksTransport 分层管理页签视图 - 重构优化版本
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<!-- 进度和状态区域 -->
|
||||
<Border BorderBrush="#FFE0E0E0" BorderThickness="1" CornerRadius="0" Padding="12"
|
||||
Visibility="{Binding IsProcessing, Converter={StaticResource BoolToVisConverter}}">
|
||||
<StackPanel>
|
||||
<ProgressBar Value="{Binding ProgressPercentage}"
|
||||
Height="16"
|
||||
Margin="0,0,0,5"/>
|
||||
<TextBlock Text="{Binding ProgressDetailText}"
|
||||
Style="{StaticResource StatusTextStyle}"/>
|
||||
|
||||
<!-- 只在有取消令牌时显示取消按钮 -->
|
||||
<Button Content="取消操作"
|
||||
Style="{StaticResource SecondaryButtonStyle}"
|
||||
Command="{Binding CancelOperationCommand}"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,10,0,0"
|
||||
Visibility="{Binding ShowCancelButton, Converter={StaticResource BoolToVisConverter}}"/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@ -27,6 +27,19 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
DataContext = ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带主ViewModel参数的构造函数,支持统一状态栏
|
||||
/// </summary>
|
||||
/// <param name="mainViewModel">主ViewModel,用于统一状态栏</param>
|
||||
public LayerManagementView(LogisticsControlViewModel mainViewModel)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
// 创建ViewModel,传入主ViewModel引用
|
||||
ViewModel = new LayerManagementViewModel(mainViewModel);
|
||||
DataContext = ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 带ViewModel参数的构造函数
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user