-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefineNewSymbol.pas
93 lines (76 loc) · 2.09 KB
/
DefineNewSymbol.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
unit DefineNewSymbol;
interface
uses
Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TNewSymbol = class(TForm)
SymbolNameText: TEdit;
Label1: TLabel;
Label2: TLabel;
GroupNameList: TComboBox;
Label3: TLabel;
btnOK: TButton;
btnCancel: TButton;
chkFavorites: TCheckBox;
SymbolCommentsText: TMemo;
procedure FormShow(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure btnCancelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
NewSymbol: TNewSymbol;
implementation
uses SymbolLib,SymbolFile,MapObject, Main, LocalizedStrings;
{$R *.dfm}
var lastGroup:integer;
lastComments:string;
procedure TNewSymbol.FormShow(Sender: TObject);
begin
GroupNameList.Items := MainForm.SymbolGroupList.Items;
if (GroupNameList.Items.Count=0) then begin
ShowMessage(res_defsymbol_group);
Hide;
exit;
end;
if (lastGroup>GroupNameList.Items.Count) then lastgroup:=0;
GroupNameList.ItemIndex := lastGroup;
SymbolNameText.Text:='';
SymbolCommentsText.Text := LastComments;
SymbolNameText.SetFocus;
end;
procedure TNewSymbol.btnOKClick(Sender: TObject);
var grp:SymbolGroup;
sym:Symbol;
begin
if (GroupNameList.ItemIndex<>-1) then begin
lastgroup:=GroupNameList.ItemIndex;
LastComments:=NewSymbol.SymbolCommentsText.Text;
grp := SymbolGroup(GroupNameList.Items.Objects[lastgroup]);
sym := Symbol.Create;
sym.Name := NewSymbol.SymbolNameText.Text;
sym.Objects := Map.GetSelectedObjects(MainForm);
sym.Comments := NewSymbol.SymbolCommentsText.Text;
sym.Favorite := NewSymbol.chkFavorites.Checked;
grp.AddSymbol(sym);
// Refresh the current group's cached icons so we recreate the new symbol.
MainForm.SymbolGroupListClick(self);
// Make sure it appears in the symbol library tree
SymbolLibraryForm.RefreshTree;
Hide;
end
else begin
ShowMessage(res_defsymbol_group_sel);
end;
end;
procedure TNewSymbol.btnCancelClick(Sender: TObject);
begin
Hide;
end;
begin
lastGroup:=0;
end.