source: tags/1.4.0/Forms/UFormGenerate.pas

Last change on this file was 129, checked in by chronos, 2 years ago
  • Added: TVCard as TComponent descendant.
  • Modified: TContactsFile renamed to TVCardFile and moved into separate file.
File size: 2.3 KB
Line 
1unit UFormGenerate;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Spin, UVCard;
8
9type
10
11 { TFormGenerate }
12
13 TFormGenerate = class(TForm)
14 ButtonGenerate: TButton;
15 Label1: TLabel;
16 SpinEditCount: TSpinEdit;
17 procedure ButtonGenerateClick(Sender: TObject);
18 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
19 procedure FormCreate(Sender: TObject);
20 procedure FormShow(Sender: TObject);
21 public
22 Contacts: TContacts;
23 procedure UpdateInterface;
24 end;
25
26var
27 FormGenerate: TFormGenerate;
28
29
30implementation
31
32{$R *.lfm}
33
34uses
35 UCore;
36
37{ TFormGenerate }
38
39procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
40var
41 I: Integer;
42 Contact: TContact;
43begin
44 for I := 1 to SpinEditCount.Value do begin
45 Contact := Contacts.AddNew;
46 with Contact do begin
47 Fields[cfVersion] := Core.DefaultVcardVersion;
48 Fields[cfFirstName] := 'First ' + IntToStr(Random(10000));
49 Fields[cfLastName] := 'Last ' + IntToStr(Random(10000));
50 Fields[cfFullName] := 'FullName ' + IntToStr(Random(100));
51 Fields[cfTelCell] := IntToStr(Random(1000000000));
52 Fields[cfTelHome] := IntToStr(Random(1000000000));
53 Fields[cfTelWork] := IntToStr(Random(1000000000));
54 Fields[cfNote] := 'Some contact notes';
55 Fields[cfEmail] := 'user@email.com';
56 Fields[cfEmailHome] := 'home@email.com';
57 Fields[cfEmailWork] := 'home@email.com';
58 Fields[cfUrl] := 'https://url.com';
59 Fields[cfUrlWork] := 'https://work.com';
60 Fields[cfUrlHome] := 'https://home.com';
61 end;
62 end;
63 Close;
64 ModalResult := mrOk;
65end;
66
67procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
68 );
69begin
70 Core.GenerateCount := SpinEditCount.Value;
71 Core.PersistentForm1.Save(Self);
72end;
73
74procedure TFormGenerate.FormCreate(Sender: TObject);
75begin
76 Core.Translator.TranslateComponentRecursive(Self);
77 Core.ThemeManager1.UseTheme(Self);
78end;
79
80procedure TFormGenerate.FormShow(Sender: TObject);
81begin
82 Core.PersistentForm1.Load(Self);
83 SpinEditCount.Value := Core.GenerateCount;
84 UpdateInterface;
85end;
86
87procedure TFormGenerate.UpdateInterface;
88begin
89 ButtonGenerate.Enabled := Assigned(Contacts);
90end;
91
92end.
93
Note: See TracBrowser for help on using the repository browser.