source: trunk/StudioPackage/Forms/UFormNewFile.pas

Last change on this file was 15, checked in by chronos, 12 years ago
  • Added: Registration of new file templates for modules.
  • Added: Program stores last opened file list in registry.
File size: 2.1 KB
Line 
1unit UFormNewFile;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 ComCtrls;
10
11type
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
32var
33 FormNewFile: TFormNewFile;
34
35
36implementation
37
38uses
39 UDataModule, UFormMain, USource;
40
41{$R *.lfm}
42
43{ TFormNewFile }
44
45procedure TFormNewFile.FormShow(Sender: TObject);
46begin
47 UpdateInterface;
48end;
49
50procedure TFormNewFile.ListView1Change(Sender: TObject; Item: TListItem;
51 Change: TItemChange);
52begin
53
54end;
55
56procedure TFormNewFile.ListView1DblClick(Sender: TObject);
57begin
58 ButtonOk.Click;
59end;
60
61procedure TFormNewFile.ListView1KeyPress(Sender: TObject; var Key: char);
62begin
63 if (Key = #13) and Assigned(ListView1.Selected) then ButtonOk.Click;
64end;
65
66procedure TFormNewFile.ListView1SelectItem(Sender: TObject; Item: TListItem;
67 Selected: Boolean);
68begin
69 ButtonOk.Enabled := Assigned(ListView1.Selected);
70end;
71
72procedure TFormNewFile.UpdateInterface;
73var
74 NewItem: TListItem;
75 I: Integer;
76begin
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;
93end;
94
95end.
96
Note: See TracBrowser for help on using the repository browser.