-
Notifications
You must be signed in to change notification settings - Fork 9
/
HelloGui.cs
58 lines (52 loc) · 1.57 KB
/
HelloGui.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using HelloDynamo.Hello;
using ProtoCore.AST.AssociativeAST;
namespace HelloDynamo.HelloNodeModel
{
/// <summary>
/// Sample NodeModel with custom Gui
/// </summary>
[NodeName("HelloGui")]
[NodeDescription("Example Node Model, multiplies A x the value of the slider")]
[NodeCategory("HelloDynamo")]
[InPortNames("A")]
[InPortTypes("double")]
[InPortDescriptions("Number A")]
[OutPortNames("C")]
[OutPortTypes("double")]
[OutPortDescriptions("Product of AxSlider")]
[IsDesignScriptCompatible]
public class HelloGui : NodeModel
{
private double _sliderValue;
public double SliderValue
{
get { return _sliderValue; }
set
{
_sliderValue = value;
RaisePropertyChanged("SliderValue");
OnNodeModified(false);
}
}
public HelloGui()
{
RegisterAllPorts();
}
public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
{
if (!HasConnectedInput(0))
{
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };
}
var sliderValue = AstFactory.BuildDoubleNode(SliderValue);
var functionCall =
AstFactory.BuildFunctionCall(
new Func<double, double, double>(SampleFunctions.MultiplyTwoNumbers),
new List<AssociativeNode> { inputAstNodes[0], sliderValue });
return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };
}
}
}