| 1 | unit FormGenerate;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 7 | Spin, VCard, FormEx;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 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 |
|
|---|
| 26 | implementation
|
|---|
| 27 |
|
|---|
| 28 | {$R *.lfm}
|
|---|
| 29 |
|
|---|
| 30 | uses
|
|---|
| 31 | Core;
|
|---|
| 32 |
|
|---|
| 33 | const
|
|---|
| 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 |
|
|---|
| 62 | procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
|
|---|
| 63 | var
|
|---|
| 64 | I: Integer;
|
|---|
| 65 | Contact: TContact;
|
|---|
| 66 | begin
|
|---|
| 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;
|
|---|
| 88 | end;
|
|---|
| 89 |
|
|---|
| 90 | procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
|---|
| 91 | );
|
|---|
| 92 | begin
|
|---|
| 93 | Core.Core.GenerateCount := SpinEditCount.Value;
|
|---|
| 94 | end;
|
|---|
| 95 |
|
|---|
| 96 | procedure TFormGenerate.FormShow(Sender: TObject);
|
|---|
| 97 | begin
|
|---|
| 98 | SpinEditCount.Value := Core.Core.GenerateCount;
|
|---|
| 99 | UpdateInterface;
|
|---|
| 100 | end;
|
|---|
| 101 |
|
|---|
| 102 | procedure TFormGenerate.UpdateInterface;
|
|---|
| 103 | begin
|
|---|
| 104 | ButtonGenerate.Enabled := Assigned(Contacts);
|
|---|
| 105 | end;
|
|---|
| 106 |
|
|---|
| 107 | end.
|
|---|
| 108 |
|
|---|