重构了各ViewModel的消息方法,抽取到ViewModelBase基类
This commit is contained in:
parent
83aad61147
commit
7d2edc9862
@ -72,7 +72,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private readonly NavisworksTransport.Core.Animation.LogisticsAnimationManager _logisticsAnimationManager;
|
||||
private readonly ClashDetectiveIntegration _clashIntegration;
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
|
||||
// 动画参数相关字段
|
||||
private ObservableCollection<int> _availableFrameRates;
|
||||
@ -423,8 +422,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存主ViewModel引用
|
||||
_mainViewModel = mainViewModel;
|
||||
// 设置主ViewModel引用到基类
|
||||
SetMainViewModel(mainViewModel);
|
||||
|
||||
// 初始化管理器
|
||||
_pathAnimationManager = new NavisworksTransport.Core.Animation.PathAnimationManager();
|
||||
@ -1629,66 +1628,6 @@ 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
|
||||
|
||||
#region 资源清理
|
||||
|
||||
|
||||
@ -43,7 +43,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private readonly ModelSplitterManager _modelSplitterManager;
|
||||
private readonly AttributeGrouper _attributeGrouper;
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
private CancellationTokenSource _cancellationTokenSource;
|
||||
|
||||
// 选择事件订阅管理器
|
||||
@ -809,8 +808,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存主ViewModel引用
|
||||
_mainViewModel = mainViewModel;
|
||||
// 设置主ViewModel引用到基类
|
||||
SetMainViewModel(mainViewModel);
|
||||
|
||||
// 获取UI状态管理器实例
|
||||
_uiStateManager = UIStateManager.Instance;
|
||||
@ -3787,65 +3786,5 @@ 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
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
#region 私有字段和依赖注入
|
||||
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
|
||||
// 选择事件订阅管理器
|
||||
private SelectionEventSubscription _selectionEventSubscription;
|
||||
@ -277,9 +276,9 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取UI状态管理器实例和主ViewModel引用
|
||||
// 获取UI状态管理器实例和设置主ViewModel引用到基类
|
||||
_uiStateManager = UIStateManager.Instance;
|
||||
_mainViewModel = mainViewModel;
|
||||
SetMainViewModel(mainViewModel);
|
||||
|
||||
// 验证关键组件是否正常初始化
|
||||
if (_uiStateManager == null)
|
||||
@ -1216,43 +1215,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
System.Windows.Input.CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
/// <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 progress = -1, bool? isProcessing = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有主ViewModel引用,更新统一状态栏
|
||||
if (_mainViewModel != null)
|
||||
{
|
||||
_mainViewModel.UpdateStatus(message, progress, isProcessing);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"更新统一状态栏失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@ -30,7 +30,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
private PathPlanningManager _pathPlanningManager;
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly PathDataManager _pathDataManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
|
||||
// 路径集合
|
||||
private ObservableCollection<PathRouteViewModel> _pathRoutes;
|
||||
@ -411,8 +410,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存主ViewModel引用
|
||||
_mainViewModel = mainViewModel;
|
||||
// 设置主ViewModel引用到基类
|
||||
SetMainViewModel(mainViewModel);
|
||||
|
||||
_uiStateManager = UIStateManager.Instance;
|
||||
_pathDataManager = new PathDataManager();
|
||||
@ -2374,66 +2373,6 @@ 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
|
||||
|
||||
#region 清理资源
|
||||
|
||||
|
||||
@ -18,7 +18,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
#region 私有字段
|
||||
|
||||
private readonly UIStateManager _uiStateManager;
|
||||
private readonly LogisticsControlViewModel _mainViewModel;
|
||||
|
||||
// 系统管理相关字段
|
||||
private bool _isAutoSaveEnabled = true;
|
||||
@ -229,8 +228,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
{
|
||||
try
|
||||
{
|
||||
// 保存主ViewModel引用
|
||||
_mainViewModel = mainViewModel;
|
||||
// 设置主ViewModel引用到基类
|
||||
SetMainViewModel(mainViewModel);
|
||||
|
||||
// 获取UI状态管理器实例
|
||||
_uiStateManager = UIStateManager.Instance;
|
||||
@ -856,63 +855,6 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 安全执行异步操作
|
||||
/// </summary>
|
||||
|
||||
@ -56,6 +56,11 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
/// </summary>
|
||||
protected bool IsPerformanceMonitoringEnabled { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// 主ViewModel引用,用于统一状态栏更新
|
||||
/// </summary>
|
||||
protected LogisticsControlViewModel _mainViewModel;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 构造函数
|
||||
@ -676,6 +681,82 @@ namespace NavisworksTransport.UI.WPF.ViewModels
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 统一状态栏更新方法
|
||||
|
||||
/// <summary>
|
||||
/// 设置主ViewModel引用
|
||||
/// </summary>
|
||||
/// <param name="mainViewModel">主ViewModel实例</param>
|
||||
protected void SetMainViewModel(LogisticsControlViewModel mainViewModel)
|
||||
{
|
||||
_mainViewModel = mainViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏(简单版本,不显示进度条)
|
||||
/// </summary>
|
||||
/// <param name="message">状态消息</param>
|
||||
protected void UpdateMainStatus(string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 如果有主ViewModel引用,更新统一状态栏
|
||||
if (_mainViewModel != null)
|
||||
{
|
||||
_mainViewModel.UpdateStatus(message);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.Error($"更新统一状态栏失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新统一状态栏(支持百分比进度)
|
||||
/// </summary>
|
||||
/// <param name="message">状态消息</param>
|
||||
/// <param name="percentage">进度百分比</param>
|
||||
protected 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>
|
||||
/// <param name="message">状态消息</param>
|
||||
/// <param name="progress">进度值(-1表示不确定进度)</param>
|
||||
/// <param name="isProcessing">是否正在处理(可选)</param>
|
||||
protected 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
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user