76 lines
2.0 KiB
C#
76 lines
2.0 KiB
C#
using BOB;
|
|
using BOB.Models;
|
|
using Model;
|
|
using Prism.Mvvm;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows.Input;
|
|
|
|
namespace ProcessManager.ViewModels
|
|
{
|
|
public class SettingViewModel : BindableBase, IDialogAware
|
|
{
|
|
private string _Title;
|
|
|
|
public string Title
|
|
{
|
|
get => _Title;
|
|
set => SetProperty(ref _Title, value);
|
|
}
|
|
private DeviceConfigModel _SelectedDevice;
|
|
|
|
public DeviceConfigModel SelectedDevice
|
|
{
|
|
get => _SelectedDevice;
|
|
set => SetProperty(ref _SelectedDevice, value);
|
|
}
|
|
|
|
private SystemConfig _config;
|
|
public SystemConfig Config
|
|
{
|
|
get => _config;
|
|
set => SetProperty(ref _config, value);
|
|
}
|
|
|
|
public ObservableCollection<DeviceConfigModel> Devices { get; set; } = new ObservableCollection<DeviceConfigModel>();
|
|
|
|
public DialogCloseListener RequestClose { get; set; }
|
|
public ICommand SaveCommand { get; set; }
|
|
public ICommand CancelCommand { get; set; }
|
|
public SettingViewModel()
|
|
{
|
|
CancelCommand = new DelegateCommand(Cancel);
|
|
SaveCommand = new DelegateCommand(Save);
|
|
}
|
|
|
|
private void Save()
|
|
{
|
|
RequestClose.Invoke();
|
|
}
|
|
|
|
private void Cancel()
|
|
{
|
|
RequestClose.Invoke();
|
|
}
|
|
|
|
public bool CanCloseDialog() => true;
|
|
|
|
public void OnDialogClosed() { }
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
// 从参数获取 SystemConfig
|
|
if (parameters.ContainsKey("SystemConfig"))
|
|
{
|
|
Config = parameters.GetValue<SystemConfig>("SystemConfig");
|
|
Devices.Clear();
|
|
foreach (var d in Config.DeviceList)
|
|
Devices.Add(d);
|
|
}
|
|
if (parameters.ContainsKey("Title"))
|
|
{
|
|
Title= parameters.GetValue<string>("Title");
|
|
}
|
|
}
|
|
}
|
|
}
|