public ProductNodeViewModel() { Name = "Product"; Input1 = new ValueNodeInputViewModel <int?> { Name = "A", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input1); Input2 = new ValueNodeInputViewModel <int?> { Name = "B", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input2); var product = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value) .Select(_ => Input1.Value != null && Input2.Value != null ? Input1.Value * Input2.Value : null); Output = new ValueNodeOutputViewModel <int?> { Name = "A * B", Value = product }; Outputs.Add(Output); }
public AxisToButtonsNode() { Name = "Axis To Buttons"; var input = new ValueNodeInputViewModel <short?>() { Name = "Input", Port = new AxisPortViewModel() }; Inputs.Add(input); AddOutput("Output Low"); AddOutput("Output High"); input.ValueChanged.Subscribe(newValue => { if (newValue < 0) { _outputs[0].OnNext(true); _outputs[1].OnNext(false); } else if (newValue > 0) { _outputs[0].OnNext(false); _outputs[1].OnNext(true); } else { _outputs[0].OnNext(false); _outputs[1].OnNext(false); } }); }
public ButtonToEventNode() { Name = "Button To Event"; var input = new ValueNodeInputViewModel <bool?>() { Name = "Input", Port = new ButtonPortViewModel(), }; Inputs.Add(input); input.ValueChanged.Subscribe(newValue => { if (newValue == null || !(bool)newValue) { return; } _output.OnNext(DateTime.Now); }); Outputs.Add(new ValueNodeOutputViewModel <DateTime?> { Name = "Output", Value = _output }); }
public DivisionNodeViewModel() { Name = "Divide"; Input1 = new ValueNodeInputViewModel <int?> { Name = "A", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input1); Input2 = new ValueNodeInputViewModel <int?> { Name = "B", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input2); var divide = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value) .Select(_ => Input1.Value != null && Input2.Value != null && Input2.Value != 0 ? Input1.Value / Input2.Value : null); Output = new ValueNodeOutputViewModel <int?> { Name = "A / B", Value = divide }; Outputs.Add(Output); }
public SumNodeViewModel() { Name = "Sum"; Input1 = new ValueNodeInputViewModel <int?> { Name = "A", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input1); Input2 = new ValueNodeInputViewModel <int?> { Name = "B", Editor = new IntegerValueEditorViewModel() }; Inputs.Add(Input2); var sum = this.WhenAnyValue(vm => vm.Input1.Value, vm => vm.Input2.Value) .Select(_ => Input1.Value != null && Input2.Value != null ? Input1.Value + Input2.Value : null); Output = new ValueNodeOutputViewModel <int?> { Name = "A + B", Value = sum }; Outputs.Add(Output); }
public BlurFilterNodeModel() { //Node Name this.Name = "Blur Filter"; //------------------KERNEL SIZE------------------ Inp_Kernel = new ValueNodeInputViewModel <double?>() { Name = "Kernel Size" }; Inp_Kernel.Editor = new SliderValueEditorViewModel(3, 3, 30); Inp_Kernel.Port.IsVisible = false; this.Inputs.Add(Inp_Kernel); //------------------------------------------------------ //------------------BORDER TYPE------------------ Inp_BorderType = new ValueNodeInputViewModel <object>() { Name = "Border Type" }; Inp_BorderType.Editor = new EnumValueEditorViewModel(typeof(Emgu.CV.CvEnum.BorderType)); Inp_BorderType.Port.IsVisible = false; this.Inputs.Add(Inp_BorderType); //------------------------------------------------------ this.WhenAnyObservable( vm => vm.Inp_Mat.Changed, vm => vm.Inp_Kernel.Changed, vm => vm.Inp_BorderType.Changed).Subscribe(newValue => { ApplyFilter(); }); //------------------------------------------------------ }
public InteractionNode(InteractionLiteral value) : base("Interaction", value) { Description = new ValueNodeInputViewModel <string>() { Name = "Description" }; ActionBuilderLua = new ValueNodeInputViewModel <string>() { Name = "Action Builder (Lua Source)" }; CreationCondition = new ValueNodeInputViewModel <string>() { Name = "Creation Condition (Lua Source)" }; ActivationDistance = new ValueNodeInputViewModel <float>() { Name = "Activation Distance" }; ClientInt = new ValueNodeInputViewModel <string>() { Name = "Client Interaction Code (Lua Source)" }; Location = new ValueNodeInputViewModel <string>() { Name = "Search Location (Lua Source)" }; Output = new ValueNodeOutputViewModel <InteractionLiteral>() { Name = "Resulting Interaction" }; this.Inputs.Add(Description); this.Inputs.Add(ActionBuilderLua); this.Inputs.Add(CreationCondition); this.Inputs.Add(ActivationDistance); this.Inputs.Add(ClientInt); this.Inputs.Add(Location); this.Outputs.Add(Output); this.WhenAnyObservable(vm => vm.Description.Changed, vm => vm.ActionBuilderLua.Changed, vm => vm.CreationCondition.Changed, vm => vm.ActivationDistance.Changed, vm => vm.ClientInt.Changed, vm => vm.Location.Changed).Subscribe(ip => { InteractionLiteral interaction = InputDocument as InteractionLiteral; interaction.Description = Description.Value; interaction.ActionBuilderLua = ActionBuilderLua.Value; interaction.CreationConditionLua = CreationCondition.Value; interaction.ActivationDistance = ActivationDistance.Value; interaction.ClientIntLua = ClientInt.Value; interaction.LocationLua = Location.Value; InputDocument = interaction; Output.Value = Observable.Return(interaction); }); CanBeRemovedByUser = false; }
public virtual ValueNodeOutputViewModel <T> CreateCompatibleOutput <T>(ValueNodeInputViewModel <T> input) { return(new ValueNodeOutputViewModel <T>() { Name = input.Name, Icon = input.Icon }); }
public OUT_Node_Class() { NameInput = new ValueNodeInputViewModel <string>() { Name = "Output", }; Inputs.Add(NameInput); }
public DialogueResponseNode() : base("Response", null) { SpeechInput = new ValueNodeInputViewModel <string>() { Name = "Line of Speech" }; PromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Prompts" }; Order = new ValueNodeInputViewModel <long>() { Name = "Response Order" }; ConditionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Condition" }; ActionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Action" }; Title = new ValueNodeInputViewModel <string>() { Name = "Prompt Name" }; FinalPrompt = new ValueNodeOutputViewModel <DialogueResponse>(); this.Inputs.Add(SpeechInput); this.Inputs.Add(PromptsInput); this.Inputs.Add(Order); this.Inputs.Add(ConditionLua); this.Inputs.Add(ActionLua); this.Inputs.Add(Title); this.Outputs.Add(FinalPrompt); this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.PromptsInput.Changed, vm => vm.Order.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip => { FinalPrompt.Value = Observable.Return(new DialogueResponse() { Speech = SpeechInput.Value, Title = Title.Value, Prompts = new ObservableCollection <DialoguePrompt>(PromptsInput.Values.Items.ToList()), Order = (int)Order.Value, ActionLua = ActionLua.Value, ConditionLua = ConditionLua.Value, }); RodskaApp app = (RodskaApp)System.Windows.Application.Current; MainWindow window = (MainWindow)app.MainWindow; window.SignalDocumentChanged(InputDocument); }); }
public static ValueNodeInputViewModel <object> CreateEnumEditor(string name, Type type) { var result = new ValueNodeInputViewModel <object>() { Name = name, Editor = new EnumEditorViewModel(type), MaxConnections = 0 }; result.Port.IsVisible = false; return(result); }
public OutputNodeViewModel() { Name = "Output"; this.CanBeRemovedByUser = false; ResultInput = new ValueNodeInputViewModel <int?> { Name = "Value", Editor = new IntegerValueEditorViewModel() }; this.Inputs.Add(ResultInput); }
public MainWindow() { InitializeComponent(); //Create a new viewmodel for the NetworkView var network = new NetworkViewModel(); //Create the node for the first node, set its name and add it to the network. var node1 = new NodeViewModel(); node1.Name = "Node 1"; network.Nodes.Add(node1); //Create the viewmodel for the input on the first node, set its name and add it to the node. var node1Input = new ValueNodeInputViewModel <string>(); node1Input.Name = "Node 1 input"; node1.Inputs.Add(node1Input); //Print value on change node1Input.ValueChanged.Subscribe(newValue => { Console.WriteLine(newValue); }); //Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. var node2 = new NodeViewModel(); node2.Name = "Node 2"; network.Nodes.Add(node2); var node2Output = new ValueNodeOutputViewModel <string>(); node2Output.Name = "Node 2 output"; node2.Outputs.Add(node2Output); node2Output.Value = Observable.Return("Example string"); //Create the third test node viewmodel //Its I/O is already set in the HelloWorldNode class, so no need to declare new ones var node3 = new HelloWorldNode(); node2.Name = "Node 3"; network.Nodes.Add(node3); //Assign the viewmodel to the view. networkView.ViewModel = network; }
public ButtonsToAxisNode() { Name = "Buttons To Axis"; _inputLow = new ValueNodeInputViewModel <bool?>() { Name = "Input Low", Port = new ButtonPortViewModel() }; Inputs.Add(_inputLow); _inputHigh = new ValueNodeInputViewModel <bool?>() { Name = "Input High", Port = new ButtonPortViewModel() }; Inputs.Add(_inputHigh); this.WhenAnyValue(vm => vm._inputLow.Value, vm => vm._inputHigh.Value).Subscribe(newValues => { var lowValue = newValues.Item1 ?? false; var highValue = newValues.Item2 ?? false; if (highValue && lowValue) { _output.OnNext(0); } else if (highValue) { _output.OnNext(short.MaxValue); } else if (lowValue) { _output.OnNext(short.MinValue); } else { _output.OnNext(0); } }); Outputs.Add(new ValueNodeOutputViewModel <short?> { Name = "Output", Port = new AxisPortViewModel(), Value = _output, }); }
public static ValueNodeInputViewModel <float?> CreateFloatEditor(string name, float defaultValue = 1f) { var editor = new FloatEditorViewModel() { Value = defaultValue }; var result = new ValueNodeInputViewModel <float?>() { Name = name, Editor = editor, MaxConnections = 0 }; result.Port.IsVisible = false; return(result); }
public static ValueNodeInputViewModel <Vector2> CreateVector2Editor(string name, float defaultX = 1f, float defaultY = 1f) { var editor = new Vector2EditorViewModel() { Value = new Vector2(defaultX, defaultY) }; var result = new ValueNodeInputViewModel <Vector2>() { Name = name, Editor = editor, MaxConnections = 0 }; result.Port.IsVisible = false; return(result); }
public MainWindow() { InitializeComponent(); //Create a new viewmodel for the NetworkView var network = new NetworkViewModel(); //Create the node for the first node, set its name and add it to the network. var node1 = new NodeViewModel(); node1.Name = "Node 1"; network.Nodes.Add(node1); //Create the viewmodel for the input on the first node, set its name and add it to the node. var node1Input = new NodeInputViewModel(); node1Input.Name = "Node 1 input"; node1.Inputs.Add(node1Input); //Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. var node2 = new NodeViewModel(); node2.Name = "Node 2"; network.Nodes.Add(node2); var node2Output = new NodeOutputViewModel(); node2Output.Name = "Node 2 output"; node2.Outputs.Add(node2Output); //Create a third test node var node3 = new NodeViewModel(); node3.Name = "Test "; network.Nodes.Add(node3); var node3Input = new ValueNodeInputViewModel <string>(); node3Input.Name = "Test String"; node3.Inputs.Add(node3Input); //Assign the viewmodel to the view. networkView.ViewModel = network; }
public HelloWorldNode() { this.Name = "Hello World Node"; NameInput = new ValueNodeInputViewModel <string>() { Name = "Name" }; this.Inputs.Add(NameInput); TextOutput = new ValueNodeOutputViewModel <string>() { Name = "Text", Value = this.WhenAnyObservable(vm => vm.NameInput.ValueChanged) .Select(name => $"Hello {name}!") }; this.Outputs.Add(TextOutput); }
public HelloWorldNode() { this.Name = "Hello World Node!"; nameInput = new ValueNodeInputViewModel <string>(); { Name = "Input"; } this.Inputs.Add(nameInput); textOutput = new ValueNodeOutputViewModel <string>() { Name = "Output", Value = this.WhenAnyObservable(vm => vm.nameInput.ValueChanged) .Select(name => $"Hello {name}!") }; this.Outputs.Add(textOutput); }
public NodeViewModel CreateNode() { var input = new ValueNodeInputViewModel <int?> { Name = "A" }; var output = new ValueNodeOutputViewModel <int?> { Name = "B", Value = Observable.CombineLatest(input.ValueChanged, Observable.Return(-1), (i1, i2) => (int?)(i1 ?? i2) + 1) }; NodeViewModel node = new NodeViewModel(); node.Inputs.Add(input); node.Outputs.Add(output); output.Value.Subscribe(v => node.Name = v.ToString()); return(node); }
public VisualEditorView() : base(DataWindowMode.Custom) { InitializeComponent(); //Create a new viewmodel for the NetworkView var network = new NetworkViewModel(); //Create the node for the first node, set its name and add it to the network. var node1 = new HelloWorldNode(); node1.Name = "Node 1"; network.Nodes.Add(node1); //Create the viewmodel for the input on the first node, set its name and add it to the node. var node1Input = new ValueNodeInputViewModel <string>(); node1Input.Name = "Node 1 input"; node1.Inputs.Add(node1Input); node1Input.ValueChanged.Subscribe(newValue => { Console.WriteLine(newValue); }); //Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. var node2 = new NodeViewModel(); node2.Name = "Node 2"; network.Nodes.Add(node2); var node2Output = new ValueNodeOutputViewModel <string>(); node2Output.Name = "Node 2 output"; node2.Outputs.Add(node2Output); node2Output.Value = Observable.Return("Example string"); //Assign the viewmodel to the view. networkView.ViewModel = network; }
public ColorSpaceFilterNodeModel() { //Node Name this.Name = "Color Space Filter"; //------------------TYPE OF FILTER------------------ Inp_ColorSpace = new ValueNodeInputViewModel <object>() { Name = "Color Space" }; Inp_ColorSpace.Editor = new EnumValueEditorViewModel(typeof(ColorSpace)); Inp_ColorSpace.Port.IsVisible = false; this.Inputs.Add(Inp_ColorSpace); //------------------------------------------------------ this.WhenAnyObservable( vm => vm.Inp_Mat.Changed, vm => vm.Inp_ColorSpace.Changed).Subscribe(newValue => { ApplyFilter(); }); }
public CannyFilterNodeModel() { //Node Name this.Name = "Canny Filter"; //------------------FIRST THRESHOLD------------------ Inp_Threshold_1 = new ValueNodeInputViewModel <double?>() { Name = "Threshold" }; Inp_Threshold_1.Editor = new SliderValueEditorViewModel(1, 0, 10); Inp_Threshold_1.Port.IsVisible = false; this.Inputs.Add(Inp_Threshold_1); //------------------------------------------------------ //------------------SECOND THRESHOLD------------------ Inp_Threshold_2 = new ValueNodeInputViewModel <double?>() { Name = "Second Threshold" }; Inp_Threshold_2.Editor = new SliderValueEditorViewModel(3, 0, 10); Inp_Threshold_2.Port.IsVisible = false; this.Inputs.Add(Inp_Threshold_2); //------------------------------------------------------ this.WhenAnyObservable( vm => vm.Inp_Mat.Changed, vm => vm.Inp_Threshold_1.Changed, vm => vm.Inp_Threshold_2.Changed).Subscribe(newValue => { ApplyFilter(); }); //------------------------------------------------------ }
public AxisInverterNode() { Name = "Axis\nInverter"; var input = new ValueNodeInputViewModel <short?>() { Name = "Input", Port = new AxisPortViewModel(), }; Inputs.Add(input); input.ValueChanged.Subscribe(newValue => { _output.OnNext(InvertAxis(newValue)); }); Outputs.Add(new ValueNodeOutputViewModel <short?> { Name = "Output", Port = new AxisPortViewModel(), Value = _output }); }
public DialoguePromptNode() : base("Prompt", null) { SpeechInput = new ValueNodeInputViewModel <string>() { Name = "Line of Speech" }; ChainedPromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>() { Name = "Chained Prompts" }; Priority = new ValueNodeInputViewModel <long>() { Name = "Prompt Priority" }; ConditionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Condition" }; ActionLua = new ValueNodeInputViewModel <string>() { Name = "Lua Action" }; Title = new ValueNodeInputViewModel <string>() { Name = "Prompt Name" }; Responses = new ValueListNodeInputViewModel <DialogueResponse>() { Name = "Responses" }; FinalPrompt = new ValueNodeOutputViewModel <DialoguePrompt>() { Name = "Resulting Prompt" }; this.Inputs.Add(SpeechInput); this.Inputs.Add(ChainedPromptsInput); this.Inputs.Add(Priority); this.Inputs.Add(ConditionLua); this.Inputs.Add(ActionLua); this.Inputs.Add(Title); this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.ChainedPromptsInput.Changed, vm => vm.Priority.Changed, vm => vm.Responses.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip => { InputDocument = new DialoguePrompt() { Speech = SpeechInput.Value, Title = Title.Value, ChainedPrompts = new ObservableCollection <DialoguePrompt>(ChainedPromptsInput.Values.Items.ToList()), Priority = (int)Priority.Value, Responses = new ObservableCollection <DialogueResponse>(Responses.Values.Items.ToList()), ActionLua = ActionLua.Value, ConditionLua = ConditionLua.Value, }; FinalPrompt.Value = Observable.Return(InputDocument as DialoguePrompt); RodskaApp app = (RodskaApp)RodskaApp.Current; MainWindow window = (MainWindow)app.MainWindow; window.SignalDocumentChanged(FinalPrompt.Value.Wait()); }); this.Inputs.Add(Responses); this.Outputs.Add(FinalPrompt); }
public SobelFilterNodeModel() { //Node Name this.Name = "Sobel Filter"; //------------------X ORDER------------------ Inp_XOrder = new ValueNodeInputViewModel <double?>() { Name = "X Order" }; Inp_XOrder.Editor = new SliderValueEditorViewModel(1, 0, 1); Inp_XOrder.Port.IsVisible = false; this.Inputs.Add(Inp_XOrder); //------------------------------------------------------ //------------------Y ORDER------------------ Inp_YOrder = new ValueNodeInputViewModel <double?>() { Name = "Y Order" }; Inp_YOrder.Editor = new SliderValueEditorViewModel(0, 0, 1); Inp_YOrder.Port.IsVisible = false; this.Inputs.Add(Inp_YOrder); //------------------------------------------------------ //------------------KERNEL SIZE------------------ Inp_Kernel = new ValueNodeInputViewModel <double?>() { Name = "Kernel Size" }; Inp_Kernel.Editor = new SliderValueEditorViewModel(3, 3, 15); Inp_Kernel.Port.IsVisible = false; this.Inputs.Add(Inp_Kernel); //------------------------------------------------------ //------------------SCALE------------------ Inp_Scale = new ValueNodeInputViewModel <double?>() { Name = "Scale" }; Inp_Scale.Editor = new SliderValueEditorViewModel(1, 1, 8); Inp_Scale.Port.IsVisible = false; this.Inputs.Add(Inp_Scale); //------------------------------------------------------ //------------------DELTA------------------ Inp_Delta = new ValueNodeInputViewModel <double?>() { Name = "Delta" }; Inp_Delta.Editor = new SliderValueEditorViewModel(0, 0, 5); Inp_Delta.Port.IsVisible = false; this.Inputs.Add(Inp_Delta); //------------------------------------------------------ //------------------DEPTH TYPE------------------ Inp_DepthType = new ValueNodeInputViewModel <object>() { Name = "Depth Type" }; Inp_DepthType.Editor = new EnumValueEditorViewModel(typeof(Emgu.CV.CvEnum.DepthType)); Inp_DepthType.Port.IsVisible = false; this.Inputs.Add(Inp_DepthType); //------------------------------------------------------ //------------------BORDER TYPE------------------ Inp_BorderType = new ValueNodeInputViewModel <object>() { Name = "Border Type" }; Inp_BorderType.Editor = new EnumValueEditorViewModel(typeof(Emgu.CV.CvEnum.BorderType)); Inp_BorderType.Port.IsVisible = false; this.Inputs.Add(Inp_BorderType); //------------------------------------------------------ this.WhenAnyObservable( vm => vm.Inp_Mat.Changed, vm => vm.Inp_Kernel.Changed, vm => vm.Inp_XOrder.Changed, vm => vm.Inp_YOrder.Changed, vm => vm.Inp_Scale.Changed, vm => vm.Inp_Delta.Changed, vm => vm.Inp_DepthType.Changed, vm => vm.Inp_BorderType.Changed).Subscribe(newValue => { ApplyFilter(); }); //------------------------------------------------------ }
protected virtual void BindOutputToInput <T>(ValueNodeOutputViewModel <T> output, ValueNodeInputViewModel <T> input) { BindEndpointProperties(output, input); output.Value = input.ValueChanged; _outputInputMapping.Add(output, input); }