-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathOWAfterPinSelectFormUnit.pas
More file actions
134 lines (109 loc) · 4.68 KB
/
OWAfterPinSelectFormUnit.pas
File metadata and controls
134 lines (109 loc) · 4.68 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
////////////////////////////////////////////////////////////////////////////////
// //
// This software is supplied under the terms of a license agreement or //
// nondisclosure agreement with Mitov Software and may not be copied //
// or disclosed except in accordance with the terms of that agreement. //
// Copyright(c) 2002-2025 Mitov Software. All Rights Reserved. //
// //
////////////////////////////////////////////////////////////////////////////////
unit OWAfterPinSelectFormUnit;
{$IFDEF FPC}
{$MODE DELPHI}{$H+}
{$ENDIF}
interface
uses
{$IFDEF FPC}
LCLIntf, LMessages, LResources,
{$ELSE}
WinApi.Windows, WinApi.Messages,
{$ENDIF}
System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms,
Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons, OWPins,
Mitov.BasicOKCancelFormUnit;
type
TOWAfterPinSelectForm = class( TMitov_BasicOKCancelForm )
ListBox: TListBox;
procedure ListBoxDblClick( Sender : TObject );
private
{ Private declarations }
public
procedure FillFromDisparcher( AExcludePin : TOWBasicPin; ADispatcher : TOWBasicStateDispatcher; ANotifyAfterPin : TOWBasicPin );
procedure FillFromSourcePin( AExcludePin : TOWBasicPin; ASourcePin : TOWSourcePin; ANotifyAfterPin : TOWBasicPin );
function GetSelectedName() : String;
function GetSelectedPin() : TOWPin;
end;
implementation
{$IFNDEF FPC}
{$R *.DFM}
{$ENDIF}
//---------------------------------------------------------------------------
procedure TOWAfterPinSelectForm.FillFromDisparcher( AExcludePin : TOWBasicPin; ADispatcher : TOWBasicStateDispatcher; ANotifyAfterPin : TOWBasicPin );
var
ANotifyAfterName : String;
begin
ListBox.Items.Add( '(none)' );
var AExecutePinRootName := AExcludePin.GetRootName();
for var I : Integer := 0 to ADispatcher.PinCount - 1 do
begin
var APin := ADispatcher.Pins[ I ];
// if( AExcludePin <> APin ) then
if( ADispatcher.CanConnectAfter( AExcludePin, APin )) then
ListBox.Items.AddObject( APin.GetFullName( AExecutePinRootName <> APin.GetRootName() ), APin );
end;
if( ANotifyAfterPin <> NIL ) then
ANotifyAfterName := ANotifyAfterPin.GetFullName( AExcludePin.GetRoot() <> ANotifyAfterPin.GetRoot() );
if( ANotifyAfterName <> '' ) then
ListBox.ItemIndex := ListBox.Items.IndexOf( ANotifyAfterName );
if( ListBox.ItemIndex < 0 ) then
ListBox.ItemIndex := 0;
end;
//---------------------------------------------------------------------------
procedure TOWAfterPinSelectForm.FillFromSourcePin( AExcludePin : TOWBasicPin; ASourcePin : TOWSourcePin; ANotifyAfterPin : TOWBasicPin );
var
ANotifyAfterName : String;
begin
ListBox.Items.Add( '(none)' );
var APinRoot := AExcludePin.GetRoot();
for var I : Integer := 0 to ASourcePin.SinkCount - 1 do
begin
var APin := ASourcePin.Sinks[ I ];
// if( AExcludePin <> APin ) then
if( ASourcePin.CanConnectAfter( AExcludePin, APin )) then
ListBox.Items.AddObject( APin.GetFullName( APinRoot <> APin.GetRoot() ), APin );
end;
if( ANotifyAfterPin <> NIL ) then
ANotifyAfterName := ANotifyAfterPin.GetFullName( APinRoot <> ANotifyAfterPin.GetRoot() );
if( ANotifyAfterName <> '' ) then
ListBox.ItemIndex := ListBox.Items.IndexOf( ANotifyAfterName );
if( ListBox.ItemIndex < 0 ) then
ListBox.ItemIndex := 0;
end;
//---------------------------------------------------------------------------
function TOWAfterPinSelectForm.GetSelectedName() : String;
begin
if( ListBox.ItemIndex > 0 ) then
Exit( ListBox.Items[ ListBox.ItemIndex ] );
Result := '';
end;
//---------------------------------------------------------------------------
function TOWAfterPinSelectForm.GetSelectedPin() : TOWPin;
begin
if( ListBox.ItemIndex > 0 ) then
Exit( TOWPin( ListBox.Items.Objects[ ListBox.ItemIndex ] ));
Result := NIL;
end;
//---------------------------------------------------------------------------
procedure TOWAfterPinSelectForm.ListBoxDblClick( Sender : TObject );
begin
if( ListBox.ItemIndex > 0 ) then
ModalResult := mrOk;
end;
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
{$IFDEF FPC}
initialization
{$i OWAfterPinSelectFormUnit.lrs}
{$ENDIF}
end.