port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
using System;
using System.Diagnostics;
using DynamicData;
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 GroupNodeViewModel : CodeGenNodeViewModel
{
private CodeNodeGroupIOBinding? _ioBinding;
static GroupNodeViewModel()
{
Locator.CurrentMutable.Register(() => new GroupNodeView(), typeof(IViewFor<GroupNodeViewModel>));
}
public GroupNodeViewModel()
: base(NodeType.Group)
{
}
public NetworkViewModel? Subnet { get; set; }
public AddEndpointDropPanelViewModel? AddEndpointDropPanelVM { get; private set; }
public CodeNodeGroupIOBinding? IOBinding
{
get => _ioBinding;
set
{
if (_ioBinding != null)
throw new InvalidOperationException("IOBinding is already set.");
_ioBinding = value;
AddEndpointDropPanelVM = new AddEndpointDropPanelViewModel { NodeGroupIOBinding = IOBinding };
}
}
public override NodeModelBase CreateModel()
{
return new GroupModel();
}
public override void SaveModel(NodeModelBase model)
{
Debug.Assert(Subnet != null, nameof(Subnet) + " != null");
Debug.Assert(IOBinding != null, nameof(IOBinding) + " != null");
base.SaveModel(model);
var group = (GroupModel)model;
var network = ProjectSerializer.SaveModel((CodeGenNetworkViewModel)Subnet);
group.Network = network;
foreach (var input in Inputs.Items)
{
var endpointType = input.GetType().GenericTypeArguments[0];
var list = endpointType.IsGenericType && typeof(IObservableList<>) == endpointType.GetGenericTypeDefinition();
if (list)
endpointType = endpointType.GenericTypeArguments[0];
group.Inputs.Add(new GroupEndpointModel
{
Name = input.Name,
EndpointType = endpointType.ToString(),
SortIndex = input.SortIndex,
PortType = ((CodeGenPortViewModel)input.Port).PortType,
List = list
});
}
foreach (var output in Outputs.Items)
{
var endpointType = output.GetType().GenericTypeArguments[0];
var list = endpointType.IsGenericType && typeof(IObservableList<>) == endpointType.GetGenericTypeDefinition();
if (list)
endpointType = endpointType.GenericTypeArguments[0];
group.Outputs.Add(new GroupEndpointModel
{
Name = output.Name,
EndpointType = endpointType.ToString(),
SortIndex = output.SortIndex,
PortType = ((CodeGenPortViewModel)output.Port).PortType,
List = list
});
}
}
}
}

View File

@@ -0,0 +1,74 @@
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;
}
}
}