1 | unit UFormGenerate;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
7 | Spin, UVCard;
|
---|
8 |
|
---|
9 | type
|
---|
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 |
|
---|
26 | var
|
---|
27 | FormGenerate: TFormGenerate;
|
---|
28 |
|
---|
29 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | {$R *.lfm}
|
---|
33 |
|
---|
34 | uses
|
---|
35 | UCore;
|
---|
36 |
|
---|
37 | { TFormGenerate }
|
---|
38 |
|
---|
39 | procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
|
---|
40 | var
|
---|
41 | I: Integer;
|
---|
42 | Contact: TContact;
|
---|
43 | begin
|
---|
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;
|
---|
65 | end;
|
---|
66 |
|
---|
67 | procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
68 | );
|
---|
69 | begin
|
---|
70 | Core.GenerateCount := SpinEditCount.Value;
|
---|
71 | Core.PersistentForm1.Save(Self);
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormGenerate.FormCreate(Sender: TObject);
|
---|
75 | begin
|
---|
76 | Core.Translator.TranslateComponentRecursive(Self);
|
---|
77 | Core.ThemeManager1.UseTheme(Self);
|
---|
78 | end;
|
---|
79 |
|
---|
80 | procedure TFormGenerate.FormShow(Sender: TObject);
|
---|
81 | begin
|
---|
82 | Core.PersistentForm1.Load(Self);
|
---|
83 | SpinEditCount.Value := Core.GenerateCount;
|
---|
84 | UpdateInterface;
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TFormGenerate.UpdateInterface;
|
---|
88 | begin
|
---|
89 | ButtonGenerate.Enabled := Assigned(Contacts);
|
---|
90 | end;
|
---|
91 |
|
---|
92 | end.
|
---|
93 |
|
---|