122 lines
3.3 KiB
C#
122 lines
3.3 KiB
C#
using Prism.Dialogs;
|
|
using SWS.CAD.Models;
|
|
using SWS.CAD.Services;
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
using SWS.CAD.Views;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using Telerik.Windows.Controls;
|
|
using Unity;
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
{
|
|
public class DialogSignalSelectViewModel : DialogBase, IDialogAware
|
|
{
|
|
|
|
public DialogSignalSelectViewModel()
|
|
{
|
|
title = "信号选择框";
|
|
}
|
|
|
|
public DialogCloseListener RequestClose { get; }
|
|
|
|
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 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;
|
|
}
|
|
Prism.Dialogs.DialogParameters res = new Prism.Dialogs.DialogParameters();
|
|
res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedSignal);
|
|
RequestClose.Invoke(res,ButtonResult.Yes);
|
|
}
|
|
public override void ExecuteCloseCommand(object parameter)
|
|
{
|
|
if (parameter as string == "ClickNo")
|
|
{
|
|
RequestClose.Invoke(ButtonResult.No);
|
|
}
|
|
else
|
|
{
|
|
RequestClose.Invoke(ButtonResult.Cancel);
|
|
}
|
|
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)); }
|
|
}
|
|
|
|
}
|
|
|
|
}
|