feat(wpf): 实现场景列表加载、筛选与消息导航功能
- ScenarioService新增筛选查询方法和动态筛选选项 - 使用WeakReferenceMessenger实现导入完成通知和导航消息 - ViewModel改为Singleton生命周期确保消息订阅正确工作 - 场景列表支持数据库加载和按维度筛选 - ScenarioId类型从int改为Guid Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using LiveChartsCore;
|
||||
using LiveChartsCore.SkiaSharpView;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using WCTDataMiner.Core.Services;
|
||||
|
||||
namespace WCTDataMiner.Wpf.ViewModels;
|
||||
|
||||
@@ -9,8 +11,11 @@ namespace WCTDataMiner.Wpf.ViewModels;
|
||||
/// </summary>
|
||||
public partial class PlossChartViewModel : ObservableObject
|
||||
{
|
||||
private readonly ScenarioService _scenarioService;
|
||||
private readonly ILogger<PlossChartViewModel> _logger;
|
||||
|
||||
[ObservableProperty]
|
||||
private int _scenarioId;
|
||||
private Guid _scenarioId;
|
||||
|
||||
[ObservableProperty]
|
||||
private ISeries[] _series;
|
||||
@@ -21,8 +26,13 @@ public partial class PlossChartViewModel : ObservableObject
|
||||
[ObservableProperty]
|
||||
private Axis[] _yAxes;
|
||||
|
||||
public PlossChartViewModel()
|
||||
public PlossChartViewModel(
|
||||
ScenarioService scenarioService,
|
||||
ILogger<PlossChartViewModel> logger)
|
||||
{
|
||||
_scenarioService = scenarioService;
|
||||
_logger = logger;
|
||||
|
||||
// 初始化图表配置
|
||||
Series = Array.Empty<ISeries>();
|
||||
XAxes = new Axis[] { new Axis { Name = "Trigger Count" } };
|
||||
@@ -31,19 +41,26 @@ public partial class PlossChartViewModel : ObservableObject
|
||||
|
||||
public async Task LoadDataAsync()
|
||||
{
|
||||
// TODO: 从数据库加载 Ploss 数据并构建图表
|
||||
Series = new ISeries[]
|
||||
try
|
||||
{
|
||||
new LineSeries<double>
|
||||
// TODO: 从数据库加载 Ploss 数据并构建图表
|
||||
Series = new ISeries[]
|
||||
{
|
||||
Name = "Ploss",
|
||||
Values = new double[] { -2882, -3500, -4200, -3800, -4500 }
|
||||
},
|
||||
new LineSeries<double>
|
||||
{
|
||||
Name = "Threshold",
|
||||
Values = new double[] { -3000, -3000, -3000, -3000, -3000 }
|
||||
}
|
||||
};
|
||||
new LineSeries<double>
|
||||
{
|
||||
Name = "Ploss",
|
||||
Values = new double[] { -2882, -3500, -4200, -3800, -4500 }
|
||||
},
|
||||
new LineSeries<double>
|
||||
{
|
||||
Name = "Threshold",
|
||||
Values = new double[] { -3000, -3000, -3000, -3000, -3000 }
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "加载 Ploss 图表数据失败: ScenarioId={ScenarioId}", ScenarioId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user