Files
WCS/Plugins/Wcs/Plugin.Cowain.Wcs/ViewModels/ProcessGraph/StationNodeViewModel.cs

87 lines
1.9 KiB
C#
Raw Normal View History

2026-03-02 09:13:29 +08:00
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]
2026-03-02 10:56:30 +08:00
private int _station1Id;
2026-03-02 09:13:29 +08:00
[ObservableProperty]
2026-03-02 10:56:30 +08:00
private string? _station1Name = "未选择";
2026-03-02 09:13:29 +08:00
[ObservableProperty]
2026-03-02 10:56:30 +08:00
private string? _station1Code = "";
[ObservableProperty]
private int? _station2Id;
[ObservableProperty]
private string? _station2Name = "未选择";
[ObservableProperty]
private string? _station2Code = "";
2026-03-02 09:13:29 +08:00
[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;
}
2026-03-02 10:56:30 +08:00
partial void OnStation1IdChanged(int value)
2026-03-02 09:13:29 +08:00
{
if (GlobalData.Instance["Stations"] is List<StationViewModel> stations)
{
var station = stations.FirstOrDefault(x => x.Id == value);
if (station != null)
{
2026-03-02 10:56:30 +08:00
Station1Name = station.StationName;
Station1Code = station.StationCode;
2026-03-02 09:13:29 +08:00
}
2026-03-02 10:56:30 +08:00
2026-03-02 09:13:29 +08:00
}
}
2026-03-02 10:56:30 +08:00
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 = "";
}
}
}
2026-03-02 09:13:29 +08:00
}