1 | unit UFormNewFile;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | ComCtrls;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormNewFile }
|
---|
14 |
|
---|
15 | TFormNewFile = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | ListView1: TListView;
|
---|
19 | procedure FormShow(Sender: TObject);
|
---|
20 | procedure ListView1Change(Sender: TObject; Item: TListItem;
|
---|
21 | Change: TItemChange);
|
---|
22 | procedure ListView1DblClick(Sender: TObject);
|
---|
23 | procedure ListView1KeyPress(Sender: TObject; var Key: char);
|
---|
24 | procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
|
---|
25 | Selected: Boolean);
|
---|
26 | private
|
---|
27 | { private declarations }
|
---|
28 | public
|
---|
29 | procedure UpdateInterface;
|
---|
30 | end;
|
---|
31 |
|
---|
32 | var
|
---|
33 | FormNewFile: TFormNewFile;
|
---|
34 |
|
---|
35 |
|
---|
36 | implementation
|
---|
37 |
|
---|
38 | uses
|
---|
39 | UDataModule, UFormMain, USource;
|
---|
40 |
|
---|
41 | {$R *.lfm}
|
---|
42 |
|
---|
43 | { TFormNewFile }
|
---|
44 |
|
---|
45 | procedure TFormNewFile.FormShow(Sender: TObject);
|
---|
46 | begin
|
---|
47 | UpdateInterface;
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TFormNewFile.ListView1Change(Sender: TObject; Item: TListItem;
|
---|
51 | Change: TItemChange);
|
---|
52 | begin
|
---|
53 |
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TFormNewFile.ListView1DblClick(Sender: TObject);
|
---|
57 | begin
|
---|
58 | ButtonOk.Click;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TFormNewFile.ListView1KeyPress(Sender: TObject; var Key: char);
|
---|
62 | begin
|
---|
63 | if (Key = #13) and Assigned(ListView1.Selected) then ButtonOk.Click;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormNewFile.ListView1SelectItem(Sender: TObject; Item: TListItem;
|
---|
67 | Selected: Boolean);
|
---|
68 | begin
|
---|
69 | ButtonOk.Enabled := Assigned(ListView1.Selected);
|
---|
70 | end;
|
---|
71 |
|
---|
72 | procedure TFormNewFile.UpdateInterface;
|
---|
73 | var
|
---|
74 | NewItem: TListItem;
|
---|
75 | I: Integer;
|
---|
76 | begin
|
---|
77 | try
|
---|
78 | ListView1.BeginUpdate;
|
---|
79 | ListView1.Items.Clear;
|
---|
80 | with DataModule1 do
|
---|
81 | for I := 0 to FileTemplates.Count - 1 do
|
---|
82 | with TFileTemplate(FileTemplates[I]) do begin
|
---|
83 | //if (not Assigned(Core.Project) and IsProject) or Assigned(Core.Project) then begin
|
---|
84 | NewItem := ListView1.Items.Add;
|
---|
85 | NewItem.Caption := Name;
|
---|
86 | NewItem.Data := FileTemplates[I];
|
---|
87 | end;
|
---|
88 | if ListView1.Items.Count > 0 then
|
---|
89 | ListView1.Selected := ListView1.Items[0];
|
---|
90 | finally
|
---|
91 | ListView1.EndUpdate;
|
---|
92 | end;
|
---|
93 | end;
|
---|
94 |
|
---|
95 | end.
|
---|
96 |
|
---|