source: trunk/Forms/FormGenerate.pas

Last change on this file was 162, checked in by chronos, 17 months ago
  • Modified: Updated Common package.
File size: 3.8 KB
Line 
1unit FormGenerate;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Spin, VCard, FormEx;
8
9type
10
11 { TFormGenerate }
12
13 TFormGenerate = class(TFormEx)
14 ButtonGenerate: TButton;
15 Label1: TLabel;
16 SpinEditCount: TSpinEdit;
17 procedure ButtonGenerateClick(Sender: TObject);
18 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
19 procedure FormShow(Sender: TObject);
20 public
21 Contacts: TContacts;
22 procedure UpdateInterface;
23 end;
24
25
26implementation
27
28{$R *.lfm}
29
30uses
31 Core;
32
33const
34 Names: array[0..100] of string = ('Peter', 'Susan', 'Luis', 'Jane', 'Bill', 'Jeniffer',
35 'Leo', 'Veronica', 'Stephan', 'Adele', 'Elvis', 'Caroline', 'John', 'Elisabeth',
36 'Joseph', 'Michaele', 'Bruce', 'Eva', 'Samuel', 'Olivie', 'Fred', 'Maria',
37 'Jose', 'David', 'Michael', 'Anna', 'Mary', 'Juan', 'Robert', 'Daniel', 'James',
38 'Richard', 'Paul', 'Olga', 'William', 'Sergey', 'Anita', 'Victor', 'Sarah',
39 'Mark', 'Rita', 'Martin', 'Patrick', 'Andrea', 'Vladimir', 'Barbara', 'Angela',
40 'Ivan', 'Jesus', 'Marian', 'Eric', 'Diana', 'Claudia', 'Gloria', 'Teresa',
41 'Francis', 'Andrew', 'Eduardo', 'Steven', 'Karen', 'Brian', 'Monica', 'Sonia',
42 'Alberto', 'Alex', 'Julio', 'Juana', 'Adam', 'Kevin', 'Edward', 'Roland',
43 'Cheng', 'Roman', 'Silvia', 'Marta', 'Lisa', 'Alice', 'Felix', 'Jan', 'Lucia',
44 'Janet', 'Sharon', 'Paula', 'Helen', 'Anton', 'Henry', 'Antonia', 'Adriana',
45 'Brenda', 'Nicole', 'Tatina', 'Gary', 'Dennis', 'Isaac', 'Luiz', 'Erika',
46 'Amanda', 'Donald', 'Edgar', 'Ruben', 'Jason');
47
48 LastNames: array[0..80] of string = ('Gates', 'Simmons', 'Eliott', 'Onion',
49 'Presleys', 'Clinton', 'Dell', 'Ford', 'Miles', 'Young', 'Newton', 'Smith',
50 'Williams', 'Johnson', 'Brown', 'Jones', 'Garcia', 'Miller', 'Davis',
51 'Lopez', 'Wilson', 'Taylor', 'Moore', 'Jackson', 'Lee', 'White', 'Lewis',
52 'Robinson', 'Walker', 'King', 'Wright', 'Scott', 'Torres', 'Green',
53 'Adams', 'Nelson', 'Baker', 'Hall', 'Rivera', 'Carter', 'Evans', 'Diaz',
54 'Collins', 'Edwards', 'Stewart', 'Murphy', 'Cook', 'Ortiz', 'Morgan', 'Cooper',
55 'Peterson', 'Reed', 'Kim', 'Watson', 'Brooks', 'Wood', 'James', 'Gray',
56 'Hughes', 'Long', 'Powell', 'Jenkins', 'Perry', 'Bell', 'Butler', 'Romero',
57 'Jordan', 'Hamilton', 'Moreno', 'West', 'Cole', 'Hayes', 'Gibson', 'Medina',
58 'Owens', 'Harrison', 'Woods', 'Wells', 'Chen', 'Webb', 'Tucker');
59
60{ TFormGenerate }
61
62procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
63var
64 I: Integer;
65 Contact: TContact;
66begin
67 for I := 1 to SpinEditCount.Value do begin
68 Contact := Contacts.AddNew;
69 with Contact do begin
70 Fields[cfVersion] := Core.Core.DefaultVcardVersion;
71 Fields[cfFirstName] := Names[Random(Length(Names))];
72 Fields[cfLastName] := LastNames[Random(Length(LastNames))];
73 Fields[cfFullName] := Fields[cfFirstName] + ' ' +Fields[cfLastName];
74 Fields[cfTelCell] := IntToStr(Random(1000000000));
75 Fields[cfTelHome] := IntToStr(Random(1000000000));
76 Fields[cfTelWork] := IntToStr(Random(1000000000));
77 Fields[cfNote] := 'Some contact notes';
78 Fields[cfEmail] := LowerCase(Fields[cfFirstName] + '.' + Fields[cfLastName]) + '@email.com';
79 Fields[cfEmailHome] := Fields[cfEmail];
80 Fields[cfEmailWork] := Fields[cfEmail];
81 Fields[cfUrl] := 'https://url.com';
82 Fields[cfUrlWork] := 'https://work.com';
83 Fields[cfUrlHome] := 'https://home.com';
84 end;
85 end;
86 Close;
87 ModalResult := mrOk;
88end;
89
90procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
91 );
92begin
93 Core.Core.GenerateCount := SpinEditCount.Value;
94end;
95
96procedure TFormGenerate.FormShow(Sender: TObject);
97begin
98 SpinEditCount.Value := Core.Core.GenerateCount;
99 UpdateInterface;
100end;
101
102procedure TFormGenerate.UpdateInterface;
103begin
104 ButtonGenerate.Enabled := Assigned(Contacts);
105end;
106
107end.
108
Note: See TracBrowser for help on using the repository browser.