113 lines
3.2 KiB
C#
113 lines
3.2 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.Windows;
|
|
using Prism.Ioc;
|
|
using Prism.Services.Dialogs;
|
|
using Telerik.Windows.Controls;
|
|
using DialogParameters = Prism.Services.Dialogs.DialogParameters;
|
|
|
|
namespace DI_Electrical.ViewModels
|
|
{
|
|
public class DialogSignalSelectViewModel : DialogBase, IDialogAware
|
|
{
|
|
|
|
public DialogSignalSelectViewModel(IContainerProvider container)
|
|
{
|
|
title = "信号选择框";
|
|
}
|
|
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
public bool CanCloseDialog()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
|
|
}
|
|
private ObservableCollection<Signal> _listSignal;
|
|
/// <summary>
|
|
/// 单位列表
|
|
/// </summary>
|
|
public ObservableCollection<Signal> listSignal
|
|
{
|
|
get { return _listSignal; }
|
|
set { _listSignal = value; RaisePropertyChanged(nameof(listSignal)); }
|
|
}
|
|
private Signal _SelectedSignal;
|
|
/// <summary>
|
|
/// 选中的单位
|
|
/// </summary>
|
|
public Signal SelectedSignal
|
|
{
|
|
get { return _SelectedSignal; }
|
|
set { _SelectedSignal = value; RaisePropertyChanged(nameof(SelectedSignal)); }
|
|
}
|
|
|
|
public string Title => "信号选择框";
|
|
|
|
public void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
var signals = parameters.GetValue<ObservableCollection<SignalManagementInfo>>(GlobalObject.dialogPar.para1.ToString());
|
|
|
|
listSignal = new ObservableCollection<Signal>();
|
|
foreach (var item in signals)
|
|
{
|
|
if (item.type.Equals("信号"))
|
|
{
|
|
listSignal.Add(new Signal() { SignalId = item.Wire_Group_ID, SignalName = item.Group_Name });
|
|
}
|
|
}
|
|
}
|
|
public override void ExecuteOKCommandAsync(object para)
|
|
{
|
|
if (SelectedSignal == null)
|
|
{
|
|
MessageBox.Show("请选择一个信号!");
|
|
return;
|
|
}
|
|
IDialogParameters res = new DialogParameters();
|
|
res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedSignal);
|
|
DialogResult result = new DialogResult(ButtonResult.Yes, res);
|
|
RequestClose.Invoke(result);
|
|
}
|
|
public override void ExecuteCloseCommand(object parameter)
|
|
{
|
|
IDialogParameters res = new DialogParameters();
|
|
DialogResult result = new DialogResult(ButtonResult.No, res);
|
|
RequestClose.Invoke(result);
|
|
this.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public class Signal : ViewModelBase
|
|
{
|
|
private string _SignalId;
|
|
/// <summary>
|
|
/// Id
|
|
/// </summary>
|
|
public string SignalId
|
|
{
|
|
get { return _SignalId; }
|
|
set { _SignalId = value; RaisePropertyChanged(nameof(SignalId)); }
|
|
}
|
|
|
|
private string _SignalName;
|
|
/// <summary>
|
|
/// 信号
|
|
/// </summary>
|
|
public string SignalName
|
|
{
|
|
get { return _SignalName; }
|
|
set { _SignalName = value; RaisePropertyChanged(nameof(SignalName)); }
|
|
}
|
|
|
|
}
|
|
|
|
}
|