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

56 lines
1.2 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]
private int _stationId;
[ObservableProperty]
private string? _stationName = "no station";
[ObservableProperty]
private string? _stationCode = "no station";
[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 OnStationIdChanged(int value)
{
if (GlobalData.Instance["Stations"] is List<StationViewModel> stations)
{
var station = stations.FirstOrDefault(x => x.Id == value);
if (station != null)
{
StationName = station.StationName;
StationCode = station.StationCode;
}
}
}
}