Changeset 126 for branches/generator/UCore.pas
- Timestamp:
- Nov 30, 2017, 12:02:32 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/UCore.pas
r118 r126 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, Controls, ActnList, URules, UPersistentForm; 8 Classes, SysUtils, XMLConf, FileUtil, Controls, ActnList, URules, DOM, 9 UPersistentForm; 9 10 10 11 type … … 15 16 ImageList1: TImageList; 16 17 PersistentForm1: TPersistentForm; 18 XMLConfig1: TXMLConfig; 17 19 procedure DataModuleCreate(Sender: TObject); 18 20 procedure DataModuleDestroy(Sender: TObject); … … 20 22 { private declarations } 21 23 public 24 LastOpenedFile: string; 25 ReopenLastFile: Boolean; 22 26 Grammer: TGrammer; 27 procedure LoadConfig; 28 procedure SaveConfig; 29 procedure Initialize; 23 30 end; 24 31 … … 30 37 {$R *.lfm} 31 38 39 uses 40 UFormMain; 41 32 42 { TCore } 33 43 34 44 procedure TCore.DataModuleCreate(Sender: TObject); 35 45 begin 36 Grammer := TGrammer.Create; 37 Grammer.LoadFromXmlFile('pascal.grm'); 46 ForceDirectories(GetAppConfigDir(False)); 47 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 48 LoadConfig; 38 49 end; 39 50 40 51 procedure TCore.DataModuleDestroy(Sender: TObject); 41 52 begin 42 Grammer.SaveToXmlFile('pascal.grm'); 43 FreeAndNil(Grammer); 53 SaveConfig; 54 end; 55 56 procedure TCore.LoadConfig; 57 begin 58 with XMLConfig1 do begin 59 LastOpenedFile := string(GetValue('LastOpenedFile', 'pascal.grm')); 60 ReopenLastFile := GetValue('ReopenLastFile', True); 61 end; 62 end; 63 64 procedure TCore.SaveConfig; 65 begin 66 with XMLConfig1 do begin 67 SetValue('LastOpenedFile', DOMString(LastOpenedFile)); 68 SetValue('ReopenLastFile', ReopenLastFile); 69 Flush; 70 end; 71 end; 72 73 procedure TCore.Initialize; 74 begin 75 FormMain.AProjectNew.Execute; 76 if ReopenLastFile and FileExists(LastOpenedFile) then 77 Grammer.LoadFromXmlFile(LastOpenedFile) 44 78 end; 45 79
Note:
See TracChangeset
for help on using the changeset viewer.