009_DI-Elec/newFront/c#前端/SWS.CAD/ViewModels/DialogIODistributionVM/DialogCablePreAssignPreviewViewModel.cs

215 lines
6.2 KiB
C#
Raw Normal View History

2025-08-15 16:34:31 +08:00
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.Ioc;
using SWS.CAD.Views.Dialog;
2025-09-04 18:28:02 +08:00
using Prism.Services.Dialogs;
using SWS.Commons;
using SWS.Model;
2025-08-15 16:34:31 +08:00
namespace SWS.CAD.ViewModels
{
public class DialogCablePreAssignPreviewViewModel : DialogBase, IDialogAware
{
#region
private ObservableCollection<PreAssignCable> _PreAssignCables = new ObservableCollection<PreAssignCable>();
/// <summary>
/// 端子排参数信息列表
/// </summary>
public ObservableCollection<PreAssignCable> PreAssignCables
{
get { return _PreAssignCables; }
set
{
_PreAssignCables = value;
RaisePropertyChanged(nameof(PreAssignCables));
}
}
#endregion
2025-09-04 18:28:02 +08:00
public string Title => "";
public event Action<IDialogResult> RequestClose;
2025-08-15 16:34:31 +08:00
public bool CanCloseDialog()
{
return true;
}
public void OnDialogClosed()
{
}
private List<ec_Cable> CablePreAssigns;
public async void OnDialogOpened(IDialogParameters parameters)
{
//title = parameters.GetValue<string>(GlobalObject.dialogPar.title.ToString());
title = "待分配的信号预览和统计";
_PreAssignCables = parameters.GetValue<ObservableCollection<PreAssignCable>>(GlobalObject.dialogPar.para1.ToString());
}
public override void ExecuteOKCommandAsync(object parameter)
{
if (PreAssignCables.Any(p => p.IsChecked == true))
{
//打开窗体
2025-09-04 18:28:02 +08:00
IDialogParameters para = new Prism.Services.Dialogs.DialogParameters();
2025-08-15 16:34:31 +08:00
para.Add(GlobalObject.dialogPar.para1.ToString(), PreAssignCables);
var _dialogService = GlobalObject._prismContainer.Resolve<IDialogService>();
_dialogService.ShowDialog(nameof(DialogCablePreAssignResult), para, async (RES) =>
{
if (RES.Result == ButtonResult.Yes)
{
}
else if (RES.Result == ButtonResult.No)
{ }
});
}
//返回的结果
2025-09-04 18:28:02 +08:00
IDialogParameters res = new Prism.Services.Dialogs.DialogParameters();
2025-08-15 16:34:31 +08:00
//res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedStripParametersInfo);
2025-09-04 18:28:02 +08:00
RequestClose.Invoke(new DialogResult(ButtonResult.Yes, res));
2025-08-15 16:34:31 +08:00
}
public override void ExecuteCloseCommand(object parameter)
{
if (parameter as string == "ClickNo")
{
2025-09-04 18:28:02 +08:00
DialogResult res = new DialogResult(ButtonResult.No);
RequestClose.Invoke(res);
2025-08-15 16:34:31 +08:00
}
else
{
2025-09-04 18:28:02 +08:00
RequestClose.Invoke(new DialogResult(ButtonResult.Cancel));
2025-08-15 16:34:31 +08:00
}
this.Dispose();
}
#region
public ICommand EditEndCmd => new DelegateCommand(EditEnd);
/// <summary>
/// 编辑结束事件
/// </summary>
/// <param name="parameter"></param>
public virtual void EditEnd(object parameter)
{
//做个标记表示该项修改过
}
#region
public ICommand ButtonCommand => new DelegateCommand(Button_Click);
/// <summary>
/// 页面左侧按钮
/// </summary>
/// <param name="parameter"></param>
public virtual async void Button_Click(object parameter)
{
if (parameter.ToString().Equals("全选"))
{
foreach (var item in PreAssignCables)
{
item.IsChecked = true;
}
return;
}
if(parameter.ToString().Equals("清空"))
{
foreach (var item in PreAssignCables)
{
item.IsChecked = false;
}
return;
}
}
#endregion
#endregion
}
public class PreAssignCable: DialogBase
{
#region
private int _Index;
/// <summary>
/// 序号
/// </summary>
public int Index
{
get { return _Index; }
set { _Index = value; }
}
private bool _IsChecked;
/// <summary>
/// 选择
/// </summary>
public bool IsChecked
{
get { return _IsChecked; }
set { _IsChecked = value;
RaisePropertyChanged(nameof(IsChecked));
}
}
private string _TagNumber;
/// <summary>
/// 电缆位号
/// </summary>
public string TagNumber
{
get { return _TagNumber; }
set { _TagNumber = value; }
}
private string _PreAssignIOType;
/// <summary>
/// 预分配的信号类型
/// </summary>
public string PreAssignIOType
{
get { return _PreAssignIOType; }
set { _PreAssignIOType = value; }
}
private string _CableClass;
/// <summary>
/// 是否为母线
/// </summary>
public string CableClass
{
get { return _CableClass; }
set { _CableClass = value; }
}
private string _ToPanel_TagNumber;
/// <summary>
/// 预分配的系统柜
/// </summary>
public string ToPanel_TagNumber
{
get { return _ToPanel_TagNumber; }
set { _ToPanel_TagNumber = value; }
}
public PreAssignCable()
{
}
public PreAssignCable(ec_Cable ec_Cable)
{
TagNumber = ec_Cable.TagNumber;
PreAssignIOType = ec_Cable.PreAssignIOType;
CableClass =ec_Cable.CableClass.Equals("homerun") ? "是":"否";
ToPanel_TagNumber = ec_Cable.ToPanel!=null?ec_Cable.ToPanel.TagNumber:null;
}
#endregion
}
}