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 | function GetMousePosition: TPoint;
|
---|
37 | public
|
---|
38 | FormConsole: TFormConsole;
|
---|
39 | FormScreen: TFormScreen;
|
---|
40 | end;
|
---|
41 |
|
---|
42 | var
|
---|
43 | FormName: TFormName;
|
---|
44 |
|
---|
45 |
|
---|
46 | implementation
|
---|
47 |
|
---|
48 | {$R *.lfm}
|
---|
49 |
|
---|
50 | { TFormName }
|
---|
51 |
|
---|
52 | procedure TFormName.FormShow(Sender: TObject);
|
---|
53 | begin
|
---|
54 | FormScreen.ManualDock(Self, nil, alClient);
|
---|
55 | FormScreen.Align := alClient;
|
---|
56 | FormScreen.Show;
|
---|
57 |
|
---|
58 | System := TSystem.Create;
|
---|
59 | System.Console.OnWrite := ConsoleWrite;
|
---|
60 | System.FileSystem.OnLoadFile := LoadFile;
|
---|
61 | System.Mouse.OnGetPosition := GetMousePosition;
|
---|
62 | System.OnDraw := FormScreen.Redraw;
|
---|
63 | FormScreen.System := System;
|
---|
64 |
|
---|
65 | System.Start;
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TFormName.FormCreate(Sender: TObject);
|
---|
69 | begin
|
---|
70 | FileSystemDir := 'FileSystem';
|
---|
71 | FormConsole := TFormConsole.Create(nil);
|
---|
72 | FormScreen := TFormScreen.Create(nil);
|
---|
73 | end;
|
---|
74 |
|
---|
75 | procedure TFormName.FormDestroy(Sender: TObject);
|
---|
76 | begin
|
---|
77 | FreeAndNil(System);
|
---|
78 | FreeAndNil(FormConsole);
|
---|
79 | FreeAndNil(FormScreen);
|
---|
80 | end;
|
---|
81 |
|
---|
82 | procedure TFormName.AExitExecute(Sender: TObject);
|
---|
83 | begin
|
---|
84 | Close;
|
---|
85 | Application.Terminate;
|
---|
86 | end;
|
---|
87 |
|
---|
88 | procedure TFormName.AConsoleExecute(Sender: TObject);
|
---|
89 | begin
|
---|
90 | FormConsole.Show;
|
---|
91 | end;
|
---|
92 |
|
---|
93 | procedure TFormName.AFullscreenExecute(Sender: TObject);
|
---|
94 | begin
|
---|
95 |
|
---|
96 | end;
|
---|
97 |
|
---|
98 | procedure TFormName.ConsoleWrite(Text: string);
|
---|
99 | begin
|
---|
100 | FormConsole.Memo1.Lines.Add(Text);
|
---|
101 | end;
|
---|
102 |
|
---|
103 | function TFormName.LoadFile(Name: string): string;
|
---|
104 | var
|
---|
105 | F: TFileStream;
|
---|
106 | begin
|
---|
107 | F := TFileStream.Create(FileSystemDir + DirectorySeparator + Name, fmOpenRead);
|
---|
108 | try
|
---|
109 | if F.Size > 0 then begin
|
---|
110 | Result := default(string);
|
---|
111 | SetLength(Result, F.Size);
|
---|
112 | F.Read(Result[1], F.Size);
|
---|
113 | end else Result := '';
|
---|
114 | finally
|
---|
115 | F.Free;
|
---|
116 | end;
|
---|
117 | end;
|
---|
118 |
|
---|
119 | function TFormName.GetMousePosition: TPoint;
|
---|
120 | begin
|
---|
121 | Result := Mouse.CursorPos;
|
---|
122 | end;
|
---|
123 |
|
---|
124 | end.
|
---|
125 |
|
---|