Rev 233 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 233 | Rev 234 | ||
---|---|---|---|
1 | unit Main; |
1 | unit Main; |
2 | 2 | ||
3 | { This source code is only compatible with Delphi 1.0 ! } |
3 | { This source code is only compatible with Delphi 1.0 ! } |
4 | 4 | ||
5 | interface |
5 | interface |
6 | 6 | ||
7 | uses |
7 | uses |
8 | SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, |
8 | SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms, |
9 | Dialogs, StdCtrls, IniFiles, Grids, Outline, ExtCtrls; |
9 | Dialogs, StdCtrls, IniFiles, Grids, Outline, ExtCtrls; |
10 | 10 | ||
11 | type |
11 | type |
12 | TForm1 = class(TForm) |
12 | TForm1 = class(TForm) |
13 | Outline1: TOutline; |
13 | Outline1: TOutline; |
14 | Notebook1: TNotebook; |
14 | Notebook1: TNotebook; |
15 | Label1: TLabel; |
- | |
16 | Label3: TLabel; |
- | |
17 | Label4: TLabel; |
- | |
18 | Label5: TLabel; |
- | |
19 | Label6: TLabel; |
- | |
20 | Label7: TLabel; |
- | |
21 | Label15: TLabel; |
- | |
22 | Edit3: TEdit; |
- | |
23 | Memo1: TMemo; |
15 | Memo1: TMemo; |
24 | Edit4: TEdit; |
- | |
25 | CheckBox1: TCheckBox; |
- | |
26 | ComboBox1: TComboBox; |
- | |
27 | Edit5: TEdit; |
- | |
28 | Edit6: TEdit; |
- | |
29 | ListBox1: TListBox; |
- | |
30 | Edit7: TEdit; |
- | |
31 | Button1: TButton; |
- | |
32 | Button3: TButton; |
- | |
33 | Button2: TButton; |
- | |
34 | Button4: TButton; |
- | |
35 | Edit1: TEdit; |
- | |
36 | Button6: TButton; |
- | |
37 | Label2: TLabel; |
16 | Label2: TLabel; |
38 | Label8: TLabel; |
17 | Label8: TLabel; |
39 | Label9: TLabel; |
18 | Label9: TLabel; |
40 | Label10: TLabel; |
19 | Label10: TLabel; |
41 | Label11: TLabel; |
20 | Label11: TLabel; |
42 | Label12: TLabel; |
21 | Label12: TLabel; |
43 | Button8: TButton; |
22 | Button8: TButton; |
44 | Edit9: TEdit; |
23 | Edit9: TEdit; |
45 | Edit10: TEdit; |
24 | Edit10: TEdit; |
46 | Edit11: TEdit; |
25 | Edit11: TEdit; |
47 | Edit12: TEdit; |
26 | Edit12: TEdit; |
48 | Edit13: TEdit; |
27 | Edit13: TEdit; |
49 | Button9: TButton; |
28 | Button9: TButton; |
50 | Edit14: TEdit; |
29 | Edit14: TEdit; |
51 | Label13: TLabel; |
30 | Label13: TLabel; |
52 | Button5: TButton; |
31 | Button5: TButton; |
53 | Edit2: TEdit; |
32 | Edit2: TEdit; |
54 | Label14: TLabel; |
33 | Label14: TLabel; |
55 | Edit8: TEdit; |
34 | Edit8: TEdit; |
56 | Button7: TButton; |
35 | Button7: TButton; |
- | 36 | Panel1: TPanel; |
|
- | 37 | Label1: TLabel; |
|
- | 38 | Label3: TLabel; |
|
- | 39 | Label4: TLabel; |
|
- | 40 | Label5: TLabel; |
|
- | 41 | Label6: TLabel; |
|
- | 42 | Label7: TLabel; |
|
- | 43 | Edit3: TEdit; |
|
- | 44 | Edit4: TEdit; |
|
- | 45 | CheckBox1: TCheckBox; |
|
- | 46 | ComboBox1: TComboBox; |
|
- | 47 | Edit5: TEdit; |
|
- | 48 | Edit6: TEdit; |
|
- | 49 | ListBox1: TListBox; |
|
- | 50 | Edit7: TEdit; |
|
- | 51 | Button1: TButton; |
|
- | 52 | Button3: TButton; |
|
- | 53 | Panel2: TPanel; |
|
- | 54 | Button2: TButton; |
|
- | 55 | Button4: TButton; |
|
- | 56 | Edit1: TEdit; |
|
- | 57 | Button6: TButton; |
|
- | 58 | Label15: TLabel; |
|
57 | procedure Outline1Change(Sender: TObject; Node: integer); |
59 | procedure Outline1Change(Sender: TObject; Node: integer); |
58 | procedure Button1Click(Sender: TObject); |
60 | procedure Button1Click(Sender: TObject); |
59 | procedure Button3Click(Sender: TObject); |
61 | procedure Button3Click(Sender: TObject); |
60 | procedure Button4Click(Sender: TObject); |
62 | procedure Button4Click(Sender: TObject); |
61 | procedure Button7Click(Sender: TObject); |
63 | procedure Button7Click(Sender: TObject); |
62 | procedure Button6Click(Sender: TObject); |
64 | procedure Button6Click(Sender: TObject); |
63 | procedure Button8Click(Sender: TObject); |
65 | procedure Button8Click(Sender: TObject); |
64 | procedure Button2Click(Sender: TObject); |
66 | procedure Button2Click(Sender: TObject); |
65 | procedure FormCreate(Sender: TObject); |
67 | procedure FormCreate(Sender: TObject); |
66 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
68 | procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
67 | procedure CheckBox1Click(Sender: TObject); |
69 | procedure CheckBox1Click(Sender: TObject); |
68 | procedure Button9Click(Sender: TObject); |
70 | procedure Button9Click(Sender: TObject); |
69 | procedure Edit8KeyPress(Sender: TObject; var Key: Char); |
71 | procedure Edit8KeyPress(Sender: TObject; var Key: Char); |
70 | procedure Edit11Change(Sender: TObject); |
72 | procedure Edit11Change(Sender: TObject); |
71 | procedure ListBox1KeyDown(Sender: TObject; var Key: Word; |
73 | procedure ListBox1KeyDown(Sender: TObject; var Key: Word; |
72 | Shift: TShiftState); |
74 | Shift: TShiftState); |
73 | procedure Edit7KeyPress(Sender: TObject; var Key: Char); |
75 | procedure Edit7KeyPress(Sender: TObject; var Key: Char); |
74 | procedure Edit2KeyPress(Sender: TObject; var Key: Char); |
76 | procedure Edit2KeyPress(Sender: TObject; var Key: Char); |
75 | procedure Edit1KeyPress(Sender: TObject; var Key: Char); |
77 | procedure Edit1KeyPress(Sender: TObject; var Key: Char); |
76 | procedure Outline1KeyDown(Sender: TObject; var Key: Word; |
78 | procedure Outline1KeyDown(Sender: TObject; var Key: Word; |
77 | Shift: TShiftState); |
79 | Shift: TShiftState); |
78 | procedure Outline1Click(Sender: TObject); |
80 | procedure Outline1Click(Sender: TObject); |
79 | procedure FormShow(Sender: TObject); |
81 | procedure FormShow(Sender: TObject); |
80 | private |
82 | private |
81 | procedure ShowOID(oid: string; ini: TIniFile; nod: integer); |
83 | procedure ShowOID(oid: string; ini: TIniFile; nod: integer); |
82 | procedure ShowRA(ini: TIniFile; nod: integer); |
84 | procedure ShowRA(ini: TIniFile; nod: integer); |
83 | function DBPath: string; |
85 | function DBPath: string; |
84 | function GetAsn1Ids(onlyfirst: boolean): string; |
86 | function GetAsn1Ids(onlyfirst: boolean): string; |
85 | procedure SaveChangesIfRequired; |
87 | procedure SaveChangesIfRequired; |
86 | procedure ShowError(msg: string); |
88 | procedure ShowError(msg: string); |
87 | end; |
89 | end; |
88 | 90 | ||
89 | var |
91 | var |
90 | Form1: TForm1; |
92 | Form1: TForm1; |
91 | 93 | ||
92 | implementation |
94 | implementation |
93 | 95 | ||
94 | {$R *.DFM} |
96 | {$R *.DFM} |
95 | 97 | ||
96 | uses |
98 | uses |
97 | SortStr; |
99 | SortStr; |
98 | 100 | ||
99 | const |
101 | const |
100 | TITLE_OID = 'Object Identifiers'; |
102 | TITLE_OID = 'Object Identifiers'; |
101 | TITLE_RA = 'Registration Authorities'; |
103 | TITLE_RA = 'Registration Authorities'; |
102 | 104 | ||
103 | procedure Split(Delimiter: string; Str: string; ListOfStrings: TStrings) ; |
105 | procedure Split(Delimiter: string; Str: string; ListOfStrings: TStrings) ; |
104 | var |
106 | var |
105 | p: integer; |
107 | p: integer; |
106 | begin |
108 | begin |
107 | ListOfStrings.Clear; |
109 | ListOfStrings.Clear; |
108 | p := Pos(Delimiter, Str); |
110 | p := Pos(Delimiter, Str); |
109 | while p > 0 do |
111 | while p > 0 do |
110 | begin |
112 | begin |
111 | ListOfStrings.Add(Copy(Str, 1, p-1)); |
113 | ListOfStrings.Add(Copy(Str, 1, p-1)); |
112 | Delete(Str, 1, p); |
114 | Delete(Str, 1, p); |
113 | p := Pos(Delimiter, Str); |
115 | p := Pos(Delimiter, Str); |
114 | end; |
116 | end; |
115 | if Str <> '' then ListOfStrings.Add(Str); |
117 | if Str <> '' then ListOfStrings.Add(Str); |
116 | end; |
118 | end; |
117 | 119 | ||
118 | procedure ExpandNodeAndParents(nod: TOutlineNode); |
120 | procedure ExpandNodeAndParents(nod: TOutlineNode); |
119 | begin |
121 | begin |
120 | if nod.Parent <> nil then ExpandNodeAndParents(nod.Parent); |
122 | if nod.Parent <> nil then ExpandNodeAndParents(nod.Parent); |
121 | nod.Expand; |
123 | nod.Expand; |
122 | end; |
124 | end; |
123 | 125 | ||
124 | { Source: Delphi 4 } |
126 | { Source: Delphi 4 } |
125 | function Trim(const S: string): string; |
127 | function Trim(const S: string): string; |
126 | var |
128 | var |
127 | I, L: Integer; |
129 | I, L: Integer; |
128 | begin |
130 | begin |
129 | L := Length(S); |
131 | L := Length(S); |
130 | I := 1; |
132 | I := 1; |
131 | while (I <= L) and (S[I] <= ' ') do Inc(I); |
133 | while (I <= L) and (S[I] <= ' ') do Inc(I); |
132 | if I > L then Result := '' else |
134 | if I > L then Result := '' else |
133 | begin |
135 | begin |
134 | while S[L] <= ' ' do Dec(L); |
136 | while S[L] <= ' ' do Dec(L); |
135 | Result := Copy(S, I, L - I + 1); |
137 | Result := Copy(S, I, L - I + 1); |
136 | end; |
138 | end; |
137 | end; |
139 | end; |
138 | 140 | ||
139 | type |
141 | type |
140 | TWorkItem = class(TObject) |
142 | TWorkItem = class(TObject) |
141 | public |
143 | public |
142 | sectionName: string; |
144 | sectionName: string; |
143 | ini: TIniFile; |
145 | ini: TIniFile; |
144 | nod: integer; |
146 | nod: integer; |
145 | end; |
147 | end; |
146 | 148 | ||
147 | procedure TForm1.ShowOID(oid: string; ini: TIniFile; nod: integer); |
149 | procedure TForm1.ShowOID(oid: string; ini: TIniFile; nod: integer); |
148 | var |
150 | var |
149 | i: integer; |
151 | i: integer; |
150 | sectionName: string; |
152 | sectionName: string; |
151 | asn1ids: string; |
153 | asn1ids: string; |
152 | l: TList; |
154 | l: TList; |
153 | sl: TStringList; |
155 | sl: TStringList; |
154 | workItem: TWorkItem; |
156 | workItem: TWorkItem; |
155 | label |
157 | label |
156 | continuework, |
158 | continuework, |
157 | ende; |
159 | ende; |
158 | begin |
160 | begin |
159 | l := TList.Create; |
161 | l := TList.Create; |
160 | sl := TStringList.Create; |
162 | sl := TStringList.Create; |
161 | 163 | ||
162 | workItem := TWorkItem.Create; |
164 | workItem := TWorkItem.Create; |
163 | workItem.sectionName := oid; |
165 | workItem.sectionName := oid; |
164 | workItem.ini := ini; |
166 | workItem.ini := ini; |
165 | workItem.nod := nod; |
167 | workItem.nod := nod; |
166 | l.Add(workItem); |
168 | l.Add(workItem); |
167 | 169 | ||
168 | continuework: |
170 | continuework: |
169 | 171 | ||
170 | if l.Count = 0 then goto ende; |
172 | if l.Count = 0 then goto ende; |
171 | workItem := l.Items[l.Count-1]; |
173 | workItem := l.Items[l.Count-1]; |
172 | oid := workItem.sectionName; |
174 | oid := workItem.sectionName; |
173 | ini := workItem.ini; |
175 | ini := workItem.ini; |
174 | nod := workItem.nod; |
176 | nod := workItem.nod; |
175 | workItem.Free; |
177 | workItem.Free; |
176 | l.Delete(l.Count-1); |
178 | l.Delete(l.Count-1); |
177 | 179 | ||
178 | if oid = 'OID:' then |
180 | if oid = 'OID:' then |
179 | begin |
181 | begin |
180 | nod := Outline1.AddChild(nod, TITLE_OID); |
182 | nod := Outline1.AddChild(nod, TITLE_OID); |
181 | end |
183 | end |
182 | else |
184 | else |
183 | begin |
185 | begin |
184 | asn1ids := ini.ReadString(oid, 'asn1id', ''); |
186 | asn1ids := ini.ReadString(oid, 'asn1id', ''); |
185 | if ini.ReadBool(oid, 'draft', false) then |
187 | if ini.ReadBool(oid, 'draft', false) then |
186 | nod := Outline1.AddChild(nod, Trim(oid+' '+Copy(asn1ids,1,Pos(',',asn1ids+',')-1))+' [DRAFT]') |
188 | nod := Outline1.AddChild(nod, Trim(oid+' '+Copy(asn1ids,1,Pos(',',asn1ids+',')-1))+' [DRAFT]') |
187 | else |
189 | else |
188 | nod := Outline1.AddChild(nod, Trim(oid+' '+Copy(asn1ids,1,Pos(',',asn1ids+',')-1))); |
190 | nod := Outline1.AddChild(nod, Trim(oid+' '+Copy(asn1ids,1,Pos(',',asn1ids+',')-1))); |
189 | end; |
191 | end; |
190 | sl.Clear; |
192 | sl.Clear; |
191 | for i := ini.ReadInteger(oid, 'delegates', 0) downto 1 do |
193 | for i := ini.ReadInteger(oid, 'delegates', 0) downto 1 do |
192 | begin |
194 | begin |
193 | sectionName := ini.ReadString(oid, 'delegate'+IntToStr(i), ''); |
195 | sectionName := ini.ReadString(oid, 'delegate'+IntToStr(i), ''); |
194 | if sectionName = '' then continue; |
196 | if sectionName = '' then continue; |
195 | sl.Add(sectionName); |
197 | sl.Add(sectionName); |
196 | end; |
198 | end; |
197 | SortSL(sl); |
199 | SortSL(sl); |
198 | for i := sl.Count-1 downto 0 do |
200 | for i := sl.Count-1 downto 0 do |
199 | begin |
201 | begin |
200 | sectionName := sl.Strings[i]; |
202 | sectionName := sl.Strings[i]; |
201 | 203 | ||
202 | workItem := TWorkItem.Create; |
204 | workItem := TWorkItem.Create; |
203 | workItem.sectionName := sectionName; |
205 | workItem.sectionName := sectionName; |
204 | workItem.ini := ini; |
206 | workItem.ini := ini; |
205 | workItem.nod := nod; |
207 | workItem.nod := nod; |
206 | l.Add(workItem); |
208 | l.Add(workItem); |
207 | end; |
209 | end; |
208 | if (oid = 'OID:') or (sl.Count < 125) then |
210 | if (oid = 'OID:') or (sl.Count < 125) then |
209 | ExpandNodeAndParents(Outline1.Items[nod]); |
211 | ExpandNodeAndParents(Outline1.Items[nod]); |
210 | 212 | ||
211 | goto continuework; |
213 | goto continuework; |
212 | 214 | ||
213 | ende: |
215 | ende: |
214 | 216 | ||
215 | sl.Free; |
217 | sl.Free; |
216 | l.Free; |
218 | l.Free; |
217 | end; |
219 | end; |
218 | 220 | ||
219 | procedure TForm1.ShowRA(ini: TIniFile; nod: integer); |
221 | procedure TForm1.ShowRA(ini: TIniFile; nod: integer); |
220 | var |
222 | var |
221 | i: integer; |
223 | i: integer; |
222 | sectionName, personname: string; |
224 | sectionName, personname: string; |
223 | sl: TStringList; |
225 | sl: TStringList; |
224 | begin |
226 | begin |
225 | nod := Outline1.AddChild(nod, TITLE_RA); |
227 | nod := Outline1.AddChild(nod, TITLE_RA); |
226 | sl := TStringList.Create; |
228 | sl := TStringList.Create; |
227 | for i := 1 to ini.ReadInteger('RA:', 'count', 0) do |
229 | for i := 1 to ini.ReadInteger('RA:', 'count', 0) do |
228 | begin |
230 | begin |
229 | sectionName := ini.ReadString('RA:', 'ra'+IntToStr(i), ''); |
231 | sectionName := ini.ReadString('RA:', 'ra'+IntToStr(i), ''); |
230 | if sectionName = '' then continue; |
232 | if sectionName = '' then continue; |
231 | personname := ini.ReadString(sectionName, 'name', ''); |
233 | personname := ini.ReadString(sectionName, 'name', ''); |
232 | sl.Add(Trim(sectionName + ' ' + personname)); |
234 | sl.Add(Trim(sectionName + ' ' + personname)); |
233 | end; |
235 | end; |
234 | SortSL(sl); |
236 | SortSL(sl); |
235 | for i := 0 to sl.Count-1 do |
237 | for i := 0 to sl.Count-1 do |
236 | begin |
238 | begin |
237 | sectionName := sl.Strings[i]; |
239 | sectionName := sl.Strings[i]; |
238 | Outline1.AddChild(nod, sectionName); |
240 | Outline1.AddChild(nod, sectionName); |
239 | ComboBox1.Items.Add(Copy(sectionName,1,Pos(' ',sectionName+' ')-1)); |
241 | ComboBox1.Items.Add(Copy(sectionName,1,Pos(' ',sectionName+' ')-1)); |
240 | end; |
242 | end; |
241 | sl.Free; |
243 | sl.Free; |
242 | ExpandNodeAndParents(Outline1.Items[nod]); |
244 | ExpandNodeAndParents(Outline1.Items[nod]); |
243 | end; |
245 | end; |
244 | 246 | ||
245 | procedure TForm1.Outline1Change(Sender: TObject; Node: integer); |
247 | procedure TForm1.Outline1Change(Sender: TObject; Node: integer); |
246 | var |
248 | var |
247 | ini: TIniFile; |
249 | ini: TIniFile; |
248 | txtFile: string; |
250 | txtFile: string; |
249 | begin |
251 | begin |
250 | SaveChangesIfRequired; |
252 | SaveChangesIfRequired; |
251 | 253 | ||
252 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 4) = 'OID:' then |
254 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 4) = 'OID:' then |
253 | begin |
255 | begin |
254 | Notebook1.PageIndex := 0; |
256 | Notebook1.PageIndex := 0; |
255 | ini := TIniFile.Create(DBPath+'OID.INI'); |
257 | ini := TIniFile.Create(DBPath+'OID.INI'); |
256 | try |
258 | try |
257 | Edit4.Text := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, |
259 | Edit4.Text := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, |
258 | Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
260 | Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
259 | ListBox1.Items.Clear; |
261 | ListBox1.Items.Clear; |
260 | Split(',', ini.ReadString(Edit4.Text, 'asn1id', ''), ListBox1.Items); |
262 | Split(',', ini.ReadString(Edit4.Text, 'asn1id', ''), ListBox1.Items); |
261 | Edit3.Text := ini.ReadString(Edit4.Text, 'description', ''); |
263 | Edit3.Text := ini.ReadString(Edit4.Text, 'description', ''); |
262 | CheckBox1.Checked := ini.ReadBool(Edit4.Text, 'draft', false); |
264 | CheckBox1.Checked := ini.ReadBool(Edit4.Text, 'draft', false); |
263 | txtFile := DBPath+ini.ReadString(Edit4.Text, 'information', ''); |
265 | txtFile := DBPath+ini.ReadString(Edit4.Text, 'information', ''); |
264 | if FileExists(txtFile) then |
266 | if FileExists(txtFile) then |
265 | Memo1.Lines.LoadFromFile(txtFile) |
267 | Memo1.Lines.LoadFromFile(txtFile) |
266 | else |
268 | else |
267 | Memo1.Lines.Clear; |
269 | Memo1.Lines.Clear; |
268 | Memo1.Modified := false; |
270 | Memo1.Modified := false; |
269 | ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(ini.ReadString(Edit4.Text, 'ra', '')); |
271 | ComboBox1.ItemIndex := ComboBox1.Items.IndexOf(ini.ReadString(Edit4.Text, 'ra', '')); |
270 | Edit5.Text := ini.ReadString(Edit4.Text, 'createdate', ''); |
272 | Edit5.Text := ini.ReadString(Edit4.Text, 'createdate', ''); |
271 | Edit6.Text := ini.ReadString(Edit4.Text, 'updatedate', ''); |
273 | Edit6.Text := ini.ReadString(Edit4.Text, 'updatedate', ''); |
272 | Edit7.Text := ''; |
274 | Edit7.Text := ''; |
273 | finally |
275 | finally |
274 | ini.Free; |
276 | ini.Free; |
275 | end; |
277 | end; |
276 | Edit1.Text := ''; |
278 | Edit1.Text := ''; |
277 | end; |
279 | end; |
278 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 3) = 'RA:' then |
280 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 3) = 'RA:' then |
279 | begin |
281 | begin |
280 | Notebook1.PageIndex := 1; |
282 | Notebook1.PageIndex := 1; |
281 | ini := TIniFile.Create(DBPath+'RA.INI'); |
283 | ini := TIniFile.Create(DBPath+'RA.INI'); |
282 | try |
284 | try |
283 | Edit9.Text := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, |
285 | Edit9.Text := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, |
284 | Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
286 | Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
285 | Edit10.Text := ini.ReadString(Edit9.Text, 'createdate', ''); |
287 | Edit10.Text := ini.ReadString(Edit9.Text, 'createdate', ''); |
286 | Edit11.Text := ini.ReadString(Edit9.Text, 'name', ''); |
288 | Edit11.Text := ini.ReadString(Edit9.Text, 'name', ''); |
287 | Edit12.Text := ini.ReadString(Edit9.Text, 'email', ''); |
289 | Edit12.Text := ini.ReadString(Edit9.Text, 'email', ''); |
288 | Edit13.Text := ini.ReadString(Edit9.Text, 'phone', ''); |
290 | Edit13.Text := ini.ReadString(Edit9.Text, 'phone', ''); |
289 | Edit14.Text := ini.ReadString(Edit9.Text, 'updatedate', ''); |
291 | Edit14.Text := ini.ReadString(Edit9.Text, 'updatedate', ''); |
290 | finally |
292 | finally |
291 | ini.Free; |
293 | ini.Free; |
292 | end; |
294 | end; |
293 | end; |
295 | end; |
294 | if Outline1.Items[Outline1.SelectedItem].Text = TITLE_OID then |
296 | if Outline1.Items[Outline1.SelectedItem].Text = TITLE_OID then |
295 | begin |
297 | begin |
296 | Notebook1.PageIndex := 2; |
298 | Notebook1.PageIndex := 2; |
297 | Edit2.Text := ''; |
299 | Edit2.Text := ''; |
298 | end; |
300 | end; |
299 | if Outline1.Items[Outline1.SelectedItem].Text = TITLE_RA then |
301 | if Outline1.Items[Outline1.SelectedItem].Text = TITLE_RA then |
300 | begin |
302 | begin |
301 | Notebook1.PageIndex := 3; |
303 | Notebook1.PageIndex := 3; |
302 | Edit8.Text := ''; |
304 | Edit8.Text := ''; |
303 | end; |
305 | end; |
304 | end; |
306 | end; |
305 | 307 | ||
306 | procedure TForm1.FormShow(Sender: TObject); |
308 | procedure TForm1.FormShow(Sender: TObject); |
307 | var |
309 | var |
308 | nod, raroot: integer; |
310 | nod, raroot: integer; |
309 | ini: TIniFile; |
311 | ini: TIniFile; |
310 | begin |
312 | begin |
311 | ComboBox1.Clear; |
313 | ComboBox1.Clear; |
312 | Outline1.Clear; |
314 | Outline1.Clear; |
313 | nod := 0; |
315 | nod := 0; |
314 | 316 | ||
315 | ini := TIniFile.Create(DBPath+'OID.INI'); |
317 | ini := TIniFile.Create(DBPath+'OID.INI'); |
316 | try |
318 | try |
317 | ShowOID('OID:', ini, nod); |
319 | ShowOID('OID:', ini, nod); |
318 | finally |
320 | finally |
319 | ini.Free; |
321 | ini.Free; |
320 | end; |
322 | end; |
321 | 323 | ||
322 | ini := TIniFile.Create(DBPath+'RA.INI'); |
324 | ini := TIniFile.Create(DBPath+'RA.INI'); |
323 | try |
325 | try |
324 | ShowRa(ini, nod); |
326 | ShowRa(ini, nod); |
325 | finally |
327 | finally |
326 | ini.Free; |
328 | ini.Free; |
327 | end; |
329 | end; |
328 | 330 | ||
329 | Outline1Click(Outline1); |
331 | Outline1Click(Outline1); |
330 | end; |
332 | end; |
331 | 333 | ||
332 | function Asn1IdValid(asn1id: string): boolean; |
334 | function Asn1IdValid(asn1id: string): boolean; |
333 | var |
335 | var |
334 | i: integer; |
336 | i: integer; |
335 | begin |
337 | begin |
336 | if asn1id = '' then |
338 | if asn1id = '' then |
337 | begin |
339 | begin |
338 | result := false; |
340 | result := false; |
339 | exit; |
341 | exit; |
340 | end; |
342 | end; |
341 | 343 | ||
342 | if not (asn1id[1] in ['a'..'z']) then |
344 | if not (asn1id[1] in ['a'..'z']) then |
343 | begin |
345 | begin |
344 | result := false; |
346 | result := false; |
345 | exit; |
347 | exit; |
346 | end; |
348 | end; |
347 | 349 | ||
348 | for i := 2 to Length(asn1id) do |
350 | for i := 2 to Length(asn1id) do |
349 | begin |
351 | begin |
350 | if not (asn1id[1] in ['a'..'z', 'A'..'Z', '0'..'9', '-']) then |
352 | if not (asn1id[1] in ['a'..'z', 'A'..'Z', '0'..'9', '-']) then |
351 | begin |
353 | begin |
352 | result := false; |
354 | result := false; |
353 | exit; |
355 | exit; |
354 | end; |
356 | end; |
355 | end; |
357 | end; |
356 | 358 | ||
357 | result := true; |
359 | result := true; |
358 | end; |
360 | end; |
359 | 361 | ||
360 | procedure TForm1.Button1Click(Sender: TObject); |
362 | procedure TForm1.Button1Click(Sender: TObject); |
361 | var |
363 | var |
362 | asn1id: string; |
364 | asn1id: string; |
363 | i: integer; |
365 | i: integer; |
364 | begin |
366 | begin |
365 | asn1id := Edit7.Text; |
367 | asn1id := Edit7.Text; |
366 | if asn1id = '' then exit; |
368 | if asn1id = '' then exit; |
367 | for i := 0 to ListBox1.Items.Count-1 do |
369 | for i := 0 to ListBox1.Items.Count-1 do |
368 | begin |
370 | begin |
369 | if ListBox1.Items.Strings[i] = asn1id then ShowError('Item already exists'); |
371 | if ListBox1.Items.Strings[i] = asn1id then ShowError('Item already exists'); |
370 | end; |
372 | end; |
371 | if not Asn1IdValid(asn1id) then ShowError('Invalid alphanumeric identifier'); |
373 | if not Asn1IdValid(asn1id) then ShowError('Invalid alphanumeric identifier'); |
372 | ListBox1.Items.Add(asn1id); |
374 | ListBox1.Items.Add(asn1id); |
373 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text + ' ' + GetAsn1Ids(true)); |
375 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text + ' ' + GetAsn1Ids(true)); |
374 | Edit7.Text := ''; |
376 | Edit7.Text := ''; |
375 | end; |
377 | end; |
376 | 378 | ||
377 | procedure TForm1.Button3Click(Sender: TObject); |
379 | procedure TForm1.Button3Click(Sender: TObject); |
378 | begin |
380 | begin |
379 | if (ListBox1.Items.Count > 0) and ListBox1.Selected[ListBox1.ItemIndex] then |
381 | if (ListBox1.Items.Count > 0) and ListBox1.Selected[ListBox1.ItemIndex] then |
380 | begin |
382 | begin |
381 | ListBox1.Items.Delete(ListBox1.ItemIndex); |
383 | ListBox1.Items.Delete(ListBox1.ItemIndex); |
382 | end; |
384 | end; |
383 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text + ' ' + GetAsn1Ids(true)); |
385 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text + ' ' + GetAsn1Ids(true)); |
384 | end; |
386 | end; |
385 | 387 | ||
386 | function IsPositiveNumber(str: string): boolean; |
388 | function IsPositiveNumber(str: string): boolean; |
387 | var |
389 | var |
388 | i: integer; |
390 | i: integer; |
389 | begin |
391 | begin |
390 | if (str = '') then |
392 | if (str = '') then |
391 | begin |
393 | begin |
392 | result := false; |
394 | result := false; |
393 | exit; |
395 | exit; |
394 | end; |
396 | end; |
395 | 397 | ||
396 | result := true; |
398 | result := true; |
397 | for i := 1 to Length(str) do |
399 | for i := 1 to Length(str) do |
398 | begin |
400 | begin |
399 | if not (str[i] in ['0'..'9']) then |
401 | if not (str[i] in ['0'..'9']) then |
400 | begin |
402 | begin |
401 | result := false; |
403 | result := false; |
402 | exit; |
404 | exit; |
403 | end; |
405 | end; |
404 | end; |
406 | end; |
405 | 407 | ||
406 | if (str[1] = '0') and (str <> '0') then |
408 | if (str[1] = '0') and (str <> '0') then |
407 | begin |
409 | begin |
408 | result := false; |
410 | result := false; |
409 | exit; |
411 | exit; |
410 | end; |
412 | end; |
411 | end; |
413 | end; |
412 | 414 | ||
413 | procedure TForm1.Button4Click(Sender: TObject); |
415 | procedure TForm1.Button4Click(Sender: TObject); |
414 | var |
416 | var |
415 | ini: TIniFile; |
417 | ini: TIniFile; |
416 | i, di: integer; |
418 | i, di: integer; |
417 | oid, parent_oid, new_value: string; |
419 | oid, parent_oid, new_value: string; |
418 | nod: integer; |
420 | nod: integer; |
419 | candidate: string; |
421 | candidate: string; |
420 | begin |
422 | begin |
421 | if Notebook1.PageIndex = 0 then new_value := Edit1.Text; |
423 | if Notebook1.PageIndex = 0 then new_value := Edit1.Text; |
422 | if Notebook1.PageIndex = 2 then new_value := Edit2.Text; |
424 | if Notebook1.PageIndex = 2 then new_value := Edit2.Text; |
423 | 425 | ||
424 | new_value := Trim(new_value); |
426 | new_value := Trim(new_value); |
425 | if new_value = '' then exit; |
427 | if new_value = '' then exit; |
426 | 428 | ||
427 | if not IsPositiveNumber(new_value) then ShowError('Not a valid number'); |
429 | if not IsPositiveNumber(new_value) then ShowError('Not a valid number'); |
428 | 430 | ||
429 | if Notebook1.PageIndex = 0 then |
431 | if Notebook1.PageIndex = 0 then |
430 | begin |
432 | begin |
431 | oid := Edit4.Text + '.' + new_value; |
433 | oid := Edit4.Text + '.' + new_value; |
432 | parent_oid := Edit4.Text; |
434 | parent_oid := Edit4.Text; |
433 | end |
435 | end |
434 | else |
436 | else |
435 | begin |
437 | begin |
436 | oid := 'OID:' + new_value; |
438 | oid := 'OID:' + new_value; |
437 | parent_oid := 'OID:'; |
439 | parent_oid := 'OID:'; |
438 | end; |
440 | end; |
439 | 441 | ||
440 | if Outline1.Items[Outline1.SelectedItem].HasItems then |
442 | if Outline1.Items[Outline1.SelectedItem].HasItems then |
441 | for i := Outline1.Items[Outline1.SelectedItem].GetFirstChild to Outline1.Items[Outline1.SelectedItem].GetLastChild do |
443 | for i := Outline1.Items[Outline1.SelectedItem].GetFirstChild to Outline1.Items[Outline1.SelectedItem].GetLastChild do |
442 | begin |
444 | begin |
443 | candidate := Copy(Trim(Outline1.Lines[i-1]), 1, Pos(' ',Trim(Outline1.Lines[i-1])+' ')-1); |
445 | candidate := Copy(Trim(Outline1.Lines[i-1]), 1, Pos(' ',Trim(Outline1.Lines[i-1])+' ')-1); |
444 | if oid = candidate then ShowError('Item already exists'); |
446 | if oid = candidate then ShowError('Item already exists'); |
445 | end; |
447 | end; |
446 | 448 | ||
447 | if (parent_oid = 'OID:') and (StrToInt(new_value) > 2) then ShowError('Number must not exceed 2'); |
449 | if (parent_oid = 'OID:') and (StrToInt(new_value) > 2) then ShowError('Number must not exceed 2'); |
448 | if (parent_oid = 'OID:0') and (StrToInt(new_value) > 39) then ShowError('Number must not exceed 39'); |
450 | if (parent_oid = 'OID:0') and (StrToInt(new_value) > 39) then ShowError('Number must not exceed 39'); |
449 | if (parent_oid = 'OID:1') and (StrToInt(new_value) > 39) then ShowError('Number must not exceed 39'); |
451 | if (parent_oid = 'OID:1') and (StrToInt(new_value) > 39) then ShowError('Number must not exceed 39'); |
450 | 452 | ||
451 | ini := TIniFile.Create(DBPath+'OID.INI'); |
453 | ini := TIniFile.Create(DBPath+'OID.INI'); |
452 | try |
454 | try |
453 | nod := Outline1.AddChild(Outline1.SelectedItem, oid); |
455 | nod := Outline1.AddChild(Outline1.SelectedItem, oid); |
454 | ComboBox1.Text := ini.ReadString(parent_oid, 'ra', ''); |
456 | ComboBox1.Text := ini.ReadString(parent_oid, 'ra', ''); |
455 | 457 | ||
456 | di := ini.ReadInteger(parent_oid, 'delegates', 0); |
458 | di := ini.ReadInteger(parent_oid, 'delegates', 0); |
457 | ini.WriteInteger(parent_oid, 'delegates', di+1); |
459 | ini.WriteInteger(parent_oid, 'delegates', di+1); |
458 | ini.WriteString(parent_oid, 'delegate'+IntToStr(di+1), oid); |
460 | ini.WriteString(parent_oid, 'delegate'+IntToStr(di+1), oid); |
459 | 461 | ||
460 | ini.WriteString(oid, 'createdate', DateToStr(date)); |
462 | ini.WriteString(oid, 'createdate', DateToStr(date)); |
461 | ini.WriteString(oid, 'ra', ComboBox1.Text); |
463 | ini.WriteString(oid, 'ra', ComboBox1.Text); |
462 | 464 | ||
463 | if Notebook1.PageIndex = 0 then Edit1.Text := ''; |
465 | if Notebook1.PageIndex = 0 then Edit1.Text := ''; |
464 | if Notebook1.PageIndex = 2 then Edit2.Text := ''; |
466 | if Notebook1.PageIndex = 2 then Edit2.Text := ''; |
465 | 467 | ||
466 | Outline1.SelectedItem := nod; |
468 | Outline1.SelectedItem := nod; |
467 | 469 | ||
468 | { ini.UpdateFile; } |
470 | { ini.UpdateFile; } |
469 | finally |
471 | finally |
470 | ini.Free; |
472 | ini.Free; |
471 | end; |
473 | end; |
472 | 474 | ||
473 | ShowMessage('Created: ' + oid); |
475 | ShowMessage('Created: ' + oid); |
474 | end; |
476 | end; |
475 | 477 | ||
476 | procedure TForm1.Button7Click(Sender: TObject); |
478 | procedure TForm1.Button7Click(Sender: TObject); |
477 | var |
479 | var |
478 | ini: TIniFile; |
480 | ini: TIniFile; |
479 | di: integer; |
481 | di: integer; |
480 | nod: integer; |
482 | nod: integer; |
481 | sectionName, new_value, candidate: string; |
483 | sectionName, new_value, candidate: string; |
482 | i: integer; |
484 | i: integer; |
483 | begin |
485 | begin |
484 | ini := TIniFile.Create(DBPath+'RA.INI'); |
486 | ini := TIniFile.Create(DBPath+'RA.INI'); |
485 | try |
487 | try |
486 | new_value := Edit8.Text; |
488 | new_value := Edit8.Text; |
487 | new_value := Trim(new_value); |
489 | new_value := Trim(new_value); |
488 | if new_value = '' then exit; |
490 | if new_value = '' then exit; |
489 | 491 | ||
490 | sectionName := 'RA:'+new_value; |
492 | sectionName := 'RA:'+new_value; |
491 | 493 | ||
492 | if Outline1.Items[Outline1.SelectedItem].HasItems then |
494 | if Outline1.Items[Outline1.SelectedItem].HasItems then |
493 | for i := Outline1.Items[Outline1.SelectedItem].GetFirstChild to Outline1.Items[Outline1.SelectedItem].GetLastChild do |
495 | for i := Outline1.Items[Outline1.SelectedItem].GetFirstChild to Outline1.Items[Outline1.SelectedItem].GetLastChild do |
494 | begin |
496 | begin |
495 | candidate := Trim(Outline1.Lines[i-1]); |
497 | candidate := Trim(Outline1.Lines[i-1]); |
496 | if sectionName = candidate then ShowError('Item already exists'); |
498 | if sectionName = candidate then ShowError('Item already exists'); |
497 | end; |
499 | end; |
498 | 500 | ||
499 | di := ini.ReadInteger('RA:', 'count', 0); |
501 | di := ini.ReadInteger('RA:', 'count', 0); |
500 | ini.WriteInteger('RA:', 'count', di+1); |
502 | ini.WriteInteger('RA:', 'count', di+1); |
501 | ini.WriteString('RA:', 'ra'+IntToStr(di+1), sectionName); |
503 | ini.WriteString('RA:', 'ra'+IntToStr(di+1), sectionName); |
502 | 504 | ||
503 | nod := Outline1.AddChild(Outline1.SelectedItem, sectionName); |
505 | nod := Outline1.AddChild(Outline1.SelectedItem, sectionName); |
504 | 506 | ||
505 | ini.WriteString(sectionName, 'createdate', DateToStr(date)); |
507 | ini.WriteString(sectionName, 'createdate', DateToStr(date)); |
506 | 508 | ||
507 | Edit8.Text := ''; |
509 | Edit8.Text := ''; |
508 | 510 | ||
509 | Outline1.SelectedItem := nod; |
511 | Outline1.SelectedItem := nod; |
510 | 512 | ||
511 | ini.WriteString(sectionName, 'createdate', DateToStr(date)); |
513 | ini.WriteString(sectionName, 'createdate', DateToStr(date)); |
512 | 514 | ||
513 | { ini.UpdateFile; } |
515 | { ini.UpdateFile; } |
514 | finally |
516 | finally |
515 | ini.Free; |
517 | ini.Free; |
516 | end; |
518 | end; |
517 | 519 | ||
518 | ComboBox1.Items.Add(sectionName); |
520 | ComboBox1.Items.Add(sectionName); |
519 | 521 | ||
520 | ShowMessage('Created: ' + sectionName); |
522 | ShowMessage('Created: ' + sectionName); |
521 | end; |
523 | end; |
522 | 524 | ||
523 | procedure IniReadSections(ini: TIniFile; Strings: TStrings); |
525 | procedure IniReadSections(ini: TIniFile; Strings: TStrings); |
524 | const |
526 | const |
525 | BufSize = 16384; |
527 | BufSize = 16384; |
526 | var |
528 | var |
527 | Buffer, P: PChar; |
529 | Buffer, P: PChar; |
528 | FFileName: string; |
530 | FFileName: string; |
529 | begin |
531 | begin |
530 | GetMem(Buffer, BufSize); |
532 | GetMem(Buffer, BufSize); |
531 | try |
533 | try |
532 | Strings.BeginUpdate; |
534 | Strings.BeginUpdate; |
533 | try |
535 | try |
534 | Strings.Clear; |
536 | Strings.Clear; |
535 | FFileName := ini.FileName; |
537 | FFileName := ini.FileName; |
536 | if GetPrivateProfileString(nil, nil, nil, Buffer, BufSize, |
538 | if GetPrivateProfileString(nil, nil, nil, Buffer, BufSize, |
537 | @FFileName[1]) <> 0 then |
539 | @FFileName[1]) <> 0 then |
538 | begin |
540 | begin |
539 | P := Buffer; |
541 | P := Buffer; |
540 | while P^ <> #0 do |
542 | while P^ <> #0 do |
541 | begin |
543 | begin |
542 | Strings.Add(StrPas(P)); |
544 | Strings.Add(StrPas(P)); |
543 | Inc(P, StrLen(P) + 1); |
545 | Inc(P, StrLen(P) + 1); |
544 | end; |
546 | end; |
545 | end; |
547 | end; |
546 | finally |
548 | finally |
547 | Strings.EndUpdate; |
549 | Strings.EndUpdate; |
548 | end; |
550 | end; |
549 | finally |
551 | finally |
550 | FreeMem(Buffer, BufSize); |
552 | FreeMem(Buffer, BufSize); |
551 | end; |
553 | end; |
552 | end; |
554 | end; |
553 | 555 | ||
554 | procedure TForm1.Button6Click(Sender: TObject); |
556 | procedure TForm1.Button6Click(Sender: TObject); |
555 | var |
557 | var |
556 | ini: TIniFile; |
558 | ini: TIniFile; |
557 | nod: TOutlineNode; |
559 | nod: TOutlineNode; |
558 | parent_oid, this_oid: string; |
560 | parent_oid, this_oid: string; |
559 | i: integer; |
561 | i: integer; |
560 | sl: TStringList; |
562 | sl: TStringList; |
561 | begin |
563 | begin |
562 | if MessageDlg('Are you sure?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit; |
564 | if MessageDlg('Are you sure?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit; |
563 | 565 | ||
564 | ini := TIniFile.Create(DBPath+'OID.INI'); |
566 | ini := TIniFile.Create(DBPath+'OID.INI'); |
565 | try |
567 | try |
566 | this_oid := Edit4.Text; |
568 | this_oid := Edit4.Text; |
567 | 569 | ||
568 | if Outline1.Items[Outline1.SelectedItem].Parent.Text = TITLE_OID then |
570 | if Outline1.Items[Outline1.SelectedItem].Parent.Text = TITLE_OID then |
569 | parent_oid := 'OID:' |
571 | parent_oid := 'OID:' |
570 | else |
572 | else |
571 | parent_oid := Copy(Outline1.Items[Outline1.SelectedItem].Parent.Text, 1, |
573 | parent_oid := Copy(Outline1.Items[Outline1.SelectedItem].Parent.Text, 1, |
572 | Pos(' ', Outline1.Items[Outline1.SelectedItem].Parent.Text+' ')-1); |
574 | Pos(' ', Outline1.Items[Outline1.SelectedItem].Parent.Text+' ')-1); |
573 | 575 | ||
574 | nod := Outline1.Items[Outline1.SelectedItem]; |
576 | nod := Outline1.Items[Outline1.SelectedItem]; |
575 | Outline1.SelectedItem := nod.Parent.Index; |
577 | Outline1.SelectedItem := nod.Parent.Index; |
576 | Outline1.Delete(nod.Index); |
578 | Outline1.Delete(nod.Index); |
577 | 579 | ||
578 | ini.EraseSection(this_oid); |
580 | ini.EraseSection(this_oid); |
579 | 581 | ||
580 | sl := TStringList.Create; |
582 | sl := TStringList.Create; |
581 | IniReadSections(ini, sl); |
583 | IniReadSections(ini, sl); |
582 | for i := 0 to sl.Count-1 do |
584 | for i := 0 to sl.Count-1 do |
583 | begin |
585 | begin |
584 | if Copy(sl.Strings[i], 1, Length(this_oid)+1) = this_oid+'.' then |
586 | if Copy(sl.Strings[i], 1, Length(this_oid)+1) = this_oid+'.' then |
585 | begin |
587 | begin |
586 | ini.EraseSection(sl.Strings[i]); |
588 | ini.EraseSection(sl.Strings[i]); |
587 | end; |
589 | end; |
588 | end; |
590 | end; |
589 | sl.Free; |
591 | sl.Free; |
590 | 592 | ||
591 | for i := 1 to ini.ReadInteger(parent_oid, 'delegates', 0) do |
593 | for i := 1 to ini.ReadInteger(parent_oid, 'delegates', 0) do |
592 | begin |
594 | begin |
593 | if ini.ReadString(parent_oid, 'delegate'+IntToStr(i), '') = this_oid then |
595 | if ini.ReadString(parent_oid, 'delegate'+IntToStr(i), '') = this_oid then |
594 | begin |
596 | begin |
595 | ini.WriteString(parent_oid, 'delegate'+IntToStr(i), ''); |
597 | ini.WriteString(parent_oid, 'delegate'+IntToStr(i), ''); |
596 | end; |
598 | end; |
597 | end; |
599 | end; |
598 | 600 | ||
599 | { ini.UpdateFile; } |
601 | { ini.UpdateFile; } |
600 | finally |
602 | finally |
601 | ini.Free; |
603 | ini.Free; |
602 | end; |
604 | end; |
603 | end; |
605 | end; |
604 | 606 | ||
605 | procedure TForm1.Button8Click(Sender: TObject); |
607 | procedure TForm1.Button8Click(Sender: TObject); |
606 | var |
608 | var |
607 | ini: TIniFile; |
609 | ini: TIniFile; |
608 | nod: TOutlineNode; |
610 | nod: TOutlineNode; |
609 | parent_ra, this_ra: string; |
611 | parent_ra, this_ra: string; |
610 | i: integer; |
612 | i: integer; |
611 | begin |
613 | begin |
612 | if MessageDlg('Are you sure?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit; |
614 | if MessageDlg('Are you sure?', mtConfirmation, mbYesNoCancel, 0) <> mrYes then exit; |
613 | 615 | ||
614 | ini := TIniFile.Create(DBPath+'RA.INI'); |
616 | ini := TIniFile.Create(DBPath+'RA.INI'); |
615 | try |
617 | try |
616 | this_ra := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
618 | this_ra := Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, Pos(' ',Outline1.Items[Outline1.SelectedItem].Text+' ')-1); |
617 | if Outline1.Items[Outline1.SelectedItem].Parent.Text = TITLE_RA then |
619 | if Outline1.Items[Outline1.SelectedItem].Parent.Text = TITLE_RA then |
618 | parent_ra := 'RA:' |
620 | parent_ra := 'RA:' |
619 | else |
621 | else |
620 | parent_ra := Copy(Outline1.Items[Outline1.SelectedItem].Parent.Text, 1, |
622 | parent_ra := Copy(Outline1.Items[Outline1.SelectedItem].Parent.Text, 1, |
621 | Pos(' ', Outline1.Items[Outline1.SelectedItem].Parent.Text+' ')-1); |
623 | Pos(' ', Outline1.Items[Outline1.SelectedItem].Parent.Text+' ')-1); |
622 | 624 | ||
623 | nod := Outline1.Items[Outline1.SelectedItem]; |
625 | nod := Outline1.Items[Outline1.SelectedItem]; |
624 | Outline1.SelectedItem := nod.Parent.Index; |
626 | Outline1.SelectedItem := nod.Parent.Index; |
625 | Outline1.Delete(nod.Index); |
627 | Outline1.Delete(nod.Index); |
626 | 628 | ||
627 | ini.EraseSection(this_ra); |
629 | ini.EraseSection(this_ra); |
628 | 630 | ||
629 | for i := 1 to ini.ReadInteger(parent_ra, 'count', 0) do |
631 | for i := 1 to ini.ReadInteger(parent_ra, 'count', 0) do |
630 | begin |
632 | begin |
631 | if ini.ReadString(parent_ra, 'ra'+IntToStr(i), '') = this_ra then |
633 | if ini.ReadString(parent_ra, 'ra'+IntToStr(i), '') = this_ra then |
632 | begin |
634 | begin |
633 | ini.WriteString(parent_ra, 'ra'+IntToStr(i), ''); |
635 | ini.WriteString(parent_ra, 'ra'+IntToStr(i), ''); |
634 | end; |
636 | end; |
635 | end; |
637 | end; |
636 | 638 | ||
637 | ComboBox1.Items.Delete(ComboBox1.Items.IndexOf(this_ra)); |
639 | ComboBox1.Items.Delete(ComboBox1.Items.IndexOf(this_ra)); |
638 | 640 | ||
639 | { ini.UpdateFile; } |
641 | { ini.UpdateFile; } |
640 | finally |
642 | finally |
641 | ini.Free; |
643 | ini.Free; |
642 | end; |
644 | end; |
643 | end; |
645 | end; |
644 | 646 | ||
645 | function RandomStr(len: integer): string; |
647 | function RandomStr(len: integer): string; |
646 | var |
648 | var |
647 | i: integer; |
649 | i: integer; |
648 | begin |
650 | begin |
649 | result := ''; |
651 | result := ''; |
650 | for i := 1 to len do |
652 | for i := 1 to len do |
651 | begin |
653 | begin |
652 | result := result + Chr(ord('A') + Random(26)); |
654 | result := result + Chr(ord('A') + Random(26)); |
653 | end; |
655 | end; |
654 | end; |
656 | end; |
655 | 657 | ||
656 | procedure TForm1.Button2Click(Sender: TObject); |
658 | procedure TForm1.Button2Click(Sender: TObject); |
657 | var |
659 | var |
658 | ini: TIniFile; |
660 | ini: TIniFile; |
659 | txtFile, asn1s: string; |
661 | txtFile, asn1s: string; |
660 | modified: boolean; |
662 | modified: boolean; |
661 | begin |
663 | begin |
662 | { Attention: Do not rely on Outline1.Items[Outline1.SelectedItem].Text, because Button2.Click |
664 | { Attention: Do not rely on Outline1.Items[Outline1.SelectedItem].Text, because Button2.Click |
663 | will be called in Outline1OnChange()! } |
665 | will be called in Outline1OnChange()! } |
664 | 666 | ||
665 | ini := TIniFile.Create(DBPath+'OID.INI'); |
667 | ini := TIniFile.Create(DBPath+'OID.INI'); |
666 | try |
668 | try |
667 | modified := false; |
669 | modified := false; |
668 | 670 | ||
669 | if ini.ReadString(Edit4.Text, 'ra', '') <> ComboBox1.Text then |
671 | if ini.ReadString(Edit4.Text, 'ra', '') <> ComboBox1.Text then |
670 | begin |
672 | begin |
671 | modified := true; |
673 | modified := true; |
672 | ini.WriteString(Edit4.Text, 'ra', ComboBox1.Text); |
674 | ini.WriteString(Edit4.Text, 'ra', ComboBox1.Text); |
673 | end; |
675 | end; |
674 | 676 | ||
675 | if ini.ReadString(Edit4.Text, 'description', '') <> Edit3.Text then |
677 | if ini.ReadString(Edit4.Text, 'description', '') <> Edit3.Text then |
676 | begin |
678 | begin |
677 | modified := true; |
679 | modified := true; |
678 | ini.WriteString(Edit4.Text, 'description', Edit3.Text); |
680 | ini.WriteString(Edit4.Text, 'description', Edit3.Text); |
679 | end; |
681 | end; |
680 | 682 | ||
681 | if ini.ReadBool(Edit4.Text, 'draft', false) <> CheckBox1.Checked then |
683 | if ini.ReadBool(Edit4.Text, 'draft', false) <> CheckBox1.Checked then |
682 | begin |
684 | begin |
683 | modified := true; |
685 | modified := true; |
684 | ini.WriteBool(Edit4.Text, 'draft', CheckBox1.Checked); |
686 | ini.WriteBool(Edit4.Text, 'draft', CheckBox1.Checked); |
685 | end; |
687 | end; |
686 | 688 | ||
687 | if Memo1.Modified then |
689 | if Memo1.Modified then |
688 | begin |
690 | begin |
689 | modified := true; |
691 | modified := true; |
690 | if Trim(Memo1.Text) = '' then |
692 | if Trim(Memo1.Text) = '' then |
691 | begin |
693 | begin |
692 | txtFile := ini.ReadString(Edit4.Text, 'information', ''); |
694 | txtFile := ini.ReadString(Edit4.Text, 'information', ''); |
693 | if FileExists(DBPath+txtFile) then |
695 | if FileExists(DBPath+txtFile) then |
694 | begin |
696 | begin |
695 | DeleteFile(DBPath+txtFile); |
697 | DeleteFile(DBPath+txtFile); |
696 | end; |
698 | end; |
697 | if txtFile <> '' then |
699 | if txtFile <> '' then |
698 | begin |
700 | begin |
699 | ini.WriteString(Edit4.Text, 'information', '') |
701 | ini.WriteString(Edit4.Text, 'information', '') |
700 | end; |
702 | end; |
701 | end |
703 | end |
702 | else |
704 | else |
703 | begin |
705 | begin |
704 | txtFile := ini.ReadString(Edit4.Text, 'information', ''); |
706 | txtFile := ini.ReadString(Edit4.Text, 'information', ''); |
705 | if txtFile = '' then |
707 | if txtFile = '' then |
706 | begin |
708 | begin |
707 | repeat |
709 | repeat |
708 | txtFile := RandomStr(8) + '.TXT'; |
710 | txtFile := RandomStr(8) + '.TXT'; |
709 | until not FileExists(DBPath+txtFile); |
711 | until not FileExists(DBPath+txtFile); |
710 | ini.WriteString(Edit4.Text, 'information', txtFile); |
712 | ini.WriteString(Edit4.Text, 'information', txtFile); |
711 | end; |
713 | end; |
712 | 714 | ||
713 | Memo1.Lines.SaveToFile(DBPath+txtFile); |
715 | Memo1.Lines.SaveToFile(DBPath+txtFile); |
714 | Memo1.Modified := false; |
716 | Memo1.Modified := false; |
715 | end; |
717 | end; |
716 | end; |
718 | end; |
717 | 719 | ||
718 | asn1s := GetAsn1Ids(false); |
720 | asn1s := GetAsn1Ids(false); |
719 | if ini.ReadString(Edit4.Text, 'asn1id', '') <> asn1s then |
721 | if ini.ReadString(Edit4.Text, 'asn1id', '') <> asn1s then |
720 | begin |
722 | begin |
721 | modified := true; |
723 | modified := true; |
722 | ini.WriteString(Edit4.Text, 'asn1id', asn1s); |
724 | ini.WriteString(Edit4.Text, 'asn1id', asn1s); |
723 | end; |
725 | end; |
724 | 726 | ||
725 | if modified then |
727 | if modified then |
726 | begin |
728 | begin |
727 | ini.WriteString(Edit4.Text, 'updatedate', DateToStr(Date)); |
729 | ini.WriteString(Edit4.Text, 'updatedate', DateToStr(Date)); |
728 | { ini.Updatefile; } |
730 | { ini.Updatefile; } |
729 | end; |
731 | end; |
730 | finally |
732 | finally |
731 | ini.Free; |
733 | ini.Free; |
732 | end; |
734 | end; |
733 | end; |
735 | end; |
734 | 736 | ||
735 | function TForm1.GetAsn1Ids(onlyfirst: boolean): string; |
737 | function TForm1.GetAsn1Ids(onlyfirst: boolean): string; |
736 | var |
738 | var |
737 | i: integer; |
739 | i: integer; |
738 | begin |
740 | begin |
739 | result := ''; |
741 | result := ''; |
740 | for i := 0 to ListBox1.Items.Count-1 do |
742 | for i := 0 to ListBox1.Items.Count-1 do |
741 | begin |
743 | begin |
742 | if result = '' then |
744 | if result = '' then |
743 | result := ListBox1.Items.Strings[i] |
745 | result := ListBox1.Items.Strings[i] |
744 | else if not onlyfirst then |
746 | else if not onlyfirst then |
745 | result := result + ',' + ListBox1.Items.Strings[i]; |
747 | result := result + ',' + ListBox1.Items.Strings[i]; |
746 | end; |
748 | end; |
747 | end; |
749 | end; |
748 | 750 | ||
749 | function DirectoryExists(const Directory: string; FollowLink: Boolean): Boolean; { Source: Delphi 10.3.3 } |
- | |
750 | { |
- | |
751 | var |
- | |
752 | Code: Cardinal; |
- | |
753 | Handle: THandle; |
- | |
754 | LastError: Cardinal; |
- | |
755 | const |
- | |
756 | faSymLink = $00000400; // Available on POSIX and Vista and above |
- | |
757 | INVALID_FILE_ATTRIBUTES = DWORD($FFFFFFFF); |
- | |
758 | begin |
- | |
759 | Result := False; |
- | |
760 | Code := GetFileAttributes(PChar(Directory)); |
- | |
761 | - | ||
762 | if Code <> INVALID_FILE_ATTRIBUTES then |
- | |
763 | begin |
- | |
764 | if faSymLink and Code = 0 then |
- | |
765 | Result := faDirectory and Code <> 0 |
- | |
766 | else |
- | |
767 | begin |
- | |
768 | if FollowLink then |
- | |
769 | begin |
- | |
770 | Handle := CreateFile(PChar(Directory), GENERIC_READ, FILE_SHARE_READ, nil, |
- | |
771 | OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); |
- | |
772 | if Handle <> INVALID_HANDLE_VALUE then |
- | |
773 | begin |
- | |
774 | CloseHandle(Handle); |
- | |
775 | Result := faDirectory and Code <> 0; |
- | |
776 | end; |
- | |
777 | end |
- | |
778 | else if faDirectory and Code <> 0 then |
- | |
779 | Result := True |
- | |
780 | else |
- | |
781 | begin |
- | |
782 | Handle := CreateFile(PChar(Directory), GENERIC_READ, FILE_SHARE_READ, nil, |
- | |
783 | OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); |
- | |
784 | if Handle <> INVALID_HANDLE_VALUE then |
- | |
785 | begin |
- | |
786 | CloseHandle(Handle); |
- | |
787 | Result := False; |
- | |
788 | end |
- | |
789 | else |
- | |
790 | Result := True; |
- | |
791 | end; |
- | |
792 | end; |
- | |
793 | end |
- | |
794 | else |
- | |
795 | begin |
- | |
796 | LastError := GetLastError; |
- | |
797 | Result := (LastError <> ERROR_FILE_NOT_FOUND) and |
- | |
798 | (LastError <> ERROR_PATH_NOT_FOUND) and |
- | |
799 | (LastError <> ERROR_BAD_PATHNAME) and |
- | |
800 | (LastError <> ERROR_INVALID_NAME) and |
- | |
801 | (LastError <> ERROR_BAD_NETPATH) and |
- | |
802 | (LastError <> ERROR_NOT_READY) and |
- | |
803 | (LastError <> ERROR_BAD_NET_NAME); |
- | |
804 | end; |
- | |
805 | } |
- | |
806 | begin |
- | |
807 | { TODO } |
- | |
808 | end; |
- | |
809 | - | ||
810 | function IniValueExists(ini: TIniFile; const Section, Ident: string): Boolean; |
751 | function IniValueExists(ini: TIniFile; const Section, Ident: string): Boolean; |
811 | var |
752 | var |
812 | S: TStrings; |
753 | S: TStrings; |
813 | begin |
754 | begin |
814 | S := TStringList.Create; |
755 | S := TStringList.Create; |
815 | try |
756 | try |
816 | ini.ReadSection(Section, S); |
757 | ini.ReadSection(Section, S); |
817 | Result := S.IndexOf(Ident) > -1; |
758 | Result := S.IndexOf(Ident) > -1; |
818 | finally |
759 | finally |
819 | S.Free; |
760 | S.Free; |
820 | end; |
761 | end; |
821 | end; |
762 | end; |
822 | 763 | ||
- | 764 | var |
|
- | 765 | MkDirTriedOnce: boolean; { Avoid that the debugger always shows the exception } |
|
- | 766 | procedure MakeDirIfRequired(dirname: string); |
|
- | 767 | begin |
|
- | 768 | if dirname[Length(dirname)] = '\' then dirname := Copy(dirname, 1, Length(dirname)-1); |
|
- | 769 | ||
- | 770 | if not MkDirTriedOnce then |
|
- | 771 | begin |
|
- | 772 | try |
|
- | 773 | MkDir(dirname); |
|
- | 774 | except |
|
- | 775 | end; |
|
- | 776 | MkDirTriedOnce := true; |
|
- | 777 | end; |
|
- | 778 | end; |
|
- | 779 | ||
823 | function TForm1.DBPath: string; |
780 | function TForm1.DBPath: string; |
824 | var |
781 | var |
825 | ini: TIniFile; |
782 | ini: TIniFile; |
826 | begin |
783 | begin |
827 | ini := TIniFile.Create('.\OIDPLUS.INI'); |
784 | ini := TIniFile.Create('.\OIDPLUS.INI'); |
828 | try |
785 | try |
829 | if not IniValueExists(ini, 'SETTINGS', 'DATA') then |
786 | if not IniValueExists(ini, 'SETTINGS', 'DATA') then |
830 | begin |
787 | begin |
831 | result := 'DB\'; |
788 | result := 'DB\'; |
832 | ini.WriteString('SETTINGS', 'DATA', result); |
789 | ini.WriteString('SETTINGS', 'DATA', result); |
833 | { ini.UpdateFile; } |
790 | { ini.UpdateFile; } |
834 | end |
791 | end |
835 | else |
792 | else |
836 | begin |
793 | begin |
837 | result := ini.ReadString('SETTINGS', 'DATA', 'DB\'); |
794 | result := ini.ReadString('SETTINGS', 'DATA', 'DB\'); |
838 | end; |
795 | end; |
839 | if not DirectoryExists(result, true) then MkDir(result); |
- | |
840 | if not DirectoryExists(result, true) then |
796 | MakeDirIfRequired(result); |
841 | begin |
- | |
842 | ShowError('Cannot create database directory '+result); |
- | |
843 | end; |
- | |
844 | finally |
797 | finally |
845 | ini.Free; |
798 | ini.Free; |
846 | end; |
799 | end; |
847 | end; |
800 | end; |
848 | 801 | ||
849 | procedure TForm1.FormCreate(Sender: TObject); |
802 | procedure TForm1.FormCreate(Sender: TObject); |
850 | begin |
803 | begin |
851 | Notebook1.PageIndex := 2; |
804 | Notebook1.PageIndex := 2; |
852 | Randomize; |
805 | Randomize; |
853 | end; |
806 | end; |
854 | 807 | ||
855 | procedure TForm1.SaveChangesIfRequired; |
808 | procedure TForm1.SaveChangesIfRequired; |
856 | begin |
809 | begin |
857 | if Notebook1.PageIndex = 0 then Button2.Click; { Save changes } |
810 | if Notebook1.PageIndex = 0 then Button2.Click; { Save changes } |
858 | if Notebook1.PageIndex = 1 then Button9.Click; { Save changes } |
811 | if Notebook1.PageIndex = 1 then Button9.Click; { Save changes } |
859 | end; |
812 | end; |
860 | 813 | ||
861 | procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
814 | procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); |
862 | begin |
815 | begin |
863 | SaveChangesIfRequired; |
816 | SaveChangesIfRequired; |
864 | CanClose := true; |
817 | CanClose := true; |
865 | end; |
818 | end; |
866 | 819 | ||
867 | procedure TForm1.CheckBox1Click(Sender: TObject); |
820 | procedure TForm1.CheckBox1Click(Sender: TObject); |
868 | begin |
821 | begin |
869 | if CheckBox1.Checked then |
822 | if CheckBox1.Checked then |
870 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text+' '+GetAsn1Ids(true))+' [DRAFT]' |
823 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text+' '+GetAsn1Ids(true))+' [DRAFT]' |
871 | else |
824 | else |
872 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text+' '+GetAsn1Ids(true)); |
825 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit4.Text+' '+GetAsn1Ids(true)); |
873 | end; |
826 | end; |
874 | 827 | ||
875 | procedure TForm1.ShowError(msg: string); |
828 | procedure TForm1.ShowError(msg: string); |
876 | begin |
829 | begin |
877 | MessageDlg(msg, mtError, [mbOk], 0); |
830 | MessageDlg(msg, mtError, [mbOk], 0); |
878 | Abort; |
831 | Abort; |
879 | end; |
832 | end; |
880 | 833 | ||
881 | procedure TForm1.Button9Click(Sender: TObject); |
834 | procedure TForm1.Button9Click(Sender: TObject); |
882 | var |
835 | var |
883 | ini: TIniFile; |
836 | ini: TIniFile; |
884 | txtFile, asn1s: string; |
837 | txtFile, asn1s: string; |
885 | modified: boolean; |
838 | modified: boolean; |
886 | begin |
839 | begin |
887 | { Attention: Do not rely on Outline1.Items[Outline1.SelectedItem].Text, because Button9.Click |
840 | { Attention: Do not rely on Outline1.Items[Outline1.SelectedItem].Text, because Button9.Click |
888 | will be called in Outline1OnChange()! } |
841 | will be called in Outline1OnChange()! } |
889 | 842 | ||
890 | ini := TIniFile.Create(DBPath+'RA.INI'); |
843 | ini := TIniFile.Create(DBPath+'RA.INI'); |
891 | try |
844 | try |
892 | modified := false; |
845 | modified := false; |
893 | if ini.ReadString(Edit9.Text, 'name', '') <> Edit11.Text then |
846 | if ini.ReadString(Edit9.Text, 'name', '') <> Edit11.Text then |
894 | begin |
847 | begin |
895 | modified := true; |
848 | modified := true; |
896 | ini.WriteString(Edit9.Text, 'name', Edit11.Text); |
849 | ini.WriteString(Edit9.Text, 'name', Edit11.Text); |
897 | end; |
850 | end; |
898 | if ini.ReadString(Edit9.Text, 'email', '') <> Edit12.Text then |
851 | if ini.ReadString(Edit9.Text, 'email', '') <> Edit12.Text then |
899 | begin |
852 | begin |
900 | modified := true; |
853 | modified := true; |
901 | ini.WriteString(Edit9.Text, 'email', Edit12.Text); |
854 | ini.WriteString(Edit9.Text, 'email', Edit12.Text); |
902 | end; |
855 | end; |
903 | if ini.ReadString(Edit9.Text, 'phone', '') <> Edit13.Text then |
856 | if ini.ReadString(Edit9.Text, 'phone', '') <> Edit13.Text then |
904 | begin |
857 | begin |
905 | modified := true; |
858 | modified := true; |
906 | ini.WriteString(Edit9.Text, 'phone', Edit13.Text); |
859 | ini.WriteString(Edit9.Text, 'phone', Edit13.Text); |
907 | end; |
860 | end; |
908 | if modified then |
861 | if modified then |
909 | begin |
862 | begin |
910 | ini.WriteString(Edit9.Text, 'updatedate', DateToStr(Date)); |
863 | ini.WriteString(Edit9.Text, 'updatedate', DateToStr(Date)); |
911 | { ini.Updatefile; } |
864 | { ini.Updatefile; } |
912 | end; |
865 | end; |
913 | finally |
866 | finally |
914 | ini.Free; |
867 | ini.Free; |
915 | end; |
868 | end; |
916 | end; |
869 | end; |
917 | 870 | ||
918 | procedure TForm1.Edit8KeyPress(Sender: TObject; var Key: Char); |
871 | procedure TForm1.Edit8KeyPress(Sender: TObject; var Key: Char); |
919 | begin |
872 | begin |
920 | if Key = #13 then |
873 | if Key = #13 then |
921 | begin |
874 | begin |
922 | Button7.Click; |
875 | Button7.Click; |
923 | Key := #0; |
876 | Key := #0; |
924 | Exit; |
877 | Exit; |
925 | end; |
878 | end; |
926 | if Key = #8(*backspace*) then exit; |
879 | if Key = #8(*backspace*) then exit; |
927 | if Key in ['a'..'z'] then Key := UpCase(Key); |
880 | if Key in ['a'..'z'] then Key := UpCase(Key); |
928 | if not (Key in ['A'..'Z', '-']) then |
881 | if not (Key in ['A'..'Z', '-']) then |
929 | begin |
882 | begin |
930 | { Beep; TODO } |
883 | MessageBeep(0); |
931 | Key := #0; |
884 | Key := #0; |
932 | end; |
885 | end; |
933 | end; |
886 | end; |
934 | 887 | ||
935 | procedure TForm1.Edit11Change(Sender: TObject); |
888 | procedure TForm1.Edit11Change(Sender: TObject); |
936 | begin |
889 | begin |
937 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit9.Text + ' ' + Edit11.Text); |
890 | Outline1.Items[Outline1.SelectedItem].Text := Trim(Edit9.Text + ' ' + Edit11.Text); |
938 | end; |
891 | end; |
939 | 892 | ||
940 | procedure TForm1.ListBox1KeyDown(Sender: TObject; var Key: Word; |
893 | procedure TForm1.ListBox1KeyDown(Sender: TObject; var Key: Word; |
941 | Shift: TShiftState); |
894 | Shift: TShiftState); |
942 | begin |
895 | begin |
943 | If Key = 46(*DEL*) then |
896 | If Key = 46(*DEL*) then |
944 | begin |
897 | begin |
945 | Button3.Click; |
898 | Button3.Click; |
946 | Key := 0; |
899 | Key := 0; |
947 | end; |
900 | end; |
948 | end; |
901 | end; |
949 | 902 | ||
950 | procedure TForm1.Edit7KeyPress(Sender: TObject; var Key: Char); |
903 | procedure TForm1.Edit7KeyPress(Sender: TObject; var Key: Char); |
951 | begin |
904 | begin |
952 | if Key = #13 then |
905 | if Key = #13 then |
953 | begin |
906 | begin |
954 | Button1.Click; |
907 | Button1.Click; |
955 | Key := #0; |
908 | Key := #0; |
956 | end; |
909 | end; |
957 | end; |
910 | end; |
958 | 911 | ||
959 | procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); |
912 | procedure TForm1.Edit2KeyPress(Sender: TObject; var Key: Char); |
960 | begin |
913 | begin |
961 | if Key = #13 then |
914 | if Key = #13 then |
962 | begin |
915 | begin |
963 | Button5.Click; |
916 | Button5.Click; |
964 | Key := #0; |
917 | Key := #0; |
965 | end; |
918 | end; |
966 | end; |
919 | end; |
967 | 920 | ||
968 | procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); |
921 | procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); |
969 | begin |
922 | begin |
970 | if Key = #13 then |
923 | if Key = #13 then |
971 | begin |
924 | begin |
972 | Button4.Click; |
925 | Button4.Click; |
973 | Key := #0; |
926 | Key := #0; |
974 | end; |
927 | end; |
975 | end; |
928 | end; |
976 | 929 | ||
977 | procedure TForm1.Outline1KeyDown(Sender: TObject; var Key: Word; |
930 | procedure TForm1.Outline1KeyDown(Sender: TObject; var Key: Word; |
978 | Shift: TShiftState); |
931 | Shift: TShiftState); |
979 | begin |
932 | begin |
980 | if Key = 46(*DEL*) then |
933 | if Key = 46(*DEL*) then |
981 | begin |
934 | begin |
982 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 4) = 'OID:' then |
935 | if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 4) = 'OID:' then |
983 | begin |
936 | begin |
984 | Button6.Click; |
937 | Button6.Click; |
985 | end |
938 | end |
986 | else if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 3) = 'RA:' then |
939 | else if Copy(Outline1.Items[Outline1.SelectedItem].Text, 1, 3) = 'RA:' then |
987 | begin |
940 | begin |
988 | Button8.Click; |
941 | Button8.Click; |
989 | end |
942 | end |
990 | else |
943 | else |
991 | begin |
944 | begin |
992 | { Beep; TODO } |
945 | MessageBeep(0); |
993 | end; |
946 | end; |
994 | 947 | ||
995 | Key := 0; |
948 | Key := 0; |
996 | end; |
949 | end; |
997 | end; |
950 | end; |
998 | 951 | ||
999 | procedure TForm1.Outline1Click(Sender: TObject); |
952 | procedure TForm1.Outline1Click(Sender: TObject); |
1000 | begin |
953 | begin |
1001 | Outline1Change(Sender, Outline1.SelectedItem); |
954 | Outline1Change(Sender, Outline1.SelectedItem); |
1002 | end; |
955 | end; |
1003 | 956 | ||
1004 | end. |
957 | end. |
1005 | 958 |