|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace VoidEngine; |
|
4
|
|
|
|
|
5
|
|
|
register_superglobals ('APPLICATION', 'SCREEN'); |
|
|
|
|
|
|
6
|
|
|
|
|
7
|
|
|
$APPLICATION = new class |
|
8
|
|
|
{ |
|
9
|
|
|
public NetClass $application; |
|
10
|
|
|
public string $executablePath; |
|
11
|
|
|
|
|
12
|
|
|
public function __construct () |
|
13
|
|
|
{ |
|
14
|
|
|
$this->application = new NetClass ('System.Windows.Forms.Application'); |
|
15
|
|
|
$this->executablePath = $this->application->executablePath; |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function run ($form = null): void |
|
19
|
|
|
{ |
|
20
|
|
|
if ($form instanceof NetObject) |
|
21
|
|
|
$this->application->run ($form->selector); |
|
22
|
|
|
|
|
23
|
|
|
elseif (is_int ($form) && \VoidCore::objectExists ($form)) |
|
24
|
|
|
$this->application->run ($form); |
|
25
|
|
|
|
|
26
|
|
|
elseif ($form === null) |
|
27
|
|
|
$this->application->run (); |
|
28
|
|
|
|
|
29
|
|
|
else throw new \Exception ('$form param must be instance of "VoidEngine\NetObject" ("VoidEngine\Form"), be null or object selector'); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function restart (): void |
|
33
|
|
|
{ |
|
34
|
|
|
$this->application->restart (); |
|
35
|
|
|
$this->close (); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function close (): void |
|
39
|
|
|
{ |
|
40
|
|
|
$this->application->exit (); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function __call (string $name, array $args) |
|
44
|
|
|
{ |
|
45
|
|
|
return $this->application->$name (...$args); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function __get (string $name) |
|
49
|
|
|
{ |
|
50
|
|
|
return $this->application->$name; |
|
51
|
|
|
} |
|
52
|
|
|
}; |
|
53
|
|
|
|
|
54
|
|
|
$SCREEN = new class |
|
55
|
|
|
{ |
|
56
|
|
|
public NetClass $screen; |
|
57
|
|
|
|
|
58
|
|
|
public function __construct () |
|
59
|
|
|
{ |
|
60
|
|
|
$this->screen = new NetClass ('System.Windows.Forms.Screen'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function __get ($name) |
|
64
|
|
|
{ |
|
65
|
|
|
switch (strtolower ($name)) |
|
66
|
|
|
{ |
|
67
|
|
|
case 'width': |
|
68
|
|
|
case 'w': |
|
69
|
|
|
return $this->screen->primaryScreen->bounds->width; |
|
70
|
|
|
break; |
|
71
|
|
|
|
|
72
|
|
|
case 'height': |
|
73
|
|
|
case 'h': |
|
74
|
|
|
return $this->screen->primaryScreen->bounds->height; |
|
75
|
|
|
break; |
|
76
|
|
|
|
|
77
|
|
|
default: |
|
78
|
|
|
return $this->screen->$name; |
|
79
|
|
|
break; |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function __debugInfo (): array |
|
84
|
|
|
{ |
|
85
|
|
|
return [ |
|
86
|
|
|
$this->w, |
|
|
|
|
|
|
87
|
|
|
$this->h |
|
|
|
|
|
|
88
|
|
|
]; |
|
89
|
|
|
} |
|
90
|
|
|
}; |
|
91
|
|
|
|