This commit is contained in:
shadowik 2022-11-29 08:44:44 +04:00
parent 112a806373
commit 728e355b50

View File

@ -59,7 +59,7 @@ public class ControllerMapWithSetBus {
private void initialize(){
gc = canvasBus.getGraphicsContext2D();
if (selected != null) {
showStorage();
ShowStorage();
}
if (_mapsCollection == null)
_mapsCollection = new MapsCollection((int) canvasBus.getWidth(), (int) canvasBus.getHeight());
@ -68,7 +68,7 @@ public class ControllerMapWithSetBus {
listViewMaps.getSelectionModel().selectedItemProperty()
.addListener((observableValue, s, t1) -> {
selected = t1;
showStorage();
ShowStorage();
});
listViewMaps.setItems(_mapsCollection.toObserveList());
}
@ -109,16 +109,16 @@ public class ControllerMapWithSetBus {
{
return;
}
Stage stageArmoredVehicleConfig = new Stage();
Stage stageBus = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(Form.class.getResource("FormBusConfig.fxml"));
Scene sceneArmoredVehicle = new Scene(fxmlLoader.load());
Scene sceneBus = new Scene(fxmlLoader.load());
stageArmoredVehicleConfig.setScene(sceneArmoredVehicle);
stageArmoredVehicleConfig.show();
stageBus.setScene(sceneBus);
stageBus.show();
ControllerBusConfig controllerArmoredVehicleConfig = fxmlLoader.getController();
controllerArmoredVehicleConfig.AddEvent(this::AddBus);
controllerArmoredVehicleConfig.SetStage(stageArmoredVehicleConfig);
ControllerBusConfig controller = fxmlLoader.getController();
controller.AddEvent(this::AddBus);
controller.SetStage(stageBus);
FirstIncome();
}
@ -128,20 +128,22 @@ public class ControllerMapWithSetBus {
{
return;
}
DrawingObjectBus objectArmoredVehicle = new DrawingObjectBus(bus);
DrawingObjectBus objectBus = new DrawingObjectBus(bus);
String selectedMapName = listViewMaps.getSelectionModel().getSelectedItem();
Alert alert;
if (selectedMapName != null && selectedMapName.length() != 0 && _mapsCollection.get(selectedMapName).add(objectArmoredVehicle) != -1)
if (selectedMapName != null && selectedMapName.length() != 0 && _mapsCollection.get(selectedMapName).add(objectBus) != -1)
{
alert = new Alert(Alert.AlertType.INFORMATION, "Объект добавлен", ButtonType.OK);
_mapsCollection.get(selectedMapName).ShowSet(gc);
ShowStorage();
}
else
{
alert = new Alert(Alert.AlertType.ERROR, "Не удалось добавить объект", ButtonType.OK);
}
alert.showAndWait();
}
@FXML
@ -165,7 +167,7 @@ public class ControllerMapWithSetBus {
}
_mapsCollection.AddMap(TextFieldMap.getText(), _mapsDict.get(comboBoxSelectorMap.getValue()));
ReloadMaps();
showStorage();
ShowStorage();
}
@FXML
private void ButtonDeleteMap_Click(ActionEvent event)
@ -176,7 +178,7 @@ public class ControllerMapWithSetBus {
}
_mapsCollection.DelMap(listViewMaps.getSelectionModel().getSelectedItem());
ReloadMaps();
showStorage();
ShowStorage();
}
@FXML
@ -236,19 +238,23 @@ public class ControllerMapWithSetBus {
alert.setContentText("Не удалось удалить объект");
option = alert.showAndWait();
}
showStorage();
ShowStorage();
}
@FXML
private void ButtonShowStorage_Click(ActionEvent event)
{
FirstIncome();
showStorage();
ShowStorage();
}
@FXML
private void ButtonShowOnMap_Click(ActionEvent event) {
FirstIncome();
ShowMap();
}
private void ShowMap() {
if (selected == null) {
return;
}
@ -276,13 +282,13 @@ public class ControllerMapWithSetBus {
_mapsCollection.GetId(selected).MoveObject(dir);
}
private void showStorage() {
private void ShowStorage() {
if (selected == null)
{
return;
}
gc.setFill(Color.WHITE);
gc.fillRect(0, 0, pictureBoxBus.getWidth(), pictureBoxBus.getHeight());
gc.clearRect(0, 0, canvasBus.getWidth(), canvasBus.getHeight());
_mapsCollection.GetId(selected).ShowSet(gc);
}