添加修改轮询时间的功能
This commit is contained in:
22
ViewModels/Dialogs/PollLevelDialogViewModel.cs
Normal file
22
ViewModels/Dialogs/PollLevelDialogViewModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using PMSWPF.Enums;
|
||||
|
||||
namespace PMSWPF.ViewModels.Dialogs
|
||||
{
|
||||
public partial class PollLevelDialogViewModel : ObservableObject
|
||||
{
|
||||
[ObservableProperty]
|
||||
private PollLevelType _selectedPollLevelType;
|
||||
|
||||
public List<PollLevelType> PollLevelTypes { get; }
|
||||
|
||||
public PollLevelDialogViewModel(PollLevelType currentPollLevelType)
|
||||
{
|
||||
PollLevelTypes = Enum.GetValues(typeof(PollLevelType)).Cast<PollLevelType>().ToList();
|
||||
SelectedPollLevelType = currentPollLevelType;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,6 +253,24 @@ partial class VariableTableViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private async Task ChangePollLevel()
|
||||
{
|
||||
if (SelectedVariableData == null)
|
||||
{
|
||||
NotificationHelper.ShowMessage("请选择一个变量", NotificationType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var newPollLevelType = await _dialogService.ShowPollLevelDialog(SelectedVariableData.PollLevelType);
|
||||
if (newPollLevelType.HasValue)
|
||||
{
|
||||
SelectedVariableData.PollLevelType = newPollLevelType.Value;
|
||||
await _varDataRepository.UpdateAsync(SelectedVariableData);
|
||||
NotificationHelper.ShowMessage($"变量 {SelectedVariableData.Name} 的轮询频率已更新", NotificationType.Success);
|
||||
}
|
||||
}
|
||||
|
||||
// [RelayCommand]
|
||||
// private async void ImportFromExcel()
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user