source: tags/1.2.0/Forms/UFormGenerate.pas

Last change on this file was 69, checked in by chronos, 3 years ago
  • Added: Remember last count value used in Generate contact form.
File size: 1.9 KB
Line 
1unit UFormGenerate;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 Spin, UContact;
10
11type
12
13 { TFormGenerate }
14
15 TFormGenerate = class(TForm)
16 ButtonGenerate: TButton;
17 Label1: TLabel;
18 SpinEditCount: TSpinEdit;
19 procedure ButtonGenerateClick(Sender: TObject);
20 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
21 procedure FormCreate(Sender: TObject);
22 procedure FormShow(Sender: TObject);
23 public
24 Contacts: TContacts;
25 procedure UpdateInterface;
26 end;
27
28var
29 FormGenerate: TFormGenerate;
30
31
32implementation
33
34{$R *.lfm}
35
36uses
37 UCore;
38
39{ TFormGenerate }
40
41procedure TFormGenerate.ButtonGenerateClick(Sender: TObject);
42var
43 I: Integer;
44 Contact: TContact;
45begin
46 for I := 1 to SpinEditCount.Value do begin
47 Contact := Contacts.AddNew;
48 Contact.Fields[cfVersion] := '2.1';
49 Contact.Fields[cfFirstName] := 'First ' + IntToStr(Random(10000));
50 Contact.Fields[cfLastName] := 'Last ' + IntToStr(Random(10000));
51 Contact.Fields[cfFullName] := 'FullName ' + IntToStr(Random(100));
52 Contact.Fields[cfTelCell] := IntToStr(Random(1000000000));
53 Contact.Fields[cfTelHome] := IntToStr(Random(1000000000));
54 end;
55 Close;
56end;
57
58procedure TFormGenerate.FormClose(Sender: TObject; var CloseAction: TCloseAction
59 );
60begin
61 Core.GenerateCount := SpinEditCount.Value;
62 Core.PersistentForm1.Save(Self);
63end;
64
65procedure TFormGenerate.FormCreate(Sender: TObject);
66begin
67 Core.Translator.TranslateComponentRecursive(Self);
68 Core.ThemeManager1.UseTheme(Self);
69end;
70
71procedure TFormGenerate.FormShow(Sender: TObject);
72begin
73 Core.PersistentForm1.Load(Self);
74 SpinEditCount.Value := Core.GenerateCount;
75 UpdateInterface;
76end;
77
78procedure TFormGenerate.UpdateInterface;
79begin
80 ButtonGenerate.Enabled := Assigned(Contacts);
81end;
82
83end.
84
Note: See TracBrowser for help on using the repository browser.