346 lines
9.9 KiB
C#
346 lines
9.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
using System.Windows.Input;
|
|
using Telerik.Windows.Controls;
|
|
using Prism.Services.Dialogs;
|
|
using SWS.Commons;
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
{
|
|
public class DialogNewStripViewModel : DialogBase, IDialogAware
|
|
{
|
|
#region 字段
|
|
private ObservableCollection<StripParametersInfo> _StripParametersInfos = new ObservableCollection<StripParametersInfo>();
|
|
/// <summary>
|
|
/// 端子排参数信息列表
|
|
/// </summary>
|
|
public ObservableCollection<StripParametersInfo> StripParametersInfos
|
|
{
|
|
get { return _StripParametersInfos; }
|
|
set
|
|
{
|
|
_StripParametersInfos = value;
|
|
RaisePropertyChanged(nameof(StripParametersInfos));
|
|
}
|
|
}
|
|
|
|
private StripParametersInfo _SelectedStripParametersInfo;
|
|
/// <summary>
|
|
/// 当前选中的信号类型
|
|
/// </summary>
|
|
public StripParametersInfo SelectedStripParametersInfo
|
|
{
|
|
get { return _SelectedStripParametersInfo; }
|
|
set
|
|
{
|
|
_SelectedStripParametersInfo = value;
|
|
RaisePropertyChanged(nameof(SelectedStripParametersInfo));
|
|
}
|
|
}
|
|
private bool _IsReadOnly;
|
|
/// <summary>
|
|
/// 是否可编辑
|
|
/// </summary>
|
|
public bool IsReadOnly
|
|
{
|
|
get { return _IsReadOnly; }
|
|
set
|
|
{
|
|
_IsReadOnly = value;
|
|
RaisePropertyChanged(nameof(IsReadOnly));
|
|
}
|
|
}
|
|
|
|
#region 表格下拉列表
|
|
private List<string> _TermNamingType_ls = new List<string>() { "数字", "字母" };
|
|
/// <summary>
|
|
/// 端子编号类型
|
|
/// </summary>
|
|
public List<string> TermNamingType_ls
|
|
{
|
|
get { return _TermNamingType_ls; }
|
|
set
|
|
{
|
|
_TermNamingType_ls = value;
|
|
RaisePropertyChanged(nameof(TermNamingType_ls));
|
|
}
|
|
}
|
|
private List<string> _TermNamingRule_ls = new List<string>() { "按端子排全局编号", "按通道内端子编号", "按通道编号" };
|
|
/// <summary>
|
|
/// 端子编号规则
|
|
/// </summary>
|
|
public List<string> TermNamingRule_ls
|
|
{
|
|
get { return _TermNamingRule_ls; }
|
|
set
|
|
{
|
|
_TermNamingRule_ls = value;
|
|
RaisePropertyChanged(nameof(TermNamingRule_ls));
|
|
}
|
|
}
|
|
private List<string> _TermNamePrefix_ls = new List<string>() { "通道编号", "+,-,s", "无" };
|
|
/// <summary>
|
|
/// 端子前缀
|
|
/// </summary>
|
|
public List<string> TermNamePrefix_ls
|
|
{
|
|
get { return _TermNamePrefix_ls; }
|
|
set
|
|
{
|
|
_TermNamePrefix_ls = value;
|
|
RaisePropertyChanged(nameof(TermNamePrefix_ls));
|
|
}
|
|
}
|
|
private List<string> _TermNameSuffix_ls = new List<string>() { "通道编号", "+,-,s", "无" };
|
|
/// <summary>
|
|
/// 端子后缀
|
|
/// </summary>
|
|
public List<string> TermNameSuffix_ls
|
|
{
|
|
get { return _TermNameSuffix_ls; }
|
|
set
|
|
{
|
|
_TermNameSuffix_ls = value;
|
|
RaisePropertyChanged(nameof(TermNameSuffix_ls));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#endregion
|
|
|
|
public string Title => "";
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
public bool CanCloseDialog()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
//title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
|
|
title = "端子排模版";
|
|
_StripParametersInfos = parameters.GetValue<ObservableCollection<StripParametersInfo>>(GlobalObject.dialogPar.para1.ToString());
|
|
_IsReadOnly = parameters.GetValue<bool>(GlobalObject.dialogPar.para2.ToString());
|
|
}
|
|
|
|
public override void ExecuteOKCommandAsync(object para)
|
|
{
|
|
|
|
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
|
|
if (IsReadOnly)//页面是公共的,为只读时是新增端子排的页面,传回去的事选中的项数据
|
|
{
|
|
res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedStripParametersInfo);
|
|
}
|
|
else
|
|
{
|
|
res.Add(GlobalObject.dialogPar.para1.ToString(), StripParametersInfos.ToList());
|
|
}
|
|
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res));
|
|
}
|
|
public override void ExecuteCloseCommand(object parameter)
|
|
{
|
|
if (parameter as string == "ClickNo")
|
|
{
|
|
DialogResult res = new DialogResult(ButtonResult.No);
|
|
RequestClose.Invoke(res);
|
|
}
|
|
else
|
|
{
|
|
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
|
|
}
|
|
this.Dispose();
|
|
}
|
|
|
|
#region 方法
|
|
public ICommand EditEndCmd => new DelegateCommand(EditEnd);
|
|
/// <summary>
|
|
/// 编辑结束事件
|
|
/// </summary>
|
|
/// <param name="parameter"></param>
|
|
public virtual void EditEnd(object parameter)
|
|
{
|
|
//做个标记表示该项修改过
|
|
SelectedStripParametersInfo.IsModified = true;
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
public class StripParametersInfo : DialogBase
|
|
{
|
|
#region 页面渲染字段
|
|
private int _Index;
|
|
/// <summary>
|
|
/// 序号
|
|
/// </summary>
|
|
public int Index
|
|
{
|
|
get { return _Index; }
|
|
set
|
|
{
|
|
_Index = value;
|
|
RaisePropertyChanged(nameof(Index));
|
|
}
|
|
}
|
|
private string _IoType;
|
|
/// <summary>
|
|
/// 信号类型
|
|
/// </summary>
|
|
public string IoType
|
|
{
|
|
get { return _IoType; }
|
|
set
|
|
{
|
|
_IoType = value;
|
|
RaisePropertyChanged(nameof(Index));
|
|
}
|
|
}
|
|
|
|
private string _MaxCount;
|
|
/// <summary>
|
|
/// 最大数量
|
|
/// </summary>
|
|
public string MaxCount
|
|
{
|
|
get { return _MaxCount; }
|
|
set
|
|
{
|
|
_MaxCount = value;
|
|
RaisePropertyChanged(nameof(MaxCount));
|
|
}
|
|
}
|
|
private string _CHNoPerStrip;
|
|
/// <summary>
|
|
/// 通道数量
|
|
/// </summary>
|
|
public string CHNoPerStrip
|
|
{
|
|
get { return _CHNoPerStrip; }
|
|
set
|
|
{
|
|
_CHNoPerStrip = value;
|
|
RaisePropertyChanged(nameof(CHNoPerStrip));
|
|
}
|
|
}
|
|
private string _TermNoPerCh;
|
|
/// <summary>
|
|
/// 每通道端子数
|
|
/// </summary>
|
|
public string TermNoPerCh
|
|
{
|
|
get { return _TermNoPerCh; }
|
|
set
|
|
{
|
|
_TermNoPerCh = value;
|
|
RaisePropertyChanged(nameof(TermNoPerCh));
|
|
}
|
|
}
|
|
private string _ChNamePrefix;
|
|
/// <summary>
|
|
/// 通道前缀
|
|
/// </summary>
|
|
public string ChNamePrefix
|
|
{
|
|
get { return _ChNamePrefix; }
|
|
set
|
|
{
|
|
_ChNamePrefix = value;
|
|
RaisePropertyChanged(nameof(ChNamePrefix));
|
|
}
|
|
}
|
|
private string _ChNameStartIndex;
|
|
/// <summary>
|
|
/// 通道起始编号
|
|
/// </summary>
|
|
public string ChNameStartIndex
|
|
{
|
|
get { return _ChNameStartIndex; }
|
|
set
|
|
{
|
|
_ChNameStartIndex = value;
|
|
RaisePropertyChanged(nameof(ChNameStartIndex));
|
|
}
|
|
}
|
|
private string _TermNamingType;
|
|
/// <summary>
|
|
/// 端子编号类型
|
|
/// </summary>
|
|
public string TermNamingType
|
|
{
|
|
get { return _TermNamingType; }
|
|
set
|
|
{
|
|
_TermNamingType = value;
|
|
RaisePropertyChanged(nameof(TermNamingType));
|
|
}
|
|
}
|
|
private string _TermNamingRule;
|
|
/// <summary>
|
|
/// 端子编号规则
|
|
/// </summary>
|
|
public string TermNamingRule
|
|
{
|
|
get { return _TermNamingRule; }
|
|
set
|
|
{
|
|
_TermNamingRule = value;
|
|
RaisePropertyChanged(nameof(TermNamingRule));
|
|
}
|
|
}
|
|
private string _TermNamePrefix;
|
|
/// <summary>
|
|
/// 端子前缀
|
|
/// </summary>
|
|
public string TermNamePrefix
|
|
{
|
|
get { return _TermNamePrefix; }
|
|
set
|
|
{
|
|
_TermNamePrefix = value;
|
|
RaisePropertyChanged(nameof(TermNamePrefix));
|
|
}
|
|
}
|
|
private string _TermNameSuffix;
|
|
/// <summary>
|
|
/// 端子后缀
|
|
/// </summary>
|
|
public string TermNameSuffix
|
|
{
|
|
get { return _TermNameSuffix; }
|
|
set
|
|
{
|
|
_TermNameSuffix = value;
|
|
RaisePropertyChanged(nameof(TermNameSuffix));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
#region 扩展字段
|
|
private bool _IsModified;
|
|
/// <summary>
|
|
/// 表示是否修改过
|
|
/// </summary>
|
|
public bool IsModified
|
|
{
|
|
get { return _IsModified; }
|
|
set { _IsModified = value;
|
|
RaisePropertyChanged(nameof(IsModified));
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
}
|