source: tags/1.1.0/Forms/UFormAcronym.pas

Last change on this file was 33, checked in by chronos, 8 years ago
  • Added: Now import sources have categories which are merged to new imported acronym meanings.
File size: 3.2 KB
Line 
1unit UFormAcronym;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Menus,
9 StdCtrls, ActnList, UAcronym;
10
11type
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 ListBox1: TListBox;
30 MemoDescription: TMemo;
31 MenuItem1: TMenuItem;
32 MenuItem2: TMenuItem;
33 PopupMenuCategory: TPopupMenu;
34 procedure ACategoryAddExecute(Sender: TObject);
35 procedure ACategoryRemoveExecute(Sender: TObject);
36 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
37 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
38 procedure FormShow(Sender: TObject);
39 procedure ListBox1SelectionChange(Sender: TObject; User: boolean);
40 private
41 procedure UpdateInterface;
42 public
43 procedure Load(Entry: TAcronymEntry);
44 procedure Save(Entry: TAcronymEntry);
45 end;
46
47var
48 FormAcronym: TFormAcronym;
49
50implementation
51
52{$R *.lfm}
53
54uses
55 UFormMain, UFormCategorySelect;
56
57{ TFormAcronym }
58
59procedure TFormAcronym.FormKeyUp(Sender: TObject; var Key: Word;
60 Shift: TShiftState);
61begin
62 if Key = 13 then ButtonOk.Click;
63 if Key = 27 then ButtonCancel.Click;
64end;
65
66procedure TFormAcronym.FormClose(Sender: TObject; var CloseAction: TCloseAction
67 );
68begin
69 FormMain.PersistentForm1.Save(Self);
70end;
71
72procedure TFormAcronym.ACategoryAddExecute(Sender: TObject);
73var
74 I: Integer;
75begin
76 FormCategorySelect.Load(ListBox1.Items);
77 if FormCategorySelect.ShowModal = mrOk then begin
78 for I := 0 to FormCategorySelect.ListBox1.Count - 1 do
79 if FormCategorySelect.ListBox1.Selected[I] then begin
80 ListBox1.Items.AddObject(FormCategorySelect.ListBox1.Items[I], FormCategorySelect.ListBox1.Items.Objects[I]);
81 end;
82 end;
83end;
84
85procedure TFormAcronym.ACategoryRemoveExecute(Sender: TObject);
86var
87 I: Integer;
88begin
89 if MessageDlg(SRemoveCategory, SRemoveCategoryQuery,
90 TMsgDlgType.mtConfirmation, [mbCancel, mbOk], 0) = mrOk then begin
91 for I := ListBox1.Items.Count - 1 downto 0 do
92 if ListBox1.Selected[I] then
93 ListBox1.Items.Delete(I);
94 UpdateInterface;
95 end;
96end;
97
98procedure TFormAcronym.FormShow(Sender: TObject);
99begin
100 FormMain.PersistentForm1.Load(Self);
101 UpdateInterface;
102end;
103
104procedure TFormAcronym.ListBox1SelectionChange(Sender: TObject; User: boolean);
105begin
106 UpdateInterface;
107end;
108
109procedure TFormAcronym.UpdateInterface;
110begin
111 ACategoryRemove.Enabled := ListBox1.ItemIndex <> -1;
112end;
113
114procedure TFormAcronym.Load(Entry: TAcronymEntry);
115begin
116 EditAcronym.Text := Entry.Name;
117 EditMeaning.Text := Entry.Meaning;
118 MemoDescription.Text := Entry.Description;
119 ListBox1.Items.Assign(Entry.Categories);
120end;
121
122procedure TFormAcronym.Save(Entry: TAcronymEntry);
123begin
124 Entry.Name := EditAcronym.Text;
125 Entry.Meaning := EditMeaning.Text;
126 Entry.Description := MemoDescription.Text;
127 Entry.Categories.Assign(ListBox1.Items);
128end;
129
130end.
131
Note: See TracBrowser for help on using the repository browser.