1 | unit UFormCategorySelect;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | UAcronym;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormCategorySelect }
|
---|
14 |
|
---|
15 | TFormCategorySelect = class(TForm)
|
---|
16 | ButtonOk: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | ListBox1: TListBox;
|
---|
19 | procedure FormCreate(Sender: TObject);
|
---|
20 | procedure FormShow(Sender: TObject);
|
---|
21 | procedure ListBox1DblClick(Sender: TObject);
|
---|
22 | procedure ListBox1KeyPress(Sender: TObject; var Key: char);
|
---|
23 | private
|
---|
24 | { private declarations }
|
---|
25 | public
|
---|
26 | procedure Load(RemoveItems: TStrings);
|
---|
27 | end;
|
---|
28 |
|
---|
29 | var
|
---|
30 | FormCategorySelect: TFormCategorySelect;
|
---|
31 |
|
---|
32 | resourcestring
|
---|
33 | SCategory = 'Category';
|
---|
34 | SRemoveCategory = 'Remove categories';
|
---|
35 | SRemoveCategoryQuery = 'Do you really want to remove selected categories?';
|
---|
36 |
|
---|
37 | implementation
|
---|
38 |
|
---|
39 | {$R *.lfm}
|
---|
40 |
|
---|
41 | uses
|
---|
42 | UCore;
|
---|
43 |
|
---|
44 | { TFormCategorySelect }
|
---|
45 |
|
---|
46 | procedure TFormCategorySelect.FormShow(Sender: TObject);
|
---|
47 | begin
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TFormCategorySelect.FormCreate(Sender: TObject);
|
---|
51 | begin
|
---|
52 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
---|
53 | Core.ThemeManager.UseTheme(Self);
|
---|
54 | end;
|
---|
55 |
|
---|
56 | procedure TFormCategorySelect.ListBox1DblClick(Sender: TObject);
|
---|
57 | begin
|
---|
58 | ButtonOk.Click;
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TFormCategorySelect.ListBox1KeyPress(Sender: TObject; var Key: char);
|
---|
62 | begin
|
---|
63 | if Key = #13 then ButtonOk.Click;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormCategorySelect.Load(RemoveItems: TStrings);
|
---|
67 | var
|
---|
68 | Index: Integer;
|
---|
69 | I: Integer;
|
---|
70 | begin
|
---|
71 | with Core.AcronymDb do begin
|
---|
72 | ListBox1.Sorted := False;
|
---|
73 | while ListBox1.Items.Count < Categories.Count do
|
---|
74 | ListBox1.Items.Add('');
|
---|
75 | while ListBox1.Items.Count > Categories.Count do
|
---|
76 | ListBox1.Items.Delete(ListBox1.Items.Count - 1);
|
---|
77 | for I := 0 to Categories.Count - 1 do begin
|
---|
78 | ListBox1.Items.Strings[I] := TAcronymCategory(Categories[I]).Name;
|
---|
79 | ListBox1.Items.Objects[I] := Categories[I];
|
---|
80 | ListBox1.Selected[I] := False;
|
---|
81 | end;
|
---|
82 | ListBox1.Sorted := True;
|
---|
83 | for I := 0 to RemoveItems.Count - 1 do begin
|
---|
84 | Index := ListBox1.Items.IndexOf(RemoveItems[I]);
|
---|
85 | if Index <> -1 then ListBox1.Items.Delete(Index);
|
---|
86 | end;
|
---|
87 | end;
|
---|
88 | end;
|
---|
89 |
|
---|
90 | end.
|
---|
91 |
|
---|