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,75 @@
using System;
using System.Reactive.Linq;
using DynamicData;
using Intromat.Model.Compiler;
using Intromat.PersistentModel;
using Intromat.ViewModels;
using Intromat.ViewModels.Editors;
using Intromat.ViewModels.Previews;
using Intromat.Views;
using NodeNetwork.Toolkit.ValueNode;
using ReactiveUI;
using Splat;
namespace Intromat.Nodes.Code
{
public class PrintNode : ExecutionNodeBase
{
static PrintNode()
{
Locator.CurrentMutable.Register(() => new CodeGenNodeView(), typeof(IViewFor<PrintNode>));
}
public PrintNode() : base(NodeType.Code)
{
Name = "Print";
Text = new CodeGenInputViewModel<ITypedExpression<string>>(EPortType.String)
{
Name = "Text",
Editor = TextEditor
};
Inputs.Add(Text);
FlowIn.Value = FlowOutChanged
.CombineLatest(Text.ValueChanged, (flowOutChanged, textValueChanged) => (FlowOutChanged: flowOutChanged, StringExpression: textValueChanged))
.Select(v => new FunctionCall
{
FunctionName = "print",
FlowOut = FlowOut.Value,
Parameters = { v.StringExpression ?? new StringLiteralValue { Value = "" } }
});
var stringPreview = new StringPreviewViewModel();
Preview = stringPreview;
this.WhenAnyValue(vm => vm.Text.Value)
.Where(v => v != null)
.Subscribe(_ => stringPreview.Value = Text.Value.PreviewValue ?? string.Empty);
}
public StringExpressionEditorViewModel TextEditor { get; } = new();
public ValueNodeInputViewModel<ITypedExpression<string>> Text { get; }
public override NodeModelBase CreateModel()
{
return new PrintModel();
}
public override void SaveModel(NodeModelBase model)
{
base.SaveModel(model);
var print = (PrintModel)model;
print.Text = TextEditor.Value is StringLiteralValue text ? text.Value : null;
}
public override void LoadModel(NodeModelBase model)
{
base.LoadModel(model);
var print = (PrintModel)model;
if (print.Text != null)
TextEditor.Value = new StringLiteralValue { Value = print.Text };
}
}
}