source: branches/generator/UCore.pas

Last change on this file was 191, checked in by chronos, 5 years ago
  • Added: Interface language selection in Settings dialog.
File size: 1.9 KB
Line 
1unit UCore;
2
3{$mode delphi}{$H+}
4
5interface
6
7uses
8 Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, UGrammer,
9 UPersistentForm, ULastOpenedList, UApplicationInfo, UCoolTranslator;
10
11type
12
13 { TCore }
14
15 TCore = class(TDataModule)
16 ApplicationInfo1: TApplicationInfo;
17 CoolTranslator1: TCoolTranslator;
18 ImageList1: TImageList;
19 PersistentForm1: TPersistentForm;
20 XMLConfig1: TXMLConfig;
21 procedure DataModuleCreate(Sender: TObject);
22 procedure DataModuleDestroy(Sender: TObject);
23 private
24 { private declarations }
25 public
26 ReopenLastFile: Boolean;
27 Grammer: TGrammer;
28 procedure LoadConfig;
29 procedure SaveConfig;
30 procedure Initialize;
31 procedure Finalize;
32 end;
33
34var
35 Core: TCore;
36
37implementation
38
39{$R *.lfm}
40
41uses
42 UFormMain;
43
44{ TCore }
45
46procedure TCore.DataModuleCreate(Sender: TObject);
47begin
48 ForceDirectories(GetAppConfigDir(False));
49 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
50end;
51
52procedure TCore.DataModuleDestroy(Sender: TObject);
53begin
54end;
55
56procedure TCore.LoadConfig;
57begin
58 with XMLConfig1 do begin
59 ReopenLastFile := GetValue('ReopenLastFile', True);
60 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(String(GetValue('Language', '')));
61 end;
62end;
63
64procedure TCore.SaveConfig;
65begin
66 with XMLConfig1 do begin
67 SetValue('ReopenLastFile', ReopenLastFile);
68 SetValue('Language', WideString(CoolTranslator1.Language.Code));
69 Flush;
70 end;
71end;
72
73procedure TCore.Initialize;
74begin
75 PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;
76 LoadConfig;
77 FormMain.LoadConfig(XMLConfig1);
78 if ReopenLastFile and FileExists(FormMain.LastOpenedList1.GetFirstFileName) then
79 FormMain.ProjectOpen(FormMain.LastOpenedList1.GetFirstFileName)
80 else FormMain.AProjectNew.Execute;
81end;
82
83procedure TCore.Finalize;
84begin
85 FormMain.SaveConfig(XMLConfig1);
86 SaveConfig;
87end;
88
89end.
90
Note: See TracBrowser for help on using the repository browser.