-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnitFormListMin.pas
242 lines (219 loc) · 6.31 KB
/
UnitFormListMin.pas
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
unit UnitFormListMin;
{$MODE Delphi}
interface
uses
LCLIntf, LCLType, LMessages, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids, NuclideClassesMin, Menus, ExtCtrls, Buttons, EuLibMin;
type
{ T_FormListMin }
T_FormListMin=class(TForm)
PanelTop: TPanel;
SpeedButtonUndock: TSpeedButton;
StringGridChosenList: TStringGrid;
procedure FormShow(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ItemDelClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure SpeedButtonUndockClick(Sender: TObject);
procedure StringGridChosenListDblClick(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure StringGridChosenListKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
ActiveThZpA: integer;
ThZpA_sList: TLongIntList;
procedure InvalidateGrid(Sender: TObject);
end;
var
_FormListMin: T_FormListMin;
implementation
uses UnitNKmin, UnitEditNuclideMin;
{$R *.frm}
procedure T_FormListMin.FormShow(Sender: TObject);
begin
if ThZpA_Slist.Count=0 then begin
MessageDlg('The state list is empty !', mtWarning, [mbOK], 0);
Exit;
end;
end;
procedure T_FormListMin.InvalidateGrid(Sender: TObject);
var
I, J, ThZpA, State, InNKlistNo: integer;
WasShown: Boolean;
Col0, Col1: TStringList;
begin
Col0:= TStringList.Create;
Col1:= TStringList.Create;
try
if Visible then begin
WasShown:= True;
Hide;
end
else
WasShown:= False;
Cursor:= crHourGlass;
with StringGridChosenList, ThZpA_Slist do begin
RowCount:= 1;
Col0.Clear;
Col0.Add('State');
Col1.Clear;
Col1.Add('Half life');
//out Dupljs
for I:= ThZpA_sList.Count-1 downto 1 do
for J:= I-1 downto 0 do
if (ThZpA_sList[I]=ThZpA_sList[J]) then begin
ThZpA_sList.Delete(J);
break;
end;
ThZpA_sList.Order(False);
for I:= ThZpA_sList.Count-1 downto 0 do begin
ThZpA:= ThZpA_sList[I]div 10;
State:= ThZpA_sList[I]mod 10;
with _FormNKmin do begin
InNKlistNo:= _FormNKmin.NuclideList.FindInList(ThZpA div 1000, ThZpA mod 1000);
if (InNKlistNo>=0) then
if State<_FormNKmin.NuclideList[InNKlistNo].StateList.Count then
with _FormNKmin.NuclideList[InNKlistNo].StateList[State] do begin
RowCount:= RowCount+1;
Col0.Add(Name);
if T1_2>0 then
Col1.Add(T1_2ToStr(T1_2))
else
Col1.Add('');
end
else begin
ThZpA_Slist.Delete(I);
end
else begin
ThZpA_Slist.Delete(I);
end
end;
end;
ThZpA_sList.Order(True);
Cols[0].Assign(Col0);
Cols[1].Assign(Col1);
if RowCount>1 then
FixedRows:= 1;
end;
Caption:= 'The filter list ('+IntToStr(ThZpA_Slist.Count)+')';
for I:=0 to _FormNKmin.PageControlDockLeft.DockClientCount-1 do
if (_FormNKmin.PageControlDockLeft.DockClients[I] = Self) then
_FormNKmin.PageControlDockLeft.Pages[I].Caption := Self.Caption;
for I:=0 to _FormNKmin.PageControlDockRight.DockClientCount-1 do
if (_FormNKmin.PageControlDockRight.DockClients[I] = Self) then
_FormNKmin.PageControlDockRight.Pages[I].Caption := Self.Caption;
finally
Cursor:= crDefault;
Col0.Free;
Col1.Free;
end;
if WasShown then begin
Show;
end;
end;
procedure T_FormListMin.FormCreate(Sender: TObject);
begin
ThZpA_sList:= TLongIntList.Create;
end;
procedure T_FormListMin.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=vk_escape then
Close;
end;
procedure T_FormListMin.ItemDelClick(Sender: TObject);
var
I: integer;
begin
Hide;
with StringGridChosenList do begin
if ((Row-1)<ThZpA_Slist.Count) then begin
ThZpA_Slist.Delete(Row-1);
for I:= Row to RowCount-1 do
Rows[I].Assign(Rows[I+1]);
RowCount:= RowCount-1;
end;
end;
InvalidateGrid(Self);
if ThZpA_Slist.Count>0 then
Show;
end;
procedure T_FormListMin.FormDestroy(Sender: TObject);
begin
ThZpA_sList.Free;
end;
procedure T_FormListMin.SpeedButtonUndockClick(Sender: TObject);
var
aRect: TRect;
begin
aRect.Left := Screen.Width div 2 - Self.Width;
aRect.Top := Screen.Height div 3;
aRect.Right := aRect.Left + 85;
aRect.Bottom := aRect.Top + 425;
Self.ManualFloat(aRect);
SpeedButtonUndock.Visible:= False;
end;
procedure T_FormListMin.StringGridChosenListDblClick(Sender: TObject);
var
ThZpA, State, InNKlistNo: integer;
begin
with StringGridChosenList do begin
ThZpA:= ThZpA_sList[Row-1]div 10;
State:= ThZpA_sList[Row-1]mod 10;
InNKlistNo:= _FormNKmin.NuclideList.FindInList(ThZpA div 1000, ThZpA mod 1000);
end;
with _FormNKmin do
if ((Visible)and(InNKlistNo>=0)) then begin
if State<NuclideList[InNKlistNo].StateList.Count then begin
ActiveThZpA:= ThZpA;
GoToThZpACenter(ActiveThZpA);
StringGridNKDblClick(Self);
with _FormEditNuclideMin do
if Visible then
case State of
0: if SpeedButtonGstate.Visible then begin
SpeedButtonGstate.Down:= True;
SpeedButtonGstateClick( Self);
end;
1: if SpeedButtonM1state.Visible then begin
SpeedButtonM1state.Down:= True;
SpeedButtonM1stateClick( Self);
end;
2: if SpeedButtonM2state.Visible then begin
SpeedButtonM2state.Down:= True;
SpeedButtonM2stateClick( Self);
end;
end;
end
else
MessageDlg('The state not found in NUKLIDKARTE !', mtWarning, [mbOK], 0);
end;
end;
procedure T_FormListMin.FormResize(Sender: TObject);
begin
with StringGridChosenList do begin
ColWidths[0]:= ((ClientWidth)div 7)*3-ColCount;
ColWidths[1]:= ClientWidth-ColWidths[0]-ColCount;
end;
SpeedButtonUndock.Left:= Self.Width - Self.SpeedButtonUndock.Width;
end;
procedure T_FormListMin.StringGridChosenListKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if (StringGridChosenList.Selection.Left<StringGridChosenList.Selection.Right)or((StringGridChosenList.Selection.Bottom>StringGridChosenList.Selection.Top) ) then
begin
// Ctrl+Ins or Ctrl+C
if (not (ssAlt in Shift) and (ssCtrl in Shift) and ((Key = VK_INSERT) or (Key = Ord('C')))) then
begin
CopyToClipboardFromStringGrid(StringGridChosenList)
end;
end;
if (not (ssAlt in Shift) and (ssCtrl in Shift) and (Key = VK_RETURN)) then
StringGridChosenListDblClick(Self);
end;
end.