1 | unit fLabTests;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
7 | ORCtrls, StdCtrls, ExtCtrls;
|
---|
8 |
|
---|
9 | type
|
---|
10 | TfrmLabTests = class(TForm)
|
---|
11 | pnlLabTests: TORAutoPanel;
|
---|
12 | cmdOK: TButton;
|
---|
13 | cmdCancel: TButton;
|
---|
14 | lstList: TORListBox;
|
---|
15 | cboTests: TORComboBox;
|
---|
16 | cmdRemove: TButton;
|
---|
17 | cmdClear: TButton;
|
---|
18 | lblTests: TLabel;
|
---|
19 | lblList: TLabel;
|
---|
20 | cmdAdd: TButton;
|
---|
21 | procedure FormCreate(Sender: TObject);
|
---|
22 | procedure cboTestsNeedData(Sender: TObject; const StartFrom: string;
|
---|
23 | Direction, InsertAt: Integer);
|
---|
24 | procedure cmdOKClick(Sender: TObject);
|
---|
25 | procedure cmdClearClick(Sender: TObject);
|
---|
26 | procedure cmdRemoveClick(Sender: TObject);
|
---|
27 | procedure lstListClick(Sender: TObject);
|
---|
28 | procedure cboTestsChange(Sender: TObject);
|
---|
29 | procedure cboTestsEnter(Sender: TObject);
|
---|
30 | procedure cboTestsExit(Sender: TObject);
|
---|
31 | procedure cmdAddClick(Sender: TObject);
|
---|
32 | private
|
---|
33 | { Private declarations }
|
---|
34 | public
|
---|
35 | { Public declarations }
|
---|
36 | end;
|
---|
37 |
|
---|
38 | procedure SelectTests(FontSize: Integer);
|
---|
39 |
|
---|
40 | implementation
|
---|
41 |
|
---|
42 | uses fLabs, ORFn, rLabs;
|
---|
43 |
|
---|
44 | {$R *.DFM}
|
---|
45 |
|
---|
46 | procedure SelectTests(FontSize: Integer);
|
---|
47 | var
|
---|
48 | frmLabTests: TfrmLabTests;
|
---|
49 | W, H: integer;
|
---|
50 | begin
|
---|
51 | frmLabTests := TfrmLabTests.Create(Application);
|
---|
52 | try
|
---|
53 | with frmLabTests do
|
---|
54 | begin
|
---|
55 | Font.Size := FontSize;
|
---|
56 | W := ClientWidth;
|
---|
57 | H := ClientHeight;
|
---|
58 | ResizeToFont(FontSize, W, H);
|
---|
59 | ClientWidth := W; pnlLabTests.Width := W;
|
---|
60 | ClientHeight := H; pnlLabTests.Height := H;
|
---|
61 | lstList.Items.Assign(frmLabs.lstTests.Items);
|
---|
62 | if lstList.Items.Count > 0 then lstList.ItemIndex := 0;
|
---|
63 | lstListClick(frmLabTests);
|
---|
64 | ShowModal;
|
---|
65 | end;
|
---|
66 | finally
|
---|
67 | frmLabTests.Release;
|
---|
68 | end;
|
---|
69 | end;
|
---|
70 |
|
---|
71 | procedure TfrmLabTests.FormCreate(Sender: TObject);
|
---|
72 | begin
|
---|
73 | RedrawSuspend(cboTests.Handle);
|
---|
74 | cboTests.InitLongList('');
|
---|
75 | RedrawActivate(cboTests.Handle);
|
---|
76 | end;
|
---|
77 |
|
---|
78 | procedure TfrmLabTests.cboTestsNeedData(Sender: TObject;
|
---|
79 | const StartFrom: string; Direction, InsertAt: Integer);
|
---|
80 | begin
|
---|
81 | cboTests.ForDataUse(AllTests(StartFrom, Direction));
|
---|
82 | end;
|
---|
83 |
|
---|
84 | procedure TfrmLabTests.cmdOKClick(Sender: TObject);
|
---|
85 | begin
|
---|
86 | if lstList.Items.Count = 0 then
|
---|
87 | ShowMessage('No tests were selected.')
|
---|
88 | else
|
---|
89 | begin
|
---|
90 | frmLabs.lstTests.Items.Assign(lstList.Items);
|
---|
91 | Close;
|
---|
92 | end;
|
---|
93 | end;
|
---|
94 |
|
---|
95 | procedure TfrmLabTests.cmdClearClick(Sender: TObject);
|
---|
96 | begin
|
---|
97 | lstList.Clear;
|
---|
98 | lstListClick(self);
|
---|
99 | end;
|
---|
100 |
|
---|
101 | procedure TfrmLabTests.cmdRemoveClick(Sender: TObject);
|
---|
102 | var
|
---|
103 | newindex: integer;
|
---|
104 | begin
|
---|
105 | if lstList.Items.Count > 0 then
|
---|
106 | begin
|
---|
107 | if lstList.ItemIndex = (lstList.Items.Count -1 ) then
|
---|
108 | newindex := lstList.ItemIndex - 1
|
---|
109 | else
|
---|
110 | newindex := lstList.ItemIndex;
|
---|
111 | lstList.Items.Delete(lstList.ItemIndex);
|
---|
112 | if lstList.Items.Count > 0 then lstList.ItemIndex := newindex;
|
---|
113 | end;
|
---|
114 | lstListClick(self);
|
---|
115 | end;
|
---|
116 |
|
---|
117 | procedure TfrmLabTests.lstListClick(Sender: TObject);
|
---|
118 | begin
|
---|
119 | if lstList.Items.Count = 0 then
|
---|
120 | begin
|
---|
121 | cmdClear.Enabled := false;
|
---|
122 | cmdRemove.Enabled := false;
|
---|
123 | end
|
---|
124 | else
|
---|
125 | begin
|
---|
126 | cmdClear.Enabled := true;
|
---|
127 | cmdRemove.Enabled := true;
|
---|
128 | end;
|
---|
129 | end;
|
---|
130 |
|
---|
131 | procedure TfrmLabTests.cboTestsChange(Sender: TObject);
|
---|
132 | begin
|
---|
133 | cmdAdd.Enabled := cboTests.ItemIndex > -1;
|
---|
134 | end;
|
---|
135 |
|
---|
136 | procedure TfrmLabTests.cboTestsEnter(Sender: TObject);
|
---|
137 | begin
|
---|
138 | cmdAdd.Default := true;
|
---|
139 | end;
|
---|
140 |
|
---|
141 | procedure TfrmLabTests.cboTestsExit(Sender: TObject);
|
---|
142 | begin
|
---|
143 | cmdAdd.Default := false;
|
---|
144 | end;
|
---|
145 |
|
---|
146 | procedure TfrmLabTests.cmdAddClick(Sender: TObject);
|
---|
147 | var
|
---|
148 | i, textindex: integer;
|
---|
149 | begin
|
---|
150 | textindex := lstList.Items.Count;
|
---|
151 | for i := 0 to lstList.Items.Count -1 do
|
---|
152 | if lstList.Items[i] = cboTests.Items[cboTests.ItemIndex] then textindex := i;
|
---|
153 | if textindex = lstList.Items.Count then lstList.Items.Add(cboTests.Items[cboTests.ItemIndex]);
|
---|
154 | lstList.ItemIndex := textindex;
|
---|
155 | lstListClick(self);
|
---|
156 | end;
|
---|
157 |
|
---|
158 | end.
|
---|