87 lines
1.9 KiB
C#
87 lines
1.9 KiB
C#
using Avalonia;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using Cowain.Base.Helpers;
|
|
|
|
namespace Plugin.Cowain.Wcs.ViewModels.ProcessGraph;
|
|
|
|
public partial class StationNodeViewModel : ObservableObject
|
|
{
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
|
|
[ObservableProperty]
|
|
private int _station1Id;
|
|
|
|
[ObservableProperty]
|
|
private string? _station1Name = "未选择";
|
|
|
|
[ObservableProperty]
|
|
private string? _station1Code = "";
|
|
|
|
[ObservableProperty]
|
|
private int? _station2Id;
|
|
|
|
[ObservableProperty]
|
|
private string? _station2Name = "未选择";
|
|
|
|
[ObservableProperty]
|
|
private string? _station2Code = "";
|
|
|
|
[ObservableProperty]
|
|
private Point _location;
|
|
|
|
|
|
|
|
public ConnectorViewModel Input { get; } = new ConnectorViewModel { Title = "Input" };
|
|
|
|
public ConnectorViewModel Output { get; } = new ConnectorViewModel { Title = "Output" };
|
|
|
|
|
|
|
|
public StationNodeViewModel()
|
|
{
|
|
Input.NodeId = Id;
|
|
Output.NodeId = Id;
|
|
}
|
|
|
|
|
|
partial void OnStation1IdChanged(int value)
|
|
{
|
|
|
|
|
|
if (GlobalData.Instance["Stations"] is List<StationViewModel> stations)
|
|
{
|
|
var station = stations.FirstOrDefault(x => x.Id == value);
|
|
if (station != null)
|
|
{
|
|
Station1Name = station.StationName;
|
|
Station1Code = station.StationCode;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
partial void OnStation2IdChanged(int? value)
|
|
{
|
|
|
|
|
|
if (GlobalData.Instance["Stations"] is List<StationViewModel> stations)
|
|
{
|
|
var station = stations.FirstOrDefault(x => x.Id == value);
|
|
if (station != null)
|
|
{
|
|
Station2Name = station.StationName;
|
|
Station2Code = station.StationCode;
|
|
}
|
|
else
|
|
{
|
|
Station2Name = "未选择";
|
|
Station2Code = "";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|