1 | unit FormMain;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
|
---|
7 | ActnList, ExtCtrls, Os, FormConsole, FormScreen;
|
---|
8 |
|
---|
9 | type
|
---|
10 |
|
---|
11 | { TFormName }
|
---|
12 |
|
---|
13 | TFormName = class(TForm)
|
---|
14 | AConsole: TAction;
|
---|
15 | AFullscreen: TAction;
|
---|
16 | AExit: TAction;
|
---|
17 | ActionList1: TActionList;
|
---|
18 | MainMenu1: TMainMenu;
|
---|
19 | MenuItem1: TMenuItem;
|
---|
20 | MenuItem2: TMenuItem;
|
---|
21 | MenuItem3: TMenuItem;
|
---|
22 | MenuItem4: TMenuItem;
|
---|
23 | MenuItem5: TMenuItem;
|
---|
24 | MenuItemView: TMenuItem;
|
---|
25 | procedure AConsoleExecute(Sender: TObject);
|
---|
26 | procedure AExitExecute(Sender: TObject);
|
---|
27 | procedure AFullscreenExecute(Sender: TObject);
|
---|
28 | procedure FormCreate(Sender: TObject);
|
---|
29 | procedure FormDestroy(Sender: TObject);
|
---|
30 | procedure FormShow(Sender: TObject);
|
---|
31 | private
|
---|
32 | FileSystemDir: string;
|
---|
33 | System: TSystem;
|
---|
34 | procedure ConsoleWrite(Text: string);
|
---|
35 | function LoadFile(Name: string): string;
|
---|
36 | public
|
---|
37 | FormConsole: TFormConsole;
|
---|
38 | FormScreen: TFormScreen;
|
---|
39 | end;
|
---|
40 |
|
---|
41 | var
|
---|
42 | FormName: TFormName;
|
---|
43 |
|
---|
44 |
|
---|
45 | implementation
|
---|
46 |
|
---|
47 | {$R *.lfm}
|
---|
48 |
|
---|
49 | { TFormName }
|
---|
50 |
|
---|
51 | procedure TFormName.FormShow(Sender: TObject);
|
---|
52 | begin
|
---|
53 | FormScreen.ManualDock(Self, nil, alClient);
|
---|
54 | FormScreen.Align := alClient;
|
---|
55 | FormScreen.Show;
|
---|
56 |
|
---|
57 | System := TSystem.Create;
|
---|
58 | System.Console.OnWrite := ConsoleWrite;
|
---|
59 | System.FileSystem.OnLoadFile := LoadFile;
|
---|
60 | System.OnDraw := FormScreen.Redraw;
|
---|
61 | FormScreen.System := System;
|
---|
62 |
|
---|
63 | System.Start;
|
---|
64 | end;
|
---|
65 |
|
---|
66 | procedure TFormName.FormCreate(Sender: TObject);
|
---|
67 | begin
|
---|
68 | FileSystemDir := 'FileSystem';
|
---|
69 | FormConsole := TFormConsole.Create(nil);
|
---|
70 | FormScreen := TFormScreen.Create(nil);
|
---|
71 | end;
|
---|
72 |
|
---|
73 | procedure TFormName.FormDestroy(Sender: TObject);
|
---|
74 | begin
|
---|
75 | FreeAndNil(System);
|
---|
76 | FreeAndNil(FormConsole);
|
---|
77 | FreeAndNil(FormScreen);
|
---|
78 | end;
|
---|
79 |
|
---|
80 | procedure TFormName.AExitExecute(Sender: TObject);
|
---|
81 | begin
|
---|
82 | Close;
|
---|
83 | Application.Terminate;
|
---|
84 | end;
|
---|
85 |
|
---|
86 | procedure TFormName.AConsoleExecute(Sender: TObject);
|
---|
87 | begin
|
---|
88 | FormConsole.Show;
|
---|
89 | end;
|
---|
90 |
|
---|
91 | procedure TFormName.AFullscreenExecute(Sender: TObject);
|
---|
92 | begin
|
---|
93 |
|
---|
94 | end;
|
---|
95 |
|
---|
96 | procedure TFormName.ConsoleWrite(Text: string);
|
---|
97 | begin
|
---|
98 | FormConsole.Memo1.Lines.Add(Text);
|
---|
99 | end;
|
---|
100 |
|
---|
101 | function TFormName.LoadFile(Name: string): string;
|
---|
102 | var
|
---|
103 | F: TFileStream;
|
---|
104 | begin
|
---|
105 | F := TFileStream.Create(FileSystemDir + DirectorySeparator + Name, fmOpenRead);
|
---|
106 | try
|
---|
107 | if F.Size > 0 then begin
|
---|
108 | Result := default(string);
|
---|
109 | SetLength(Result, F.Size);
|
---|
110 | F.Read(Result[1], F.Size);
|
---|
111 | end else Result := '';
|
---|
112 | finally
|
---|
113 | F.Free;
|
---|
114 | end;
|
---|
115 | end;
|
---|
116 |
|
---|
117 | end.
|
---|
118 |
|
---|