1 | unit UFormAcronym;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
|
---|
9 | StdCtrls, ActnList, UAcronym;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TFormAcronym }
|
---|
14 |
|
---|
15 | TFormAcronym = class(TForm)
|
---|
16 | ACategoryRemove: TAction;
|
---|
17 | ACategoryAdd: TAction;
|
---|
18 | ActionList1: TActionList;
|
---|
19 | Button1: TButton;
|
---|
20 | Button2: TButton;
|
---|
21 | ButtonOk: TButton;
|
---|
22 | ButtonCancel: TButton;
|
---|
23 | EditAcronym: TEdit;
|
---|
24 | EditMeaning: TEdit;
|
---|
25 | Label1: TLabel;
|
---|
26 | Label2: TLabel;
|
---|
27 | Label3: TLabel;
|
---|
28 | Label4: TLabel;
|
---|
29 | Label5: TLabel;
|
---|
30 | ListBoxCategories: TListBox;
|
---|
31 | ListBoxImportSources: TListBox;
|
---|
32 | MemoDescription: TMemo;
|
---|
33 | MenuItem1: TMenuItem;
|
---|
34 | MenuItem2: TMenuItem;
|
---|
35 | PopupMenuCategory: TPopupMenu;
|
---|
36 | procedure ACategoryAddExecute(Sender: TObject);
|
---|
37 | procedure ACategoryRemoveExecute(Sender: TObject);
|
---|
38 | procedure EditMeaningKeyPress(Sender: TObject; var Key: char);
|
---|
39 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
40 | procedure FormCreate(Sender: TObject);
|
---|
41 | procedure FormShow(Sender: TObject);
|
---|
42 | procedure ListBoxCategoriesSelectionChange(Sender: TObject; User: boolean);
|
---|
43 | private
|
---|
44 | procedure UpdateInterface;
|
---|
45 | public
|
---|
46 | procedure Load(Entry: TAcronymEntry);
|
---|
47 | procedure Save(Entry: TAcronymEntry);
|
---|
48 | end;
|
---|
49 |
|
---|
50 | var
|
---|
51 | FormAcronym: TFormAcronym;
|
---|
52 |
|
---|
53 | implementation
|
---|
54 |
|
---|
55 | {$R *.lfm}
|
---|
56 |
|
---|
57 | uses
|
---|
58 | UCore, UFormCategorySelect;
|
---|
59 |
|
---|
60 | { TFormAcronym }
|
---|
61 |
|
---|
62 | procedure TFormAcronym.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
63 | );
|
---|
64 | begin
|
---|
65 | Core.PersistentForm1.Save(Self);
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TFormAcronym.FormCreate(Sender: TObject);
|
---|
69 | begin
|
---|
70 | Core.CoolTranslator1.TranslateComponentRecursive(Self);
|
---|
71 | Core.ThemeManager.UseTheme(Self);
|
---|
72 | end;
|
---|
73 |
|
---|
74 | procedure TFormAcronym.ACategoryAddExecute(Sender: TObject);
|
---|
75 | var
|
---|
76 | I: Integer;
|
---|
77 | begin
|
---|
78 | FormCategorySelect := TFormCategorySelect.Create(Self);
|
---|
79 | try
|
---|
80 | FormCategorySelect.Load(ListBoxCategories.Items);
|
---|
81 | if FormCategorySelect.ShowModal = mrOk then begin
|
---|
82 | for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
|
---|
83 | if FormCategorySelect.ListBox1.Selected[I] then begin
|
---|
84 | ListBoxCategories.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
|
---|
85 | end;
|
---|
86 | end;
|
---|
87 | finally
|
---|
88 | FreeAndNil(FormCategorySelect);
|
---|
89 | end;
|
---|
90 | end;
|
---|
91 |
|
---|
92 | procedure TFormAcronym.ACategoryRemoveExecute(Sender: TObject);
|
---|
93 | var
|
---|
94 | I: Integer;
|
---|
95 | begin
|
---|
96 | if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
|
---|
97 | TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
|
---|
98 | for I := ListBoxCategories.Items.Count - 1 downto 0 do
|
---|
99 | if ListBoxCategories.Selected[I] then
|
---|
100 | ListBoxCategories.Items.Delete(I);
|
---|
101 | UpdateInterface;
|
---|
102 | end;
|
---|
103 | end;
|
---|
104 |
|
---|
105 | procedure TFormAcronym.EditMeaningKeyPress(Sender: TObject; var Key: char);
|
---|
106 | begin
|
---|
107 | if Ord(Key) = 13 then ButtonOk.Click;
|
---|
108 | if Ord(Key) = 27 then ButtonCancel.Click;
|
---|
109 | end;
|
---|
110 |
|
---|
111 | procedure TFormAcronym.FormShow(Sender: TObject);
|
---|
112 | begin
|
---|
113 | Core.PersistentForm1.Load(Self);
|
---|
114 | UpdateInterface;
|
---|
115 | end;
|
---|
116 |
|
---|
117 | procedure TFormAcronym.ListBoxCategoriesSelectionChange(Sender: TObject; User: boolean);
|
---|
118 | begin
|
---|
119 | UpdateInterface;
|
---|
120 | end;
|
---|
121 |
|
---|
122 | procedure TFormAcronym.UpdateInterface;
|
---|
123 | begin
|
---|
124 | ACategoryRemove.Enabled := ListBoxCategories.ItemIndex <> -1;
|
---|
125 | end;
|
---|
126 |
|
---|
127 | procedure TFormAcronym.Load(Entry: TAcronymEntry);
|
---|
128 | begin
|
---|
129 | EditAcronym.Text := Entry.Name;
|
---|
130 | EditMeaning.Text := Entry.Meaning;
|
---|
131 | MemoDescription.Text := Entry.Description;
|
---|
132 | ListBoxCategories.Items.Assign(Entry.Categories);
|
---|
133 | ListBoxImportSources.Items.Assign(Entry.Sources);
|
---|
134 | end;
|
---|
135 |
|
---|
136 | procedure TFormAcronym.Save(Entry: TAcronymEntry);
|
---|
137 | begin
|
---|
138 | Entry.Name := EditAcronym.Text;
|
---|
139 | Entry.Meaning := EditMeaning.Text;
|
---|
140 | Entry.Description := MemoDescription.Text;
|
---|
141 | Entry.Categories.Assign(ListBoxCategories.Items);
|
---|
142 | end;
|
---|
143 |
|
---|
144 | end.
|
---|
145 |
|
---|