初步完成历史记录(未完成)
This commit is contained in:
@@ -70,4 +70,11 @@ public interface IVariableAppService
|
||||
/// <param name="variableToCheck">要检查的变量。</param>
|
||||
/// <returns>如果变量已存在则返回该变量,否则返回null。</returns>
|
||||
Task<VariableDto?> FindExistingVariableAsync(VariableDto variableToCheck);
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取指定变量的历史记录。
|
||||
/// </summary>
|
||||
/// <param name="variableId">变量ID</param>
|
||||
/// <returns>变量历史记录列表</returns>
|
||||
Task<List<VariableHistoryDto>> GetVariableHistoriesAsync(int variableId);
|
||||
}
|
||||
@@ -36,6 +36,11 @@ public class MqttPublishProcessor : IVariableProcessor
|
||||
// 遍历所有关联的MQTT配置,并将其推入发送队列
|
||||
foreach (var variableMqttAliasDto in variable.MqttAliases)
|
||||
{
|
||||
if (!variableMqttAliasDto.MqttServer.IsActive)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// 发布变量数据到MQTT服务器
|
||||
var variableMqttAlias = _mapper.Map<VariableMqttAlias>(variableMqttAliasDto);
|
||||
variableMqttAlias.Variable.DataValue=variable.DataValue;
|
||||
|
||||
@@ -285,4 +285,15 @@ public class VariableAppService : IVariableAppService
|
||||
// 如果找到了匹配的变量,返回第一个(也是唯一一个)
|
||||
return existingVariables.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取指定变量的历史记录。
|
||||
/// </summary>
|
||||
/// <param name="variableId">变量ID</param>
|
||||
/// <returns>变量历史记录列表</returns>
|
||||
public async Task<List<VariableHistoryDto>> GetVariableHistoriesAsync(int variableId)
|
||||
{
|
||||
var histories = await _repoManager.VariableHistories.GetByVariableIdAsync(variableId);
|
||||
return _mapper.Map<List<VariableHistoryDto>>(histories);
|
||||
}
|
||||
}
|
||||
@@ -5,5 +5,6 @@ public enum MenuType
|
||||
MainMenu,
|
||||
DeviceMenu,
|
||||
VariableTableMenu,
|
||||
VariableMenu,
|
||||
MqttMenu
|
||||
}
|
||||
@@ -4,5 +4,10 @@ namespace DMS.Core.Interfaces.Repositories;
|
||||
|
||||
public interface IVariableHistoryRepository:IBaseRepository<VariableHistory>
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 根据变量ID获取历史记录
|
||||
/// </summary>
|
||||
/// <param name="variableId">变量ID</param>
|
||||
/// <returns>变量历史记录列表</returns>
|
||||
Task<List<VariableHistory>> GetByVariableIdAsync(int variableId);
|
||||
}
|
||||
@@ -109,4 +109,18 @@ public class VariableHistoryRepository : BaseRepository<DbVariableHistory>, IVar
|
||||
var dbEntities = _mapper.Map<List<DbVariableHistory>>(entities);
|
||||
return base.AddBatchAsync(dbEntities);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据变量ID获取历史记录
|
||||
/// </summary>
|
||||
/// <param name="variableId">变量ID</param>
|
||||
/// <returns>变量历史记录列表</returns>
|
||||
public async Task<List<VariableHistory>> GetByVariableIdAsync(int variableId)
|
||||
{
|
||||
var dbList = await Db.Queryable<DbVariableHistory>()
|
||||
.Where(h => h.VariableId == variableId)
|
||||
.OrderBy(h => h.Timestamp, SqlSugar.OrderByType.Desc)
|
||||
.ToListAsync();
|
||||
return _mapper.Map<List<VariableHistory>>(dbList);
|
||||
}
|
||||
}
|
||||
@@ -199,10 +199,14 @@ public class OpcUaBackgroundService : BackgroundService
|
||||
|
||||
// 遍历_opcUaDevices中的所有设备,尝试连接
|
||||
foreach (var device in _opcUaDevices.Values.ToList())
|
||||
{
|
||||
if (device.IsActive)
|
||||
{
|
||||
connectTasks.Add(ConnectSingleOpcUaDeviceAsync(device, stoppingToken));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await Task.WhenAll(connectTasks);
|
||||
}
|
||||
|
||||
|
||||
@@ -279,6 +279,7 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<MqttsViewModel>();
|
||||
services.AddSingleton<LogHistoryViewModel>();
|
||||
services.AddScoped<MqttServerDetailViewModel>();
|
||||
services.AddSingleton<VariableHistoryViewModel>();
|
||||
|
||||
// 注册对话框视图模型
|
||||
services.AddTransient<DeviceDialogViewModel>();
|
||||
@@ -300,6 +301,7 @@ public partial class App : System.Windows.Application
|
||||
services.AddSingleton<HomeView>();
|
||||
services.AddSingleton<DevicesView>();
|
||||
services.AddSingleton<VariableTableView>();
|
||||
services.AddSingleton<VariableHistoryView>();
|
||||
services.AddSingleton<LogHistoryView>();
|
||||
services.AddScoped<DeviceDetailView>();
|
||||
services.AddScoped<MqttsView>();
|
||||
|
||||
@@ -16,4 +16,11 @@ public interface INavigationService
|
||||
/// <param name="parameter">要传递给目标ViewModel的参数。</param>
|
||||
Task NavigateToAsync(MenuItemViewModel menu);
|
||||
|
||||
/// <summary>
|
||||
/// 导航到由唯一键标识的视图,并传递一个参数。
|
||||
/// </summary>
|
||||
/// <param name="viewKey">在DI容器中注册的目标视图的唯一键(通常是ViewModel的名称)。</param>
|
||||
/// <param name="parameter">要传递给目标ViewModel的参数。</param>
|
||||
Task NavigateToAsync(string viewKey, object parameter = null);
|
||||
|
||||
}
|
||||
|
||||
13
DMS.WPF/Interfaces/IParameterReceiver.cs
Normal file
13
DMS.WPF/Interfaces/IParameterReceiver.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace DMS.WPF.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// 定义了可以接收导航参数的接口
|
||||
/// </summary>
|
||||
public interface IParameterReceiver
|
||||
{
|
||||
/// <summary>
|
||||
/// 接收导航参数
|
||||
/// </summary>
|
||||
/// <param name="parameter">传递的参数</param>
|
||||
void ReceiveParameter(object parameter);
|
||||
}
|
||||
@@ -49,6 +49,24 @@ public class NavigationService : INavigationService
|
||||
mainViewModel.CurrentViewModel = viewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导航到指定键的视图,并传递参数。
|
||||
/// </summary>
|
||||
public async Task NavigateToAsync(string viewKey, object parameter = null)
|
||||
{
|
||||
var mainViewModel = App.Current.Services.GetRequiredService<MainViewModel>();
|
||||
var viewModel = GetViewModelByKey(viewKey);
|
||||
if (viewModel == null)
|
||||
{
|
||||
_notificationService.ShowError($"切换界面失败,没有找到界面:{viewKey}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
mainViewModel.CurrentViewModel = viewModel;
|
||||
}
|
||||
|
||||
|
||||
private ViewModelBase GetViewModelByKey(string key)
|
||||
{
|
||||
@@ -66,6 +84,8 @@ public class NavigationService : INavigationService
|
||||
return App.Current.Services.GetRequiredService<DataTransformViewModel>();
|
||||
case "VariableTableView":
|
||||
return App.Current.Services.GetRequiredService<VariableTableViewModel>();
|
||||
case "VariableHistoryView":
|
||||
return App.Current.Services.GetRequiredService<VariableHistoryViewModel>();
|
||||
case "LogHistoryView":
|
||||
return App.Current.Services.GetRequiredService<LogHistoryViewModel>();
|
||||
case "MqttsView":
|
||||
|
||||
239
DMS.WPF/ViewModels/VariableHistoryViewModel.cs
Normal file
239
DMS.WPF/ViewModels/VariableHistoryViewModel.cs
Normal file
@@ -0,0 +1,239 @@
|
||||
using System.Collections;
|
||||
using AutoMapper;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using DMS.Application.DTOs;
|
||||
using DMS.Application.Interfaces;
|
||||
using DMS.Core.Models;
|
||||
using DMS.WPF.Interfaces;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ObservableCollections;
|
||||
|
||||
namespace DMS.WPF.ViewModels;
|
||||
|
||||
partial class VariableHistoryViewModel : ViewModelBase,INavigatable
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly IVariableAppService _variableAppService;
|
||||
private readonly IWPFDataService _wpfDataService;
|
||||
private readonly IDataStorageService _dataStorageService;
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的设备
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private DeviceItemViewModel _selectedDevice;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的变量表
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private VariableTableItemViewModel _selectedVariableTable;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的变量
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private VariableItemViewModel _selectedVariable;
|
||||
|
||||
/// <summary>
|
||||
/// 用于过滤变量的搜索文本
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private string _searchText;
|
||||
|
||||
/// <summary>
|
||||
/// 所有设备列表
|
||||
/// </summary>
|
||||
public NotifyCollectionChangedSynchronizedViewList<DeviceItemViewModel> Devices { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前设备下的变量表列表
|
||||
/// </summary>
|
||||
public NotifyCollectionChangedSynchronizedViewList<VariableTableItemViewModel> VariableTables { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前变量表下的变量列表
|
||||
/// </summary>
|
||||
public NotifyCollectionChangedSynchronizedViewList<VariableItemViewModel> Variables { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 变量历史记录列表
|
||||
/// </summary>
|
||||
public NotifyCollectionChangedSynchronizedViewList<VariableHistoryDto> VariableHistories { get; }
|
||||
|
||||
private readonly ObservableList<DeviceItemViewModel> _deviceItemList;
|
||||
private readonly ObservableList<VariableTableItemViewModel> _variableTableItemList;
|
||||
private readonly ObservableList<VariableItemViewModel> _variableItemList;
|
||||
private readonly ObservableList<VariableHistoryDto> _variableHistoryList;
|
||||
|
||||
private readonly ISynchronizedView<DeviceItemViewModel, DeviceItemViewModel> _deviceSynchronizedView;
|
||||
private readonly ISynchronizedView<VariableTableItemViewModel, VariableTableItemViewModel> _variableTableSynchronizedView;
|
||||
private readonly ISynchronizedView<VariableItemViewModel, VariableItemViewModel> _variableSynchronizedView;
|
||||
private readonly ISynchronizedView<VariableHistoryDto, VariableHistoryDto> _variableHistorySynchronizedView;
|
||||
|
||||
public VariableHistoryViewModel(IMapper mapper, IDialogService dialogService, IVariableAppService variableAppService,
|
||||
IWPFDataService wpfDataService, IDataStorageService dataStorageService, INotificationService notificationService)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_dialogService = dialogService;
|
||||
_variableAppService = variableAppService;
|
||||
_wpfDataService = wpfDataService;
|
||||
_dataStorageService = dataStorageService;
|
||||
_notificationService = notificationService;
|
||||
|
||||
_deviceItemList = new ObservableList<DeviceItemViewModel>();
|
||||
_variableTableItemList = new ObservableList<VariableTableItemViewModel>();
|
||||
_variableItemList = new ObservableList<VariableItemViewModel>();
|
||||
_variableHistoryList = new ObservableList<VariableHistoryDto>();
|
||||
|
||||
_deviceSynchronizedView = _deviceItemList.CreateView(v => v);
|
||||
_variableTableSynchronizedView = _variableTableItemList.CreateView(v => v);
|
||||
_variableSynchronizedView = _variableItemList.CreateView(v => v);
|
||||
_variableHistorySynchronizedView = _variableHistoryList.CreateView(v => v);
|
||||
|
||||
Devices = _deviceSynchronizedView.ToNotifyCollectionChanged();
|
||||
VariableTables = _variableTableSynchronizedView.ToNotifyCollectionChanged();
|
||||
Variables = _variableSynchronizedView.ToNotifyCollectionChanged();
|
||||
VariableHistories = _variableHistorySynchronizedView.ToNotifyCollectionChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 加载所有设备
|
||||
/// </summary>
|
||||
private void LoadDevices()
|
||||
{
|
||||
_deviceItemList.Clear();
|
||||
_deviceItemList.AddRange(_dataStorageService.Devices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当选中的设备发生变化时
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
partial void OnSelectedDeviceChanged(DeviceItemViewModel value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
// 清空变量表和变量列表
|
||||
_variableTableItemList.Clear();
|
||||
_variableItemList.Clear();
|
||||
_variableHistoryList.Clear();
|
||||
|
||||
// 加载选中设备下的变量表
|
||||
_variableTableItemList.AddRange(value.VariableTables);
|
||||
|
||||
// 清空选中项
|
||||
SelectedVariableTable = null;
|
||||
SelectedVariable = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当选中的变量表发生变化时
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
partial void OnSelectedVariableTableChanged(VariableTableItemViewModel value)
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
// 清空变量列表和历史记录
|
||||
_variableItemList.Clear();
|
||||
_variableHistoryList.Clear();
|
||||
|
||||
// 加载选中变量表下的变量
|
||||
_variableItemList.AddRange(value.Variables);
|
||||
|
||||
// 清空选中项
|
||||
SelectedVariable = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当选中的变量发生变化时
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
partial void OnSelectedVariableChanged(VariableItemViewModel value)
|
||||
{
|
||||
// if (value != null)
|
||||
// {
|
||||
// // 加载选中变量的历史记录
|
||||
// LoadVariableHistories(value.Id);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// _variableHistoryList.Clear();
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载变量的历史记录
|
||||
/// </summary>
|
||||
/// <param name="variableId"></param>
|
||||
private async void LoadVariableHistories(int variableId)
|
||||
{
|
||||
try
|
||||
{
|
||||
_variableHistoryList.Clear();
|
||||
var histories = await _variableAppService.GetVariableHistoriesAsync(variableId);
|
||||
_variableHistoryList.AddRange(histories);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 记录更详细的错误信息
|
||||
_notificationService.ShowError($"加载变量历史记录失败: {ex.Message}", ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索变量
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
partial void OnSearchTextChanged(string value)
|
||||
{
|
||||
if (SelectedVariableTable == null) return;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(SearchText))
|
||||
{
|
||||
_variableSynchronizedView.ResetFilter();
|
||||
}
|
||||
else
|
||||
{
|
||||
_variableSynchronizedView.AttachFilter(FilterVariables);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过滤变量
|
||||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
private bool FilterVariables(VariableItemViewModel item)
|
||||
{
|
||||
var searchTextLower = SearchText.ToLower();
|
||||
return item.Name?.ToLower().Contains(searchTextLower) == true ||
|
||||
item.Description?.ToLower().Contains(searchTextLower) == true ||
|
||||
item.OpcUaNodeId?.ToLower().Contains(searchTextLower) == true ||
|
||||
item.S7Address?.ToLower().Contains(searchTextLower) == true;
|
||||
}
|
||||
|
||||
public async Task OnNavigatedToAsync(MenuItemViewModel menu)
|
||||
{
|
||||
|
||||
VariableItemViewModel variable =_dataStorageService.Variables.FirstOrDefault(v => v.Id == menu.TargetId);
|
||||
if (variable!=null)
|
||||
{
|
||||
// 直接设置选中的变量
|
||||
SelectedVariable = variable;
|
||||
|
||||
|
||||
// 加载历史记录
|
||||
LoadVariableHistories(variable.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -703,6 +703,18 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void ToHistory()
|
||||
{
|
||||
// 导航到历史记录视图
|
||||
var navigationService = App.Current.Services.GetRequiredService<INavigationService>();
|
||||
MenuItemViewModel viewModel=new MenuItemViewModel();
|
||||
viewModel.TargetViewKey = "VariableHistoryView";
|
||||
viewModel.MenuType = MenuType.VariableMenu;
|
||||
viewModel.TargetId = SelectedVariable.Id;
|
||||
navigationService.NavigateToAsync(viewModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当变量表的启用/禁用状态改变时调用。
|
||||
/// 更新数据库中变量表的激活状态,并显示相应的通知。
|
||||
|
||||
@@ -116,6 +116,10 @@
|
||||
<DataTemplate DataType="{x:Type vm:VariableTableViewModel}">
|
||||
<local:VariableTableView DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
<!-- 设备变量历史记录页 -->
|
||||
<DataTemplate DataType="{x:Type vm:VariableHistoryViewModel}">
|
||||
<local:VariableHistoryView DataContext="{Binding}" />
|
||||
</DataTemplate>
|
||||
<!-- Mqtt服务器详情页 -->
|
||||
<!-- <DataTemplate DataType="{x:Type vm:MqttServerDetailViewModel}"> -->
|
||||
<!-- <local:MqttServerDetailView DataContext="{Binding }"/> -->
|
||||
|
||||
100
DMS.WPF/Views/VariableHistoryView.xaml
Normal file
100
DMS.WPF/Views/VariableHistoryView.xaml
Normal file
@@ -0,0 +1,100 @@
|
||||
<UserControl
|
||||
x:Class="DMS.WPF.Views.VariableHistoryView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
|
||||
xmlns:ex="clr-namespace:DMS.Extensions"
|
||||
xmlns:helper="clr-namespace:DMS.WPF.Helper"
|
||||
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
|
||||
xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
|
||||
xmlns:vm="clr-namespace:DMS.WPF.ViewModels"
|
||||
d:DataContext="{d:DesignInstance vm:VariableHistoryViewModel}"
|
||||
d:DesignHeight="600"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<UserControl.Resources>
|
||||
<ex:BindingProxy x:Key="proxy" Data="{Binding}" />
|
||||
<valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
|
||||
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
|
||||
|
||||
<!-- 标签字体的样式 -->
|
||||
<Style x:Key="VarHistoryLabelStyle" TargetType="TextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SecondaryTextBrush}" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
<!-- 值字体的样式 -->
|
||||
<Style x:Key="VarHistoryValueStyle" TargetType="TextBlock">
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
<Setter Property="FontSize" Value="14" />
|
||||
<Setter Property="MinWidth" Value="100" />
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<DockPanel>
|
||||
<ikw:SimpleStackPanel Margin="10" DockPanel.Dock="Top">
|
||||
<!-- 选择区域 -->
|
||||
<GroupBox Header="选择条件">
|
||||
<ikw:SimpleStackPanel Margin="5" Spacing="10">
|
||||
<ikw:SimpleStackPanel Orientation="Horizontal" Spacing="10">
|
||||
<TextBlock Style="{StaticResource VarHistoryLabelStyle}" Text="设备:" />
|
||||
<ComboBox
|
||||
MinWidth="150"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Devices}"
|
||||
SelectedItem="{Binding SelectedDevice}" />
|
||||
|
||||
<TextBlock Style="{StaticResource VarHistoryLabelStyle}" Text="变量表:" />
|
||||
<ComboBox
|
||||
MinWidth="150"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding VariableTables}"
|
||||
SelectedItem="{Binding SelectedVariableTable}" />
|
||||
|
||||
<TextBlock Style="{StaticResource VarHistoryLabelStyle}" Text="变量:" />
|
||||
<ComboBox
|
||||
MinWidth="150"
|
||||
DisplayMemberPath="Name"
|
||||
ItemsSource="{Binding Variables}"
|
||||
SelectedItem="{Binding SelectedVariable}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
<ikw:SimpleStackPanel
|
||||
HorizontalAlignment="Right"
|
||||
Orientation="Horizontal"
|
||||
Spacing="10">
|
||||
<TextBlock Style="{StaticResource VarHistoryLabelStyle}" Text="搜索变量:" />
|
||||
<TextBox
|
||||
Width="200"
|
||||
ui:ControlHelper.PlaceholderText="搜索变量..."
|
||||
Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</ikw:SimpleStackPanel>
|
||||
</ikw:SimpleStackPanel>
|
||||
</GroupBox>
|
||||
</ikw:SimpleStackPanel>
|
||||
|
||||
<DataGrid
|
||||
Margin="10"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserDeleteRows="False"
|
||||
CanUserSortColumns="False"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding VariableHistories}"
|
||||
SelectionMode="Single"
|
||||
Style="{StaticResource DataGridBaseStyle}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Binding="{Binding Value}" Header="值" />
|
||||
<DataGridTextColumn
|
||||
Binding="{Binding Timestamp, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss.fff}'}"
|
||||
Header="时间戳"
|
||||
IsReadOnly="True" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
</UserControl>
|
||||
14
DMS.WPF/Views/VariableHistoryView.xaml.cs
Normal file
14
DMS.WPF/Views/VariableHistoryView.xaml.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace DMS.WPF.Views;
|
||||
|
||||
/// <summary>
|
||||
/// VariableHistoryView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class VariableHistoryView : UserControl
|
||||
{
|
||||
public VariableHistoryView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -208,6 +208,14 @@
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem
|
||||
Command="{Binding ToHistoryCommand}"
|
||||
Header="查看历史记录">
|
||||
<MenuItem.Icon>
|
||||
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Add}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.RowStyle>
|
||||
|
||||
@@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog;
|
||||
using DMS.Core.Enums;
|
||||
using DMS.WPF.ViewModels.Items;
|
||||
|
||||
namespace DMS.WPF.Views;
|
||||
|
||||
@@ -50,4 +51,5 @@ public partial class VariableTableView : UserControl
|
||||
IsLoadCompletion = true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user