-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNodeFormUnit.pas
More file actions
115 lines (95 loc) · 2.5 KB
/
NodeFormUnit.pas
File metadata and controls
115 lines (95 loc) · 2.5 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
unit NodeFormUnit;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
BTCPeerNodeUnit,
NodeObserverPattern,
Vcl.StdCtrls,
PeerNodeUnit,
IPeerNodeUnit, Vcl.ComCtrls, System.Actions, Vcl.ActnList,
Vcl.PlatformDefaultStyleActnCtrls, Vcl.ActnMan, Vcl.ToolWin, Vcl.ActnCtrls,
Vcl.ActnMenus;
type
TNodeForm = class(TForm, INodeObserver)
TabSheet11: TPageControl;
TabSheet1: TTabSheet;
Peers: TTabSheet;
Label1: TLabel;
Button1: TButton;
ActionMainMenuBar1: TActionMainMenuBar;
ActionManager1: TActionManager;
actGetPeers: TAction;
Action2: TAction;
ActionMainMenuBar2: TActionMainMenuBar;
Memo1: TMemo;
procedure actGetPeersExecute(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
fPeerNode: TPeerNode;
procedure SetNode(const Value: TPeerNode);
{ Private declarations }
procedure DoNotify(const msgtype: TMSGType; const aNode: INode);
public
{ Public declarations }
destructor Destroy; override;
property Node: TPeerNode write SetNode;
end;
implementation
{$R *.dfm}
{ TNodeForm }
destructor TNodeForm.Destroy;
begin
// nos unregistramos
DeattachObserverFromSubject(self, fPeerNode);
inherited;
end;
procedure TNodeForm.actGetPeersExecute(Sender: TObject);
begin
if fPeerNode is TBTCRPCNode then
begin
// Caption := TBTCRPCNode(fPeerNode).fRPC.GetNetworkInfo.version;
Memo1.Lines.Add(TBTCRPCNode(fPeerNode).fRPC.GetPeerInfo.json);
end;
end;
procedure TNodeForm.Button1Click(Sender: TObject);
begin
if fPeerNode is TBTCRPCNode then
begin
// Caption := TBTCRPCNode(fPeerNode).fRPC.GetNetworkInfo.version;
// Memo1.Lines.Add(TBTCRPCNode(fPeerNode).fRPC.GetNetworkInfo.json)
end;
end;
procedure TNodeForm.DoNotify(const msgtype: TMSGType; const aNode: INode);
begin
caption := 'connected' + aNode.GetIP;
Label1.caption := aNode.getagent;
end;
procedure TNodeForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TNodeForm.SetNode(const Value: TPeerNode);
begin
if fPeerNode <> Value then
begin
if fPeerNode <> nil then
DeattachObserverFromSubject(self, fPeerNode);
end;
fPeerNode := Value;
if Value <> nil then
begin
AttachObserverToSubject(self, Value);
caption := Value.PeerIp;
Label1.caption := Value.agent;
end;
end;
end.