-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathResultNode.cs
More file actions
42 lines (32 loc) · 1.07 KB
/
ResultNode.cs
File metadata and controls
42 lines (32 loc) · 1.07 KB
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
using Gtk;
using Gtk.NodeGraph;
using Node = Gtk.NodeGraph.Node;
namespace Calculator.Nodes
{
public class ResultNode : Node
{
private NodeSocket _nodeSocket;
private Label _value;
public ResultNode()
{
Label = "Result";
_value = new Label("0") { Xalign = -1.0f };
_nodeSocket = ItemAdd(_value, NodeSocketIO.Sink, 1);
}
private void OnSourceSocketDataOutgoingEvent(object sender, SocketDataEventArgs e)
{
_value.Text = e.Data.ToString();
}
protected override void OnNodeSocketConnect(NodeSocket sink, NodeSocket source)
{
base.OnNodeSocketConnect(sink, source);
source.SocketDataOutgoingEvent += OnSourceSocketDataOutgoingEvent;
}
protected override void OnNodeSocketDisconnect(NodeSocket sink, NodeSocket source)
{
base.OnNodeSocketDisconnect(sink, source);
_value.Text = "0";
source.SocketDataOutgoingEvent -= OnSourceSocketDataOutgoingEvent;
}
}
}