74 lines
2.2 KiB
C#
74 lines
2.2 KiB
C#
using System;
|
|
using System.Reactive.Linq;
|
|
using Intromat.PersistentModel;
|
|
using Intromat.PersistentModel.Nodes;
|
|
using Intromat.Views;
|
|
using NodeNetwork.Toolkit.Group.AddEndpointDropPanel;
|
|
using NodeNetwork.ViewModels;
|
|
using ReactiveUI;
|
|
using Splat;
|
|
|
|
namespace Intromat.ViewModels.Nodes
|
|
{
|
|
public class GroupSubnetIONodeViewModel : CodeGenNodeViewModel
|
|
{
|
|
private CodeNodeGroupIOBinding? _ioBinding;
|
|
private bool _isEntranceNode;
|
|
|
|
static GroupSubnetIONodeViewModel()
|
|
{
|
|
Locator.CurrentMutable.Register(() => new GroupSubnetIONodeView(), typeof(IViewFor<GroupSubnetIONodeViewModel>));
|
|
}
|
|
|
|
public GroupSubnetIONodeViewModel()
|
|
: base(NodeType.Group)
|
|
{
|
|
this.WhenAnyValue(vm => vm.IsEntranceNode)
|
|
.StartWith(false)
|
|
.Subscribe(isEntrance => Name = isEntrance ? "Group Input" : "Group Output");
|
|
}
|
|
|
|
public NetworkViewModel? Subnet { get; set; }
|
|
|
|
public AddEndpointDropPanelViewModel? AddEndpointDropPanelVM { get; set; }
|
|
|
|
public bool IsEntranceNode
|
|
{
|
|
get => _isEntranceNode;
|
|
set => this.RaiseAndSetIfChanged(ref _isEntranceNode, value);
|
|
}
|
|
|
|
public CodeNodeGroupIOBinding? IOBinding
|
|
{
|
|
get => _ioBinding;
|
|
set
|
|
{
|
|
if (_ioBinding != null)
|
|
throw new InvalidOperationException("IOBinding is already set.");
|
|
|
|
_ioBinding = value;
|
|
|
|
AddEndpointDropPanelVM = new AddEndpointDropPanelViewModel(IsEntranceNode, !IsEntranceNode) { NodeGroupIOBinding = IOBinding };
|
|
}
|
|
}
|
|
|
|
public override NodeModelBase CreateModel()
|
|
{
|
|
return new GroupSubnetIOModel();
|
|
}
|
|
|
|
public override void LoadModel(NodeModelBase model)
|
|
{
|
|
base.LoadModel(model);
|
|
var groupSubnetIO = (GroupSubnetIOModel)model;
|
|
IsEntranceNode = groupSubnetIO.IsEntrance;
|
|
}
|
|
|
|
public override void SaveModel(NodeModelBase model)
|
|
{
|
|
base.SaveModel(model);
|
|
var groupSubnetIO = (GroupSubnetIOModel)model;
|
|
groupSubnetIO.IsEntrance = IsEntranceNode;
|
|
}
|
|
}
|
|
} |