将pollLevel属性名改为pollingInterval

This commit is contained in:
2025-09-05 20:24:27 +08:00
parent 6e123b47cc
commit 08f9de137e
17 changed files with 95 additions and 98 deletions

View File

@@ -78,8 +78,6 @@
</Page>
<Page Update="Views\Dialogs\PollLevelDialog.xaml">
<Generator>MSBuild:Compile</Generator>
<XamlRuntime>Wpf</XamlRuntime>
<SubType>Designer</SubType>
</Page>
<Page Update="Views\Dialogs\ProcessingDialog.xaml">
<Generator>MSBuild:Compile</Generator>

View File

@@ -9,22 +9,22 @@ namespace DMS.WPF.ViewModels.Dialogs
public partial class PollLevelDialogViewModel : DialogViewModelBase<int?>
{
[ObservableProperty]
private int _selectedPollLevelType;
private int _selectedPollingInterval;
public List<int> PollLevelTypes { get; }
public List<int> PollingIntervals { get; }
public PollLevelDialogViewModel(int currentPollLevelType)
public PollLevelDialogViewModel(int currentPollingInterval)
{
PollLevelTypes = new List<int> { 10, 100, 500, 1000, 5000, 10000, 20000, 30000, 60000, 180000, 300000, 600000, 1800000, 3600000 };
SelectedPollLevelType = currentPollLevelType;
Title = "修改轮询频率";
PollingIntervals = new List<int> { 10, 100, 500, 1000, 5000, 10000, 20000, 30000, 60000, 180000, 300000, 600000, 1800000, 3600000 };
SelectedPollingInterval = currentPollingInterval;
Title = "修改轮询间隔";
PrimaryButText = "确定";
}
[RelayCommand]
private void PrimaryButton()
{
Close(SelectedPollLevelType);
Close(SelectedPollingInterval);
}
[RelayCommand]

View File

@@ -69,11 +69,11 @@ public partial class VariableItemViewModel : ObservableObject
private SignalType _signalType =SignalType.OtherASignal;
/// <summary>
/// 获取或设置变量的轮询等级
/// 用于决定数据采集的频率(如:高、中、低)
/// 获取或设置变量的轮询间隔(毫秒)
/// 用于决定数据采集的频率。
/// </summary>
[ObservableProperty]
private int _pollLevel = 30000; // ThirtySeconds
private int _pollingInterval = 30000; // ThirtySeconds
/// <summary>
/// 获取或设置一个值,该值指示此变量是否被激活。

View File

@@ -472,12 +472,12 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
/// </summary>
/// <param name="variablesToChange">要修改轮询频率的变量数据列表。</param>
[RelayCommand]
public async Task ChangePollLevel()
public async Task ChangePollingInterval()
{
// 检查是否有变量被选中
if (SelectedVariables.Count == 0)
{
_notificationService.ShowInfo("请选择要修改轮询频率的变量");
_notificationService.ShowInfo("请选择要修改轮询间隔的变量");
return;
}
@@ -485,16 +485,16 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
var validVariables = SelectedVariables.Cast<VariableItemViewModel>()
.ToList();
// 显示轮询频率选择对话框,并传入第一个变量的当前轮询频率作为默认值
// 显示轮询间隔选择对话框,并传入第一个变量的当前轮询间隔作为默认值
PollLevelDialogViewModel viewModel = new PollLevelDialogViewModel(validVariables.First()
.PollLevel);
var newPollLevelType = await _dialogService.ShowDialogAsync(viewModel);
if (newPollLevelType.HasValue)
.PollingInterval);
var newPollingInterval = await _dialogService.ShowDialogAsync(viewModel);
if (newPollingInterval.HasValue)
{
// 更新所有选定变量的轮询频率和修改状态
// 更新所有选定变量的轮询间隔和修改状态
foreach (var variable in validVariables)
{
variable.PollLevel = newPollLevelType.Value;
variable.PollingInterval = newPollingInterval.Value;
variable.UpdatedAt = DateTime.Now;
}
@@ -505,11 +505,11 @@ partial class VariableTableViewModel : ViewModelBase, INavigatable
if (result > 0)
{
// 显示成功通知
_notificationService.ShowSuccess($"已成功更新 {validVariables.Count} 个变量的轮询频率");
_notificationService.ShowSuccess($"已成功更新 {validVariables.Count} 个变量的轮询间隔");
}
else
{
_notificationService.ShowError("更新轮询频率失败");
_notificationService.ShowError("更新轮询间隔失败");
}
}
}

View File

@@ -20,8 +20,8 @@
<Grid>
<ComboBox
Margin="20"
ItemsSource="{Binding PollLevelTypes}"
SelectedItem="{Binding SelectedPollLevelType}">
ItemsSource="{Binding PollingIntervals}"
SelectedItem="{Binding SelectedPollingInterval}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}" />

View File

@@ -148,8 +148,8 @@
Grid.Row="2"
Grid.Column="0"
Margin="0,15,0,0"
hc:InfoElement.Title="轮询级别:"
Text="{Binding PollLevel}"
hc:InfoElement.Title="轮询间隔(毫秒):"
Text="{Binding PollingInterval}"
>
</hc:TextBox>

View File

@@ -179,9 +179,9 @@
</MenuItem.Icon>
</MenuItem>
<MenuItem
Command="{Binding ChangePollLevelCommand}"
Command="{Binding ChangePollingIntervalCommand}"
CommandParameter="{Binding PlacementTarget.SelectedItems, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
Header="修改轮询频率">
Header="修改轮询间隔">
<MenuItem.Icon>
<ui:FontIcon Icon="{x:Static ui:SegoeFluentIcons.Edit}" />
</MenuItem.Icon>
@@ -268,10 +268,10 @@
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="轮询频率" SortMemberPath="PollLevel">
<DataGridTemplateColumn Header="轮询间隔(毫秒)" SortMemberPath="PollingInterval">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding PollLevel}" />
<TextBlock Text="{Binding PollingInterval}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>