| 1 | unit LDPlatform.Core;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | System.SysUtils, System.Classes, Vcl.Forms, LDPlatform.FormMain, LDPlatform.FormOptions,
|
|---|
| 7 | System.Actions, Vcl.ActnList, Vcl.ImgList, Vcl.Controls, LDPlatform.FormNew,
|
|---|
| 8 | Generics.Collections, Vcl.Dialogs, UProject;
|
|---|
| 9 |
|
|---|
| 10 | type
|
|---|
| 11 | TOpenedFile = class
|
|---|
| 12 | FileName: string;
|
|---|
| 13 | end;
|
|---|
| 14 |
|
|---|
| 15 | TCore = class(TDataModule)
|
|---|
| 16 | ActionList1: TActionList;
|
|---|
| 17 | ImageList1: TImageList;
|
|---|
| 18 | AOptions: TAction;
|
|---|
| 19 | AQuit: TAction;
|
|---|
| 20 | AFileOpen: TAction;
|
|---|
| 21 | AFileClose: TAction;
|
|---|
| 22 | AFileSave: TAction;
|
|---|
| 23 | AFileSaveAs: TAction;
|
|---|
| 24 | ANew: TAction;
|
|---|
| 25 | AFileCloseAll: TAction;
|
|---|
| 26 | AFileSaveAll: TAction;
|
|---|
| 27 | AHelpAbout: TAction;
|
|---|
| 28 | OpenDialog1: TOpenDialog;
|
|---|
| 29 | SaveDialog1: TSaveDialog;
|
|---|
| 30 | procedure DataModuleCreate(Sender: TObject);
|
|---|
| 31 | procedure DataModuleDestroy(Sender: TObject);
|
|---|
| 32 | procedure AOptionsExecute(Sender: TObject);
|
|---|
| 33 | procedure AQuitExecute(Sender: TObject);
|
|---|
| 34 | procedure ANewExecute(Sender: TObject);
|
|---|
| 35 | procedure AFileOpenExecute(Sender: TObject);
|
|---|
| 36 | procedure AFileSaveAsExecute(Sender: TObject);
|
|---|
| 37 | procedure AFileSaveExecute(Sender: TObject);
|
|---|
| 38 | private
|
|---|
| 39 | { Private declarations }
|
|---|
| 40 | public
|
|---|
| 41 | Project: TProject;
|
|---|
| 42 | OpenedFiles: TList<TOpenedFile>;
|
|---|
| 43 | FormNew: TFormNew;
|
|---|
| 44 | FormMain: TFormMain;
|
|---|
| 45 | FormOptions: TFormOptions;
|
|---|
| 46 | end;
|
|---|
| 47 |
|
|---|
| 48 | var
|
|---|
| 49 | Core: TCore;
|
|---|
| 50 |
|
|---|
| 51 | implementation
|
|---|
| 52 |
|
|---|
| 53 | {%CLASSGROUP 'Vcl.Controls.TControl'}
|
|---|
| 54 |
|
|---|
| 55 | {$R *.dfm}
|
|---|
| 56 |
|
|---|
| 57 | procedure TCore.AFileOpenExecute(Sender: TObject);
|
|---|
| 58 | begin
|
|---|
| 59 | if OpenDialog1.Execute then begin
|
|---|
| 60 | Project.LoadFromFile(OpenDialog1.FileName);
|
|---|
| 61 | end;
|
|---|
| 62 | end;
|
|---|
| 63 |
|
|---|
| 64 | procedure TCore.AFileSaveAsExecute(Sender: TObject);
|
|---|
| 65 | begin
|
|---|
| 66 | SaveDialog1.FileName := Project.FileName;
|
|---|
| 67 | if SaveDialog1.Execute then begin
|
|---|
| 68 | Project.SaveToFile(SaveDialog1.FileName);
|
|---|
| 69 | end;
|
|---|
| 70 | end;
|
|---|
| 71 |
|
|---|
| 72 | procedure TCore.AFileSaveExecute(Sender: TObject);
|
|---|
| 73 | begin
|
|---|
| 74 | if Project.Modified then AFileSaveAs.Execute
|
|---|
| 75 | else Project.Save;
|
|---|
| 76 | end;
|
|---|
| 77 |
|
|---|
| 78 | procedure TCore.ANewExecute(Sender: TObject);
|
|---|
| 79 | begin
|
|---|
| 80 | try
|
|---|
| 81 | FormNew := TFormNew.Create(nil);
|
|---|
| 82 | //FormNew.Load;
|
|---|
| 83 | if FormNew.ShowModal = mrOk then begin
|
|---|
| 84 | //FormOptions.Save;
|
|---|
| 85 | end;
|
|---|
| 86 | finally
|
|---|
| 87 | FreeAndNil(FormNew);
|
|---|
| 88 | end;
|
|---|
| 89 | end;
|
|---|
| 90 |
|
|---|
| 91 | procedure TCore.AOptionsExecute(Sender: TObject);
|
|---|
| 92 | begin
|
|---|
| 93 | try
|
|---|
| 94 | FormOptions := TFormOptions.Create(nil);
|
|---|
| 95 | FormOptions.Load;
|
|---|
| 96 | if FormOptions.ShowModal = mrOk then begin
|
|---|
| 97 | FormOptions.Save;
|
|---|
| 98 | end;
|
|---|
| 99 | finally
|
|---|
| 100 | FreeAndNil(FormOptions);
|
|---|
| 101 | end;
|
|---|
| 102 | end;
|
|---|
| 103 |
|
|---|
| 104 | procedure TCore.AQuitExecute(Sender: TObject);
|
|---|
| 105 | begin
|
|---|
| 106 | Application.Terminate;
|
|---|
| 107 | end;
|
|---|
| 108 |
|
|---|
| 109 | procedure TCore.DataModuleCreate(Sender: TObject);
|
|---|
| 110 | begin
|
|---|
| 111 | Project := TProject.Create;
|
|---|
| 112 | OpenedFiles := TList<TOpenedFile>.Create;
|
|---|
| 113 | Application.CreateForm(TFormMain, FormMain);
|
|---|
| 114 | FormMain.Show;
|
|---|
| 115 | end;
|
|---|
| 116 |
|
|---|
| 117 | procedure TCore.DataModuleDestroy(Sender: TObject);
|
|---|
| 118 | begin
|
|---|
| 119 | Project.Free;
|
|---|
| 120 | OpenedFiles.Free;
|
|---|
| 121 | end;
|
|---|
| 122 |
|
|---|
| 123 | end.
|
|---|