@@ -78,40 +78,40 @@ discard block |
||
78 | 78 | { |
79 | 79 | $this->componentAddedEvent = function ($self, $args) |
80 | 80 | { |
81 | - if (!isset ($GLOBALS['new_component'])) |
|
82 | - { |
|
81 | + if (!isset ($GLOBALS['new_component'])) |
|
82 | + { |
|
83 | 83 | $name = $args->component->getType ()->toString (); |
84 | 84 | |
85 | 85 | // pre (\VoidCore::getProperty ($args->component->selector, 'Name')); |
86 | 86 | |
87 | - $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
88 | - } |
|
87 | + $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
88 | + } |
|
89 | 89 | |
90 | - $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | - $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
90 | + $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | + $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
92 | 92 | |
93 | - $components->items->clear (); |
|
94 | - $components->items->addRange (array_keys ($this->objects)); |
|
93 | + $components->items->clear (); |
|
94 | + $components->items->addRange (array_keys ($this->objects)); |
|
95 | 95 | |
96 | - $components->selectedItem = $GLOBALS['new_component'][0]; |
|
97 | - $this->setSelectedComponents ($args->component); |
|
96 | + $components->selectedItem = $GLOBALS['new_component'][0]; |
|
97 | + $this->setSelectedComponents ($args->component); |
|
98 | 98 | |
99 | - unset ($GLOBALS['new_component']); |
|
99 | + unset ($GLOBALS['new_component']); |
|
100 | 100 | }; |
101 | 101 | |
102 | - $this->componentRemovedEvent = function ($self, $args) |
|
103 | - { |
|
104 | - $name = $this->getComponentName ($args->component->selector); |
|
105 | - unset ($this->objects[$name]); |
|
102 | + $this->componentRemovedEvent = function ($self, $args) |
|
103 | + { |
|
104 | + $name = $this->getComponentName ($args->component->selector); |
|
105 | + unset ($this->objects[$name]); |
|
106 | 106 | |
107 | - foreach ($this->objects as $objectName => $object) |
|
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | - unset ($this->objects[$objectName]); |
|
107 | + foreach ($this->objects as $objectName => $object) |
|
108 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | + unset ($this->objects[$objectName]); |
|
110 | 110 | |
111 | - $this->currentSelectedItem->items->clear (); |
|
112 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
114 | - }; |
|
111 | + $this->currentSelectedItem->items->clear (); |
|
112 | + $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | + $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
114 | + }; |
|
115 | 115 | |
116 | 116 | // ! Отредактировал что-то здесь? |
117 | 117 | // ! Не забудь отредактировать и в main.vlf |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | $menu->items->addRange (isset ($desItem) ? [ |
204 | 204 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
205 | 205 | $toFrontItem, $toBackItem, $desItem, '-', |
206 | - $undoItem, $redoItem, '-', |
|
206 | + $undoItem, $redoItem, '-', |
|
207 | 207 | $infoItem |
208 | 208 | ] : [ |
209 | 209 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
210 | 210 | $toFrontItem, $toBackItem, '-', |
211 | - $undoItem, $redoItem, '-', |
|
211 | + $undoItem, $redoItem, '-', |
|
212 | 212 | $infoItem |
213 | 213 | ]); |
214 | 214 |
@@ -12,20 +12,19 @@ discard block |
||
12 | 12 | protected $currentSelectedItem; |
13 | 13 | protected $formsList; |
14 | 14 | |
15 | - public function __construct (Component $parent, string $formName = 'form', PropertyGrid $propertyGrid, ComboBox $currentSelectedItem, TabControl $formsList, $form = null) |
|
15 | + public function __construct(Component $parent, string $formName = 'form', PropertyGrid $propertyGrid, ComboBox $currentSelectedItem, TabControl $formsList, $form = null) |
|
16 | 16 | { |
17 | - $this->form = $form === null ? new Form : |
|
18 | - EngineAdditions::coupleSelector ($form); |
|
17 | + $this->form = $form === null ? new Form : EngineAdditions::coupleSelector($form); |
|
19 | 18 | |
20 | - if (!is_object ($this->form)) |
|
21 | - throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
19 | + if (!is_object($this->form)) |
|
20 | + throw new \Exception('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
22 | 21 | |
23 | 22 | $this->propertyGrid = $propertyGrid; |
24 | 23 | $this->currentSelectedItem = $currentSelectedItem; |
25 | 24 | $this->formsList = $formsList; |
26 | 25 | |
27 | - $this->selector = \VoidCore::createObject ('WinForms_PHP.FormDesigner5', null, $this->form->selector, $formName); |
|
28 | - Components::addComponent ($this->selector, $this); |
|
26 | + $this->selector = \VoidCore::createObject('WinForms_PHP.FormDesigner5', null, $this->form->selector, $formName); |
|
27 | + Components::addComponent($this->selector, $this); |
|
29 | 28 | |
30 | 29 | $this->form->name = $formName; |
31 | 30 | |
@@ -35,172 +34,172 @@ discard block |
||
35 | 34 | $this->form->size = [400, 360]; |
36 | 35 | } |
37 | 36 | |
38 | - $this->control = $this->callMethod ('GetControl'); |
|
37 | + $this->control = $this->callMethod('GetControl'); |
|
39 | 38 | $this->objects[$formName] = ['System.Windows.Forms.Form', 'System.Windows.Forms']; |
40 | 39 | |
41 | - \VoidCore::setProperty ($this->control, 'Parent', $parent->selector); |
|
40 | + \VoidCore::setProperty($this->control, 'Parent', $parent->selector); |
|
42 | 41 | |
43 | - $this->selectionChangedEvent = function () |
|
42 | + $this->selectionChangedEvent = function() |
|
44 | 43 | { |
45 | - $object = $this->getPrimarySelection ()->selector; |
|
44 | + $object = $this->getPrimarySelection()->selector; |
|
46 | 45 | |
47 | 46 | $this->propertyGrid->selectedObject = $object; |
48 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($object); |
|
47 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($object); |
|
49 | 48 | }; |
50 | 49 | |
51 | - $this->createUniqueMethodNameEvent = function ($self, $args) |
|
50 | + $this->createUniqueMethodNameEvent = function($self, $args) |
|
52 | 51 | { |
53 | - return $this->getComponentName ($args->component->selector) . '_' . $args->eventDescriptor->Name; |
|
52 | + return $this->getComponentName($args->component->selector).'_'.$args->eventDescriptor->Name; |
|
54 | 53 | }; |
55 | 54 | |
56 | - $this->getCompatibleMethodsEvent = function () |
|
55 | + $this->getCompatibleMethodsEvent = function() |
|
57 | 56 | { |
58 | 57 | $form = $this->formsList->selectedTab->text; |
59 | 58 | |
60 | - return getNetArray ('System.String', ClassWorker::getAvailableClassMethods (VoidStudioAPI::$events[$form] ?? '', $form))->selector; |
|
59 | + return getNetArray('System.String', ClassWorker::getAvailableClassMethods(VoidStudioAPI::$events[$form] ?? '', $form))->selector; |
|
61 | 60 | }; |
62 | 61 | |
63 | - $this->showCodeEvent = function ($self, $args) |
|
62 | + $this->showCodeEvent = function($self, $args) |
|
64 | 63 | { |
65 | - VoidStudioAPI::openEventEditor ($this->propertyGrid->selectedObject->selector, $args->methodName, $args->eventDescriptor, $form = c('Designer__FormsList')->selectedTab->text, VoidStudioAPI::getObjects ('main')['Designer__'. $form .'Designer']); |
|
64 | + VoidStudioAPI::openEventEditor($this->propertyGrid->selectedObject->selector, $args->methodName, $args->eventDescriptor, $form = c('Designer__FormsList')->selectedTab->text, VoidStudioAPI::getObjects('main')['Designer__'.$form.'Designer']); |
|
66 | 65 | }; |
67 | 66 | |
68 | - $this->freeMethodEvent = function ($self, $args) |
|
67 | + $this->freeMethodEvent = function($self, $args) |
|
69 | 68 | { |
70 | 69 | $object = $this->propertyGrid->selectedObject->selector; |
71 | 70 | |
72 | - Events::removeObjectEvent ($object, $method = $args->eventDescriptor->Name); |
|
71 | + Events::removeObjectEvent($object, $method = $args->eventDescriptor->Name); |
|
73 | 72 | unset (VoidStudioAPI::$events[$object][$method]); |
74 | 73 | }; |
75 | 74 | } |
76 | 75 | |
77 | - public function initDesigner (): void |
|
76 | + public function initDesigner(): void |
|
78 | 77 | { |
79 | - $this->componentAddedEvent = function ($self, $args) |
|
78 | + $this->componentAddedEvent = function($self, $args) |
|
80 | 79 | { |
81 | 80 | if (!isset ($GLOBALS['new_component'])) |
82 | 81 | { |
83 | - $name = $args->component->getType ()->toString (); |
|
82 | + $name = $args->component->getType()->toString(); |
|
84 | 83 | |
85 | 84 | // pre (\VoidCore::getProperty ($args->component->selector, 'Name')); |
86 | 85 | |
87 | - $GLOBALS['new_component'] = [$this->getComponentName ($args->component->selector), [$name, substr ($name, 0, strrpos ($name, '.'))]]; |
|
86 | + $GLOBALS['new_component'] = [$this->getComponentName($args->component->selector), [$name, substr($name, 0, strrpos($name, '.'))]]; |
|
88 | 87 | } |
89 | 88 | |
90 | - $this->setComponentToHistory ($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
91 | - $components = VoidStudioAPI::getObjects ('main')['PropertiesPanel__SelectedComponent']; |
|
89 | + $this->setComponentToHistory($GLOBALS['new_component'][1], $GLOBALS['new_component'][0]); |
|
90 | + $components = VoidStudioAPI::getObjects('main')['PropertiesPanel__SelectedComponent']; |
|
92 | 91 | |
93 | - $components->items->clear (); |
|
94 | - $components->items->addRange (array_keys ($this->objects)); |
|
92 | + $components->items->clear(); |
|
93 | + $components->items->addRange(array_keys($this->objects)); |
|
95 | 94 | |
96 | 95 | $components->selectedItem = $GLOBALS['new_component'][0]; |
97 | - $this->setSelectedComponents ($args->component); |
|
96 | + $this->setSelectedComponents($args->component); |
|
98 | 97 | |
99 | 98 | unset ($GLOBALS['new_component']); |
100 | 99 | }; |
101 | 100 | |
102 | - $this->componentRemovedEvent = function ($self, $args) |
|
101 | + $this->componentRemovedEvent = function($self, $args) |
|
103 | 102 | { |
104 | - $name = $this->getComponentName ($args->component->selector); |
|
103 | + $name = $this->getComponentName($args->component->selector); |
|
105 | 104 | unset ($this->objects[$name]); |
106 | 105 | |
107 | 106 | foreach ($this->objects as $objectName => $object) |
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
107 | + if (!is_int($this->getComponentByName($objectName))) |
|
109 | 108 | unset ($this->objects[$objectName]); |
110 | 109 | |
111 | - $this->currentSelectedItem->items->clear (); |
|
112 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
113 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
110 | + $this->currentSelectedItem->items->clear(); |
|
111 | + $this->currentSelectedItem->items->addRange(array_keys($this->objects)); |
|
112 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($this->getPrimarySelection()->selector); |
|
114 | 113 | }; |
115 | 114 | |
116 | 115 | // ! Отредактировал что-то здесь? |
117 | 116 | // ! Не забудь отредактировать и в main.vlf |
118 | 117 | |
119 | - $this->rightClickEvent = function ($self, $args) |
|
118 | + $this->rightClickEvent = function($self, $args) |
|
120 | 119 | { |
121 | - $delItem = new ToolStripMenuItem ('Удалить'); |
|
122 | - $delItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Delete_16x.png'); |
|
120 | + $delItem = new ToolStripMenuItem('Удалить'); |
|
121 | + $delItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Delete_16x.png'); |
|
123 | 122 | $delItem->shortcutKeys = 46; |
124 | - $delItem->clickEvent = fn () => $this->removeSelected (); |
|
123 | + $delItem->clickEvent = fn() => $this->removeSelected(); |
|
125 | 124 | |
126 | - $toFrontItem = new ToolStripMenuItem ('На передний план'); |
|
127 | - $toFrontItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Front_16x.png'); |
|
125 | + $toFrontItem = new ToolStripMenuItem('На передний план'); |
|
126 | + $toFrontItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Front_16x.png'); |
|
128 | 127 | // $toFrontItem->shortcutKeys = 131142; |
129 | - $toFrontItem->clickEvent = fn () => $self->doAction ('bringToFront'); |
|
128 | + $toFrontItem->clickEvent = fn() => $self->doAction('bringToFront'); |
|
130 | 129 | |
131 | - $toBackItem = new ToolStripMenuItem ('На задний план'); |
|
132 | - $toBackItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Back_16x.png'); |
|
130 | + $toBackItem = new ToolStripMenuItem('На задний план'); |
|
131 | + $toBackItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Back_16x.png'); |
|
133 | 132 | // $toBackItem->shortcutKeys = 131138; |
134 | - $toBackItem->clickEvent = fn () => $self->doAction ('sendToBack'); |
|
133 | + $toBackItem->clickEvent = fn() => $self->doAction('sendToBack'); |
|
135 | 134 | |
136 | - if ((new WFObject (\VoidCore::typeof ('System.Windows.Forms.Control')))->isAssignableFrom ($this->propertyGrid->selectedObject->getType ())) |
|
135 | + if ((new WFObject(\VoidCore::typeof('System.Windows.Forms.Control')))->isAssignableFrom($this->propertyGrid->selectedObject->getType())) |
|
137 | 136 | { |
138 | - $locked = ($locker = (new WFClass ('System.ComponentModel.TypeDescriptor', 'System')) |
|
139 | - ->getProperties ($object = $this->propertyGrid->selectedObject->selector)['Locked']) |
|
140 | - ->getValue ($object); |
|
137 | + $locked = ($locker = (new WFClass('System.ComponentModel.TypeDescriptor', 'System')) |
|
138 | + ->getProperties($object = $this->propertyGrid->selectedObject->selector)['Locked']) |
|
139 | + ->getValue($object); |
|
141 | 140 | |
142 | - $desItem = new ToolStripMenuItem ($locked ? 'Разблокировать' : 'Заблокировать'); |
|
143 | - $desItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/'. ($locked ? 'Unlock' : 'Lock') .'_16x.png'); |
|
141 | + $desItem = new ToolStripMenuItem($locked ? 'Разблокировать' : 'Заблокировать'); |
|
142 | + $desItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/'.($locked ? 'Unlock' : 'Lock').'_16x.png'); |
|
144 | 143 | // $desItem->shortcutKeys = 131148; |
145 | - $desItem->clickEvent = function () use ($object, $locker, $locked) |
|
144 | + $desItem->clickEvent = function() use ($object, $locker, $locked) |
|
146 | 145 | { |
147 | - $locker->setValue ($object, !$locked); |
|
146 | + $locker->setValue($object, !$locked); |
|
148 | 147 | |
149 | - $this->propertyGrid->refresh (); |
|
148 | + $this->propertyGrid->refresh(); |
|
150 | 149 | }; |
151 | 150 | } |
152 | 151 | |
153 | - $selectAllItem = new ToolStripMenuItem ('Выделить всё'); |
|
154 | - $selectAllItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/SelectAll_16x.png'); |
|
152 | + $selectAllItem = new ToolStripMenuItem('Выделить всё'); |
|
153 | + $selectAllItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/SelectAll_16x.png'); |
|
155 | 154 | $selectAllItem->shortcutKeys = 131137; |
156 | - $selectAllItem->clickEvent = fn () => $self->doAction ('selectAll'); |
|
155 | + $selectAllItem->clickEvent = fn() => $self->doAction('selectAll'); |
|
157 | 156 | |
158 | - $cutItem = new ToolStripMenuItem ('Вырезать'); |
|
159 | - $cutItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Cut_16x.png'); |
|
157 | + $cutItem = new ToolStripMenuItem('Вырезать'); |
|
158 | + $cutItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Cut_16x.png'); |
|
160 | 159 | $cutItem->shortcutKeys = 131160; |
161 | - $cutItem->clickEvent = fn () => $self->doAction ('cut'); |
|
160 | + $cutItem->clickEvent = fn() => $self->doAction('cut'); |
|
162 | 161 | |
163 | - $copyItem = new ToolStripMenuItem ('Копировать'); |
|
164 | - $copyItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Copy_16x.png'); |
|
162 | + $copyItem = new ToolStripMenuItem('Копировать'); |
|
163 | + $copyItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Copy_16x.png'); |
|
165 | 164 | $copyItem->shortcutKeys = 131139; |
166 | - $copyItem->clickEvent = fn () => $self->doAction ('copy'); |
|
165 | + $copyItem->clickEvent = fn() => $self->doAction('copy'); |
|
167 | 166 | |
168 | - $pasteItem = new ToolStripMenuItem ('Вставить'); |
|
169 | - $pasteItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Paste_16x.png'); |
|
167 | + $pasteItem = new ToolStripMenuItem('Вставить'); |
|
168 | + $pasteItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Paste_16x.png'); |
|
170 | 169 | $pasteItem->shortcutKeys = 131158; |
171 | - $pasteItem->clickEvent = fn () => $self->doAction('paste'); |
|
170 | + $pasteItem->clickEvent = fn() => $self->doAction('paste'); |
|
172 | 171 | |
173 | - $undoItem = new ToolStripMenuItem ('Отменить'); |
|
174 | - $undoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Undo_16x.png'); |
|
172 | + $undoItem = new ToolStripMenuItem('Отменить'); |
|
173 | + $undoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Undo_16x.png'); |
|
175 | 174 | $undoItem->shortcutKeys = 131162; |
176 | - $undoItem->clickEvent = fn () => $self->undoEngine->undo (); |
|
175 | + $undoItem->clickEvent = fn() => $self->undoEngine->undo(); |
|
177 | 176 | |
178 | - $redoItem = new ToolStripMenuItem ('Повторить'); |
|
179 | - $redoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Redo_16x.png'); |
|
177 | + $redoItem = new ToolStripMenuItem('Повторить'); |
|
178 | + $redoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Redo_16x.png'); |
|
180 | 179 | $redoItem->shortcutKeys = 131161; |
181 | - $redoItem->clickEvent = fn () => $self->undoEngine->redo (); |
|
180 | + $redoItem->clickEvent = fn() => $self->undoEngine->redo(); |
|
182 | 181 | |
183 | - $infoItem = new ToolStripMenuItem ('Отладочная информация'); |
|
184 | - $infoItem->image = (new Image)->loadFromFile (APP_DIR .'/system/icons/Debug_16x.png'); |
|
185 | - $infoItem->clickEvent = function () use ($self) |
|
182 | + $infoItem = new ToolStripMenuItem('Отладочная информация'); |
|
183 | + $infoItem->image = (new Image)->loadFromFile(APP_DIR.'/system/icons/Debug_16x.png'); |
|
184 | + $infoItem->clickEvent = function() use ($self) |
|
186 | 185 | { |
187 | - $self->getSelectedComponents ()->foreach (function ($value) use ($self) |
|
186 | + $self->getSelectedComponents()->foreach(function($value) use ($self) |
|
188 | 187 | { |
189 | - pre ($value instanceof Component ? $value : $value->toString () ."\nSelector: ". $value->selector); |
|
188 | + pre($value instanceof Component ? $value : $value->toString()."\nSelector: ".$value->selector); |
|
190 | 189 | |
191 | - if ((new WFObject (\VoidCore::typeof ('System.Windows.Forms.Form')))->isAssignableFrom ($value->getType ())) |
|
190 | + if ((new WFObject(\VoidCore::typeof('System.Windows.Forms.Form')))->isAssignableFrom($value->getType())) |
|
192 | 191 | { |
193 | - $code = $self->getVoidCode ($self->form->name, false); |
|
192 | + $code = $self->getVoidCode($self->form->name, false); |
|
194 | 193 | |
195 | - pre ($self->getSharpCode ($self->form->name)); |
|
196 | - pre ('namespace VoidEngine;'. "\n\n" .'return new class' . substr ($code, 38) . ';'); |
|
194 | + pre($self->getSharpCode($self->form->name)); |
|
195 | + pre('namespace VoidEngine;'."\n\n".'return new class'.substr($code, 38).';'); |
|
197 | 196 | } |
198 | 197 | }); |
199 | 198 | }; |
200 | 199 | |
201 | 200 | $menu = new ContextMenuStrip; |
202 | 201 | |
203 | - $menu->items->addRange (isset ($desItem) ? [ |
|
202 | + $menu->items->addRange(isset ($desItem) ? [ |
|
204 | 203 | $selectAllItem, $copyItem, $pasteItem, $cutItem, $delItem, '-', |
205 | 204 | $toFrontItem, $toBackItem, $desItem, '-', |
206 | 205 | $undoItem, $redoItem, '-', |
@@ -212,91 +211,91 @@ discard block |
||
212 | 211 | $infoItem |
213 | 212 | ]); |
214 | 213 | |
215 | - $menu->show ($self->form, $self->form->pointToClient (\VoidCore::createObject ('System.Drawing.Point', false, $args->x, $args->y))); |
|
214 | + $menu->show($self->form, $self->form->pointToClient(\VoidCore::createObject('System.Drawing.Point', false, $args->x, $args->y))); |
|
216 | 215 | }; |
217 | 216 | |
218 | - VoidStudioAPI::addObjects ('main', ['Designer__'. $this->form->name .'Designer' => $this]); |
|
217 | + VoidStudioAPI::addObjects('main', ['Designer__'.$this->form->name.'Designer' => $this]); |
|
219 | 218 | } |
220 | 219 | |
221 | - public function focus (): void |
|
220 | + public function focus(): void |
|
222 | 221 | { |
223 | - $this->form->focus (); |
|
222 | + $this->form->focus(); |
|
224 | 223 | } |
225 | 224 | |
226 | - public function getSharpCode (string $formName): string |
|
225 | + public function getSharpCode(string $formName): string |
|
227 | 226 | { |
228 | - $code = $this->callMethod (['GetSharpCode', 'object'], $formName); |
|
227 | + $code = $this->callMethod(['GetSharpCode', 'object'], $formName); |
|
229 | 228 | |
230 | - $code = \VoidCore::callMethod ($code, ['Replace', 'object'], 'public class '. $this->form->name .' : '. $this->form->name, 'public class '. $this->form->name .' : System.Windows.Forms.Form'); |
|
231 | - $code = \VoidCore::callMethod ($code, ['Replace', 'object'], ' private ', ' public '); |
|
229 | + $code = \VoidCore::callMethod($code, ['Replace', 'object'], 'public class '.$this->form->name.' : '.$this->form->name, 'public class '.$this->form->name.' : System.Windows.Forms.Form'); |
|
230 | + $code = \VoidCore::callMethod($code, ['Replace', 'object'], ' private ', ' public '); |
|
232 | 231 | |
233 | - return \VoidCore::callMethod ($code, 'ToString'); |
|
232 | + return \VoidCore::callMethod($code, 'ToString'); |
|
234 | 233 | } |
235 | 234 | |
236 | - public function createComponent (array $component, string $componentName): int |
|
235 | + public function createComponent(array $component, string $componentName): int |
|
237 | 236 | { |
238 | 237 | $this->objects[$componentName] = $component; |
239 | - $selector = \VoidCore::createObject (...$component); |
|
238 | + $selector = \VoidCore::createObject(...$component); |
|
240 | 239 | |
241 | - $this->callMethod ('AddComponent', $selector, $componentName); |
|
240 | + $this->callMethod('AddComponent', $selector, $componentName); |
|
242 | 241 | |
243 | 242 | return $selector; |
244 | 243 | } |
245 | 244 | |
246 | - public function setComponentToHistory (array $component, string $componentName): void |
|
245 | + public function setComponentToHistory(array $component, string $componentName): void |
|
247 | 246 | { |
248 | 247 | $this->objects[$componentName] = $component; |
249 | 248 | } |
250 | 249 | |
251 | - public function addComponent (int $selector, string $componentName): void |
|
250 | + public function addComponent(int $selector, string $componentName): void |
|
252 | 251 | { |
253 | - $this->objects[$componentName] = [\VoidCore::callMethod (\VoidCore::callMethod ($selector, 'GetType'), 'ToString'), false]; |
|
252 | + $this->objects[$componentName] = [\VoidCore::callMethod(\VoidCore::callMethod($selector, 'GetType'), 'ToString'), false]; |
|
254 | 253 | |
255 | - $this->callMethod ('AddComponent', $selector, $componentName); |
|
254 | + $this->callMethod('AddComponent', $selector, $componentName); |
|
256 | 255 | } |
257 | 256 | |
258 | - public function removeComponent (int $component): void |
|
257 | + public function removeComponent(int $component): void |
|
259 | 258 | { |
260 | - unset ($this->objects[$this->getComponentName ($component)]); |
|
259 | + unset ($this->objects[$this->getComponentName($component)]); |
|
261 | 260 | |
262 | - $this->callMethod ('RemoveComponent', $component); |
|
261 | + $this->callMethod('RemoveComponent', $component); |
|
263 | 262 | } |
264 | 263 | |
265 | - public function removeComponentHistoryByName (string $name): void |
|
264 | + public function removeComponentHistoryByName(string $name): void |
|
266 | 265 | { |
267 | 266 | unset ($this->objects[$name]); |
268 | 267 | } |
269 | 268 | |
270 | - public function removeSelected (): void |
|
269 | + public function removeSelected(): void |
|
271 | 270 | { |
272 | 271 | $toUnset = []; |
273 | 272 | |
274 | - foreach ($this->getSelectedComponents ()->list as $object) |
|
273 | + foreach ($this->getSelectedComponents()->list as $object) |
|
275 | 274 | { |
276 | - if ($object->getType ()->toString () != 'System.Windows.Forms.Form') |
|
277 | - $toUnset[] = $this->getComponentName ($object->selector); |
|
275 | + if ($object->getType()->toString() != 'System.Windows.Forms.Form') |
|
276 | + $toUnset[] = $this->getComponentName($object->selector); |
|
278 | 277 | |
279 | 278 | else |
280 | 279 | { |
281 | 280 | if ($this->formsList->items->count > 1) |
282 | 281 | { |
283 | - if (messageBox ('Вы действительно хотите удалить форму "'. $this->form->name .'"?', 'Подтвердите действие', enum ('System.Windows.Forms.MessageBoxButtons.YesNo'), enum ('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
|
282 | + if (messageBox('Вы действительно хотите удалить форму "'.$this->form->name.'"?', 'Подтвердите действие', enum('System.Windows.Forms.MessageBoxButtons.YesNo'), enum('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
|
284 | 283 | { |
285 | 284 | foreach ($this->objects as $name => $obj) |
286 | 285 | unset ($this->objects[$name]); |
287 | 286 | |
288 | - unset ($this->formsList->items[array_flip ($this->formsList->items->names)[$form = $this->getComponentName ($object->selector)]]); |
|
287 | + unset ($this->formsList->items[array_flip($this->formsList->items->names)[$form = $this->getComponentName($object->selector)]]); |
|
289 | 288 | |
290 | 289 | /*$this->form->dispose (); |
291 | 290 | \VoidCore::callMethod ($this->control, 'Dispose');*/ |
292 | - $this->callMethod ('DeleteSelected'); |
|
291 | + $this->callMethod('DeleteSelected'); |
|
293 | 292 | |
294 | - $designer = VoidStudioAPI::getObjects ('main')['Designer__'. $this->formsList->selectedTab->text .'Designer']; |
|
293 | + $designer = VoidStudioAPI::getObjects('main')['Designer__'.$this->formsList->selectedTab->text.'Designer']; |
|
295 | 294 | |
296 | 295 | $designer->propertyGrid->selectedObject = $designer->form; |
297 | - $designer->setSelectedComponents ($designer->form); |
|
296 | + $designer->setSelectedComponents($designer->form); |
|
298 | 297 | |
299 | - unset (VoidStudioAPI::$objects['main']['Designer__'. $form .'Designer']); |
|
298 | + unset (VoidStudioAPI::$objects['main']['Designer__'.$form.'Designer']); |
|
300 | 299 | |
301 | 300 | return; |
302 | 301 | } |
@@ -304,7 +303,7 @@ discard block |
||
304 | 303 | |
305 | 304 | else |
306 | 305 | { |
307 | - messageBox ('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
|
306 | + messageBox('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Error')); |
|
308 | 307 | |
309 | 308 | return; |
310 | 309 | } |
@@ -314,52 +313,52 @@ discard block |
||
314 | 313 | foreach ($toUnset as $name) |
315 | 314 | unset ($this->objects[$name]); |
316 | 315 | |
317 | - $this->doAction ('delete'); |
|
316 | + $this->doAction('delete'); |
|
318 | 317 | |
319 | 318 | foreach ($this->objects as $objectName => $object) |
320 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
319 | + if (!is_int($this->getComponentByName($objectName))) |
|
321 | 320 | unset ($this->objects[$objectName]); |
322 | 321 | |
323 | - $this->currentSelectedItem->items->clear (); |
|
324 | - $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
|
325 | - $this->currentSelectedItem->selectedItem = $this->getComponentName ($this->getPrimarySelection ()->selector); |
|
322 | + $this->currentSelectedItem->items->clear(); |
|
323 | + $this->currentSelectedItem->items->addRange(array_keys($this->objects)); |
|
324 | + $this->currentSelectedItem->selectedItem = $this->getComponentName($this->getPrimarySelection()->selector); |
|
326 | 325 | } |
327 | 326 | |
328 | - public function renameComponent (int $component, string $name, string $fromName = null): void |
|
327 | + public function renameComponent(int $component, string $name, string $fromName = null): void |
|
329 | 328 | { |
330 | 329 | if ($fromName === null) |
331 | - $fromName = $this->getComponentName ($component); |
|
330 | + $fromName = $this->getComponentName($component); |
|
332 | 331 | |
333 | 332 | $info = $this->objects[$fromName]; |
334 | 333 | unset ($this->objects[$fromName]); |
335 | 334 | $this->objects[$name] = $info; |
336 | 335 | |
337 | - $this->callMethod ('RenameComponent', $component, $name); |
|
336 | + $this->callMethod('RenameComponent', $component, $name); |
|
338 | 337 | } |
339 | 338 | |
340 | - public function getComponentName (int $component): string |
|
339 | + public function getComponentName(int $component): string |
|
341 | 340 | { |
342 | - return $this->callMethod ('GetComponentName', $component); |
|
341 | + return $this->callMethod('GetComponentName', $component); |
|
343 | 342 | } |
344 | 343 | |
345 | - public function getComponentByName (string $name) |
|
344 | + public function getComponentByName(string $name) |
|
346 | 345 | { |
347 | - return $this->callMethod ('GetComponentByName', $name); |
|
346 | + return $this->callMethod('GetComponentByName', $name); |
|
348 | 347 | } |
349 | 348 | |
350 | - public function getComponentClass (string $name) |
|
349 | + public function getComponentClass(string $name) |
|
351 | 350 | { |
352 | 351 | return isset ($this->objects[$name]) ? |
353 | 352 | $this->objects[$name] : false; |
354 | 353 | } |
355 | 354 | |
356 | - public function addProperty (int $selector, string $name, int $value, bool $readOnly, string $category, string $description, bool $visible) |
|
355 | + public function addProperty(int $selector, string $name, int $value, bool $readOnly, string $category, string $description, bool $visible) |
|
357 | 356 | { |
358 | - $this->callMethod ('AddProperty', $selector, $name, $value, $readOnly, $category, $description, $visible); |
|
357 | + $this->callMethod('AddProperty', $selector, $name, $value, $readOnly, $category, $description, $visible); |
|
359 | 358 | } |
360 | 359 | |
361 | - public function removeProperty (int $selector, string $name) |
|
360 | + public function removeProperty(int $selector, string $name) |
|
362 | 361 | { |
363 | - $this->callMethod ('RemoveProperty', $selector, $name); |
|
362 | + $this->callMethod('RemoveProperty', $selector, $name); |
|
364 | 363 | } |
365 | 364 | } |
@@ -17,8 +17,9 @@ discard block |
||
17 | 17 | $this->form = $form === null ? new Form : |
18 | 18 | EngineAdditions::coupleSelector ($form); |
19 | 19 | |
20 | - if (!is_object ($this->form)) |
|
21 | - throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
20 | + if (!is_object ($this->form)) { |
|
21 | + throw new \Exception ('$form param in "VoidEngine\VoidDesigner" constructor must be instance of "VoidEngine\WFObject" ("VoidEngine\Form") or be object selector'); |
|
22 | + } |
|
22 | 23 | |
23 | 24 | $this->propertyGrid = $propertyGrid; |
24 | 25 | $this->currentSelectedItem = $currentSelectedItem; |
@@ -104,9 +105,10 @@ discard block |
||
104 | 105 | $name = $this->getComponentName ($args->component->selector); |
105 | 106 | unset ($this->objects[$name]); |
106 | 107 | |
107 | - foreach ($this->objects as $objectName => $object) |
|
108 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
109 | - unset ($this->objects[$objectName]); |
|
108 | + foreach ($this->objects as $objectName => $object) { |
|
109 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
110 | + unset ($this->objects[$objectName]); |
|
111 | + } |
|
110 | 112 | |
111 | 113 | $this->currentSelectedItem->items->clear (); |
112 | 114 | $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
@@ -273,17 +275,17 @@ discard block |
||
273 | 275 | |
274 | 276 | foreach ($this->getSelectedComponents ()->list as $object) |
275 | 277 | { |
276 | - if ($object->getType ()->toString () != 'System.Windows.Forms.Form') |
|
277 | - $toUnset[] = $this->getComponentName ($object->selector); |
|
278 | - |
|
279 | - else |
|
278 | + if ($object->getType ()->toString () != 'System.Windows.Forms.Form') { |
|
279 | + $toUnset[] = $this->getComponentName ($object->selector); |
|
280 | + } else |
|
280 | 281 | { |
281 | 282 | if ($this->formsList->items->count > 1) |
282 | 283 | { |
283 | 284 | if (messageBox ('Вы действительно хотите удалить форму "'. $this->form->name .'"?', 'Подтвердите действие', enum ('System.Windows.Forms.MessageBoxButtons.YesNo'), enum ('System.Windows.Forms.MessageBoxIcon.Question')) == 6) |
284 | 285 | { |
285 | - foreach ($this->objects as $name => $obj) |
|
286 | - unset ($this->objects[$name]); |
|
286 | + foreach ($this->objects as $name => $obj) { |
|
287 | + unset ($this->objects[$name]); |
|
288 | + } |
|
287 | 289 | |
288 | 290 | unset ($this->formsList->items[array_flip ($this->formsList->items->names)[$form = $this->getComponentName ($object->selector)]]); |
289 | 291 | |
@@ -300,9 +302,7 @@ discard block |
||
300 | 302 | |
301 | 303 | return; |
302 | 304 | } |
303 | - } |
|
304 | - |
|
305 | - else |
|
305 | + } else |
|
306 | 306 | { |
307 | 307 | messageBox ('Нельзя удалить единственную форму проекта', 'Ошибка удаления', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
308 | 308 | |
@@ -311,14 +311,16 @@ discard block |
||
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
314 | - foreach ($toUnset as $name) |
|
315 | - unset ($this->objects[$name]); |
|
314 | + foreach ($toUnset as $name) { |
|
315 | + unset ($this->objects[$name]); |
|
316 | + } |
|
316 | 317 | |
317 | 318 | $this->doAction ('delete'); |
318 | 319 | |
319 | - foreach ($this->objects as $objectName => $object) |
|
320 | - if (!is_int ($this->getComponentByName ($objectName))) |
|
321 | - unset ($this->objects[$objectName]); |
|
320 | + foreach ($this->objects as $objectName => $object) { |
|
321 | + if (!is_int ($this->getComponentByName ($objectName))) |
|
322 | + unset ($this->objects[$objectName]); |
|
323 | + } |
|
322 | 324 | |
323 | 325 | $this->currentSelectedItem->items->clear (); |
324 | 326 | $this->currentSelectedItem->items->addRange (array_keys ($this->objects)); |
@@ -327,8 +329,9 @@ discard block |
||
327 | 329 | |
328 | 330 | public function renameComponent (int $component, string $name, string $fromName = null): void |
329 | 331 | { |
330 | - if ($fromName === null) |
|
331 | - $fromName = $this->getComponentName ($component); |
|
332 | + if ($fromName === null) { |
|
333 | + $fromName = $this->getComponentName ($component); |
|
334 | + } |
|
332 | 335 | |
333 | 336 | $info = $this->objects[$fromName]; |
334 | 337 | unset ($this->objects[$fromName]); |
@@ -4,14 +4,14 @@ discard block |
||
4 | 4 | |
5 | 5 | class ClassWorker |
6 | 6 | { |
7 | - public static function applyClass (string $code, string $class, string $apply): string |
|
7 | + public static function applyClass(string $code, string $class, string $apply): string |
|
8 | 8 | { |
9 | - $code = self::stripComments ($code); |
|
9 | + $code = self::stripComments($code); |
|
10 | 10 | |
11 | 11 | $split1 = $split2 = false; |
12 | 12 | |
13 | - $len = strlen ($code); |
|
14 | - $classLen = strlen ($class); |
|
13 | + $len = strlen($code); |
|
14 | + $classLen = strlen($class); |
|
15 | 15 | |
16 | 16 | $class_predefined = false; |
17 | 17 | $class_close = null; |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | |
27 | 27 | elseif (!$split1 && !$split2) |
28 | 28 | { |
29 | - if ($code[$i] == 'c' && substr ($code, $i, 5) == 'class') |
|
29 | + if ($code[$i] == 'c' && substr($code, $i, 5) == 'class') |
|
30 | 30 | { |
31 | 31 | for ($j = $i + 5; $j < $len; ++$j) |
32 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
32 | + if (in_array($code[$j], ["\n", "\r", "\t", ' '])) |
|
33 | 33 | continue; |
34 | 34 | |
35 | 35 | else |
36 | 36 | { |
37 | - if (substr ($code, $j, $classLen) == $class) |
|
37 | + if (substr($code, $j, $classLen) == $class) |
|
38 | 38 | $class_predefined = true; |
39 | 39 | |
40 | 40 | $i = $j; |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | --$class_close; |
58 | 58 | |
59 | 59 | if ($class_close === 0) |
60 | - return substr ($code, 0, $i) . $apply . substr ($code, $i); |
|
60 | + return substr($code, 0, $i).$apply.substr($code, $i); |
|
61 | 61 | } |
62 | 62 | } |
63 | 63 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | return $code; |
66 | 66 | } |
67 | 67 | |
68 | - public static function getAvailableClassMethods (string $code, string $class): array |
|
68 | + public static function getAvailableClassMethods(string $code, string $class): array |
|
69 | 69 | { |
70 | - $code = self::stripComments ($code); |
|
70 | + $code = self::stripComments($code); |
|
71 | 71 | |
72 | 72 | $split1 = $split2 = false; |
73 | 73 | |
74 | - $len = strlen ($code); |
|
75 | - $classLen = strlen ($class); |
|
74 | + $len = strlen($code); |
|
75 | + $classLen = strlen($class); |
|
76 | 76 | |
77 | 77 | $class_predefined = false; |
78 | 78 | $class_close = null; |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | |
90 | 90 | elseif (!$split1 && !$split2) |
91 | 91 | { |
92 | - if ($code[$i] == 'c' && substr ($code, $i, 5) == 'class') |
|
92 | + if ($code[$i] == 'c' && substr($code, $i, 5) == 'class') |
|
93 | 93 | { |
94 | 94 | for ($j = $i + 5; $j < $len; ++$j) |
95 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
95 | + if (in_array($code[$j], ["\n", "\r", "\t", ' '])) |
|
96 | 96 | continue; |
97 | 97 | |
98 | 98 | else |
99 | 99 | { |
100 | - if (substr ($code, $j, $classLen) == $class) |
|
100 | + if (substr($code, $j, $classLen) == $class) |
|
101 | 101 | $class_predefined = true; |
102 | 102 | |
103 | 103 | $i = $j; |
@@ -108,27 +108,27 @@ discard block |
||
108 | 108 | |
109 | 109 | elseif ($class_predefined == true) |
110 | 110 | { |
111 | - if ($code[$i] == 'p' && substr ($code, $i, 6) == 'public') |
|
111 | + if ($code[$i] == 'p' && substr($code, $i, 6) == 'public') |
|
112 | 112 | { |
113 | 113 | for ($j = $i + 6; $j < $len; ++$j) |
114 | - if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
114 | + if (!in_array($code[$j], ["\n", "\r", "\t", ' '])) |
|
115 | 115 | break; |
116 | 116 | |
117 | - if ($code[$j] == 's' && substr ($code, $j, 6) == 'static') |
|
117 | + if ($code[$j] == 's' && substr($code, $j, 6) == 'static') |
|
118 | 118 | for ($j = $j + 6; $j < $len; ++$j) |
119 | - if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
119 | + if (!in_array($code[$j], ["\n", "\r", "\t", ' '])) |
|
120 | 120 | break; |
121 | 121 | |
122 | - if ($code[$j] == 'f' && substr ($code, $j, 8) == 'function') |
|
122 | + if ($code[$j] == 'f' && substr($code, $j, 8) == 'function') |
|
123 | 123 | { |
124 | 124 | for ($j = $j + 8; $j < $len; ++$j) |
125 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
125 | + if (in_array($code[$j], ["\n", "\r", "\t", ' '])) |
|
126 | 126 | continue; |
127 | 127 | |
128 | 128 | else |
129 | 129 | { |
130 | 130 | $i = $j; |
131 | - $methods[] = trim (substr ($code, $j, strpos ($code, '(', $j) - $j)); |
|
131 | + $methods[] = trim(substr($code, $j, strpos($code, '(', $j) - $j)); |
|
132 | 132 | |
133 | 133 | break; |
134 | 134 | } |
@@ -155,13 +155,13 @@ discard block |
||
155 | 155 | return $methods; |
156 | 156 | } |
157 | 157 | |
158 | - public static function stripComments (string $code): string |
|
158 | + public static function stripComments(string $code): string |
|
159 | 159 | { |
160 | - $tokens = token_get_all ("<?php\n\n". $code); |
|
160 | + $tokens = token_get_all("<?php\n\n".$code); |
|
161 | 161 | $return = ''; |
162 | 162 | |
163 | 163 | foreach ($tokens as $token) |
164 | - if (is_string ($token)) |
|
164 | + if (is_string($token)) |
|
165 | 165 | $return .= $token; |
166 | 166 | |
167 | 167 | else |
@@ -181,6 +181,6 @@ discard block |
||
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | - return substr ($return, 7); |
|
184 | + return substr($return, 7); |
|
185 | 185 | } |
186 | 186 | } |
@@ -18,46 +18,45 @@ discard block |
||
18 | 18 | |
19 | 19 | for ($i = 0; $i < $len; ++$i) |
20 | 20 | { |
21 | - if ($code[$i] == '\'' && !$split2) |
|
22 | - $split1 = !$split1; |
|
23 | - |
|
24 | - elseif ($code[$i] == '"' && !$split1) |
|
25 | - $split2 = !$split2; |
|
26 | - |
|
27 | - elseif (!$split1 && !$split2) |
|
21 | + if ($code[$i] == '\'' && !$split2) { |
|
22 | + $split1 = !$split1; |
|
23 | + } elseif ($code[$i] == '"' && !$split1) { |
|
24 | + $split2 = !$split2; |
|
25 | + } elseif (!$split1 && !$split2) |
|
28 | 26 | { |
29 | 27 | if ($code[$i] == 'c' && substr ($code, $i, 5) == 'class') |
30 | 28 | { |
31 | - for ($j = $i + 5; $j < $len; ++$j) |
|
32 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
33 | - continue; |
|
29 | + for ($j = $i + 5; $j < $len; ++$j) { |
|
30 | + if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
31 | + continue; |
|
32 | + } |
|
34 | 33 | |
35 | 34 | else |
36 | 35 | { |
37 | - if (substr ($code, $j, $classLen) == $class) |
|
38 | - $class_predefined = true; |
|
36 | + if (substr ($code, $j, $classLen) == $class) { |
|
37 | + $class_predefined = true; |
|
38 | + } |
|
39 | 39 | |
40 | 40 | $i = $j; |
41 | 41 | |
42 | 42 | break; |
43 | 43 | } |
44 | - } |
|
45 | - |
|
46 | - elseif ($class_predefined == true) |
|
44 | + } elseif ($class_predefined == true) |
|
47 | 45 | { |
48 | 46 | if ($code[$i] == '{') |
49 | 47 | { |
50 | - if ($class_close === null) |
|
51 | - $class_close = 1; |
|
52 | - |
|
53 | - else ++$class_close; |
|
54 | - } |
|
55 | - |
|
56 | - elseif ($code[$i] == '}') |
|
57 | - --$class_close; |
|
58 | - |
|
59 | - if ($class_close === 0) |
|
60 | - return substr ($code, 0, $i) . $apply . substr ($code, $i); |
|
48 | + if ($class_close === null) { |
|
49 | + $class_close = 1; |
|
50 | + } else { |
|
51 | + ++$class_close; |
|
52 | + } |
|
53 | + } elseif ($code[$i] == '}') { |
|
54 | + --$class_close; |
|
55 | + } |
|
56 | + |
|
57 | + if ($class_close === 0) { |
|
58 | + return substr ($code, 0, $i) . $apply . substr ($code, $i); |
|
59 | + } |
|
61 | 60 | } |
62 | 61 | } |
63 | 62 | } |
@@ -81,49 +80,52 @@ discard block |
||
81 | 80 | |
82 | 81 | for ($i = 0; $i < $len; ++$i) |
83 | 82 | { |
84 | - if ($code[$i] == '\'' && !$split2) |
|
85 | - $split1 = !$split1; |
|
86 | - |
|
87 | - elseif ($code[$i] == '"' && !$split1) |
|
88 | - $split2 = !$split2; |
|
89 | - |
|
90 | - elseif (!$split1 && !$split2) |
|
83 | + if ($code[$i] == '\'' && !$split2) { |
|
84 | + $split1 = !$split1; |
|
85 | + } elseif ($code[$i] == '"' && !$split1) { |
|
86 | + $split2 = !$split2; |
|
87 | + } elseif (!$split1 && !$split2) |
|
91 | 88 | { |
92 | 89 | if ($code[$i] == 'c' && substr ($code, $i, 5) == 'class') |
93 | 90 | { |
94 | - for ($j = $i + 5; $j < $len; ++$j) |
|
95 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
96 | - continue; |
|
91 | + for ($j = $i + 5; $j < $len; ++$j) { |
|
92 | + if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
93 | + continue; |
|
94 | + } |
|
97 | 95 | |
98 | 96 | else |
99 | 97 | { |
100 | - if (substr ($code, $j, $classLen) == $class) |
|
101 | - $class_predefined = true; |
|
98 | + if (substr ($code, $j, $classLen) == $class) { |
|
99 | + $class_predefined = true; |
|
100 | + } |
|
102 | 101 | |
103 | 102 | $i = $j; |
104 | 103 | |
105 | 104 | break; |
106 | 105 | } |
107 | - } |
|
108 | - |
|
109 | - elseif ($class_predefined == true) |
|
106 | + } elseif ($class_predefined == true) |
|
110 | 107 | { |
111 | 108 | if ($code[$i] == 'p' && substr ($code, $i, 6) == 'public') |
112 | 109 | { |
113 | - for ($j = $i + 6; $j < $len; ++$j) |
|
114 | - if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
115 | - break; |
|
116 | - |
|
117 | - if ($code[$j] == 's' && substr ($code, $j, 6) == 'static') |
|
118 | - for ($j = $j + 6; $j < $len; ++$j) |
|
119 | - if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
120 | - break; |
|
110 | + for ($j = $i + 6; $j < $len; ++$j) { |
|
111 | + if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
112 | + break; |
|
113 | + } |
|
114 | + |
|
115 | + if ($code[$j] == 's' && substr ($code, $j, 6) == 'static') { |
|
116 | + for ($j = $j + 6; |
|
117 | + } |
|
118 | + $j < $len; ++$j) { |
|
119 | + if (!in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
120 | + break; |
|
121 | + } |
|
121 | 122 | |
122 | 123 | if ($code[$j] == 'f' && substr ($code, $j, 8) == 'function') |
123 | 124 | { |
124 | - for ($j = $j + 8; $j < $len; ++$j) |
|
125 | - if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
126 | - continue; |
|
125 | + for ($j = $j + 8; $j < $len; ++$j) { |
|
126 | + if (in_array ($code[$j], ["\n", "\r", "\t", ' '])) |
|
127 | + continue; |
|
128 | + } |
|
127 | 129 | |
128 | 130 | else |
129 | 131 | { |
@@ -133,21 +135,20 @@ discard block |
||
133 | 135 | break; |
134 | 136 | } |
135 | 137 | } |
136 | - } |
|
137 | - |
|
138 | - elseif ($code[$i] == '{') |
|
138 | + } elseif ($code[$i] == '{') |
|
139 | 139 | { |
140 | - if ($class_close === null) |
|
141 | - $class_close = 1; |
|
142 | - |
|
143 | - else ++$class_close; |
|
144 | - } |
|
145 | - |
|
146 | - elseif ($code[$i] == '}') |
|
147 | - --$class_close; |
|
148 | - |
|
149 | - if ($class_close === 0) |
|
150 | - return $methods; |
|
140 | + if ($class_close === null) { |
|
141 | + $class_close = 1; |
|
142 | + } else { |
|
143 | + ++$class_close; |
|
144 | + } |
|
145 | + } elseif ($code[$i] == '}') { |
|
146 | + --$class_close; |
|
147 | + } |
|
148 | + |
|
149 | + if ($class_close === 0) { |
|
150 | + return $methods; |
|
151 | + } |
|
151 | 152 | } |
152 | 153 | } |
153 | 154 | } |
@@ -160,9 +161,10 @@ discard block |
||
160 | 161 | $tokens = token_get_all ("<?php\n\n". $code); |
161 | 162 | $return = ''; |
162 | 163 | |
163 | - foreach ($tokens as $token) |
|
164 | - if (is_string ($token)) |
|
165 | - $return .= $token; |
|
164 | + foreach ($tokens as $token) { |
|
165 | + if (is_string ($token)) |
|
166 | + $return .= $token; |
|
167 | + } |
|
166 | 168 | |
167 | 169 | else |
168 | 170 | { |
@@ -8,85 +8,84 @@ |
||
8 | 8 | public static array $events = []; |
9 | 9 | public static $project; |
10 | 10 | |
11 | - public static function addObjects (string $group, array $objects) |
|
11 | + public static function addObjects(string $group, array $objects) |
|
12 | 12 | { |
13 | - self::$objects[$group] = array_merge |
|
14 | - ( |
|
13 | + self::$objects[$group] = array_merge( |
|
15 | 14 | self::$objects[$group] ?? [], |
16 | 15 | $objects |
17 | 16 | ); |
18 | 17 | } |
19 | 18 | |
20 | - public static function getObjects (string $group) |
|
19 | + public static function getObjects(string $group) |
|
21 | 20 | { |
22 | 21 | return self::$objects[$group] ?? false; |
23 | 22 | } |
24 | 23 | |
25 | - public static function openEventEditor (int $component, string $method, WFObject $eventDescriptor, string $form, VoidDesigner $designer = null) |
|
24 | + public static function openEventEditor(int $component, string $method, WFObject $eventDescriptor, string $form, VoidDesigner $designer = null) |
|
26 | 25 | { |
27 | - $objects = self::getObjects ('editor'); |
|
26 | + $objects = self::getObjects('editor'); |
|
28 | 27 | $editor = $objects['Editor']; |
29 | 28 | |
30 | 29 | $args = []; |
31 | 30 | |
32 | 31 | $eventDescriptor->eventType |
33 | - ->getMethod ('Invoke') |
|
34 | - ->getParameters () |
|
35 | - ->foreach (function ($param) use (&$args) |
|
32 | + ->getMethod('Invoke') |
|
33 | + ->getParameters() |
|
34 | + ->foreach(function($param) use (&$args) |
|
36 | 35 | { |
37 | - $args[] = $param->parameterType->toString (); |
|
36 | + $args[] = $param->parameterType->toString(); |
|
38 | 37 | }); |
39 | 38 | |
40 | - $args = array_slice ($args, 1); |
|
39 | + $args = array_slice($args, 1); |
|
41 | 40 | $comments = ''; |
42 | 41 | |
43 | 42 | foreach ($args as $id => $arg) |
44 | 43 | { |
45 | - $comments .= "\n\t * @param WFObject \$args". ($id > 0 ? $id : '') .' - '. $arg; |
|
44 | + $comments .= "\n\t * @param WFObject \$args".($id > 0 ? $id : '').' - '.$arg; |
|
46 | 45 | |
47 | - $args[$id] = '$args'. ($id > 0 ? $id : ''); |
|
46 | + $args[$id] = '$args'.($id > 0 ? $id : ''); |
|
48 | 47 | } |
49 | 48 | |
50 | 49 | $comments = "\t/**\n\t * @method $method\n\n\t * @param WFObject \$self$comments\n\t */"; |
51 | 50 | |
52 | 51 | if (!isset (self::$events[$form])) |
53 | - self::$events[$form] = "class $form extends Form\n{\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n}\n"; |
|
52 | + self::$events[$form] = "class $form extends Form\n{\n$comments\n\tpublic function $method (WFObject \$self, ".implode(', ', $args).")\n\t{\n\t\t\n\t}\n}\n"; |
|
54 | 53 | |
55 | 54 | // preg_match ('/function(\s)*'. $method .'(\s)*\(/i', self::$events[$form]) |
56 | - elseif (!in_array ($method, ClassWorker::getAvailableClassMethods (self::$events[$form], $form))) |
|
57 | - self::$events[$form] = ClassWorker::applyClass (self::$events[$form], $form, "\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n"); |
|
55 | + elseif (!in_array($method, ClassWorker::getAvailableClassMethods(self::$events[$form], $form))) |
|
56 | + self::$events[$form] = ClassWorker::applyClass(self::$events[$form], $form, "\n$comments\n\tpublic function $method (WFObject \$self, ".implode(', ', $args).")\n\t{\n\t\t\n\t}\n"); |
|
58 | 57 | |
59 | 58 | $editor->text = self::$events[$form]; |
60 | 59 | $editor->helpStorage = $form; |
61 | 60 | |
62 | 61 | // $form->caption = 'Событие "'. $event .'", объект "'. ($designer === null ? \VoidCore::getProperty ($component, 'Name') : $designer->getComponentName ($component)) .'"'; |
63 | 62 | |
64 | - $objects['MainForm']->showDialog (); |
|
63 | + $objects['MainForm']->showDialog(); |
|
65 | 64 | } |
66 | 65 | |
67 | - public static function stopProject () |
|
66 | + public static function stopProject() |
|
68 | 67 | { |
69 | 68 | if (self::$project instanceof WFObject && !self::$project->hasExited) |
70 | 69 | { |
71 | - self::$project->kill (); |
|
72 | - self::$project->waitForExit (); |
|
70 | + self::$project->kill(); |
|
71 | + self::$project->waitForExit(); |
|
73 | 72 | } |
74 | 73 | } |
75 | 74 | |
76 | - public static function startProject (TabControl $formsList, bool $debug = true): ?WFObject |
|
75 | + public static function startProject(TabControl $formsList, bool $debug = true): ?WFObject |
|
77 | 76 | { |
78 | - self::stopProject (); |
|
77 | + self::stopProject(); |
|
79 | 78 | |
80 | 79 | try |
81 | 80 | { |
82 | - VoidStudioBuilder::compileProject (VoidStudioProjectManager::$projectPath .'/build.exe', $formsList->items[0]->text, VoidStudioBuilder::getReferences (ENGINE_DIR .'/VoidEngine.php'), [], false, $debug); |
|
81 | + VoidStudioBuilder::compileProject(VoidStudioProjectManager::$projectPath.'/build.exe', $formsList->items[0]->text, VoidStudioBuilder::getReferences(ENGINE_DIR.'/VoidEngine.php'), [], false, $debug); |
|
83 | 82 | |
84 | - self::$project = run (VoidStudioProjectManager::$projectPath .'/build/build.exe'); |
|
83 | + self::$project = run(VoidStudioProjectManager::$projectPath.'/build/build.exe'); |
|
85 | 84 | } |
86 | 85 | |
87 | 86 | catch (\Throwable $e) |
88 | 87 | { |
89 | - messageBox ('Нельзя сохранить проект или произошла ошибка компиляции' ."\n\nПодробнее:\n\n". print_r ($e, true), 'Ошибка запуска проекта', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
|
88 | + messageBox('Нельзя сохранить проект или произошла ошибка компиляции'."\n\nПодробнее:\n\n".print_r($e, true), 'Ошибка запуска проекта', enum('System.Windows.Forms.MessageBoxButtons.OK'), enum('System.Windows.Forms.MessageBoxIcon.Error')); |
|
90 | 89 | |
91 | 90 | return null; |
92 | 91 | } |
@@ -49,12 +49,14 @@ discard block |
||
49 | 49 | |
50 | 50 | $comments = "\t/**\n\t * @method $method\n\n\t * @param WFObject \$self$comments\n\t */"; |
51 | 51 | |
52 | - if (!isset (self::$events[$form])) |
|
53 | - self::$events[$form] = "class $form extends Form\n{\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n}\n"; |
|
52 | + if (!isset (self::$events[$form])) { |
|
53 | + self::$events[$form] = "class $form extends Form\n{\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n}\n"; |
|
54 | + } |
|
54 | 55 | |
55 | 56 | // preg_match ('/function(\s)*'. $method .'(\s)*\(/i', self::$events[$form]) |
56 | - elseif (!in_array ($method, ClassWorker::getAvailableClassMethods (self::$events[$form], $form))) |
|
57 | - self::$events[$form] = ClassWorker::applyClass (self::$events[$form], $form, "\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n"); |
|
57 | + elseif (!in_array ($method, ClassWorker::getAvailableClassMethods (self::$events[$form], $form))) { |
|
58 | + self::$events[$form] = ClassWorker::applyClass (self::$events[$form], $form, "\n$comments\n\tpublic function $method (WFObject \$self, ". implode (', ', $args) .")\n\t{\n\t\t\n\t}\n"); |
|
59 | + } |
|
58 | 60 | |
59 | 61 | $editor->text = self::$events[$form]; |
60 | 62 | $editor->helpStorage = $form; |
@@ -82,9 +84,7 @@ discard block |
||
82 | 84 | VoidStudioBuilder::compileProject (VoidStudioProjectManager::$projectPath .'/build.exe', $formsList->items[0]->text, VoidStudioBuilder::getReferences (ENGINE_DIR .'/VoidEngine.php'), [], false, $debug); |
83 | 85 | |
84 | 86 | self::$project = run (VoidStudioProjectManager::$projectPath .'/build/build.exe'); |
85 | - } |
|
86 | - |
|
87 | - catch (\Throwable $e) |
|
87 | + } catch (\Throwable $e) |
|
88 | 88 | { |
89 | 89 | messageBox ('Нельзя сохранить проект или произошла ошибка компиляции' ."\n\nПодробнее:\n\n". print_r ($e, true), 'Ошибка запуска проекта', enum ('System.Windows.Forms.MessageBoxButtons.OK'), enum ('System.Windows.Forms.MessageBoxIcon.Error')); |
90 | 90 |