package ch.zhaw.prog2.fxmlcalculator;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

import java.io.IOException;

/**
 * Main-Application. Opens the first window (MainWindow) and the common ValueHandler
 * @author
 * @version 1.0
 */
public class Main extends Application {

    private ValueHandler valueHandler;

    private static final String INFO = """
        Enter valid values to
        - Initial amount (> 0)
        - Return in % (can be +/- or 0)
        - Annual Costs (> 0)
        - Number of years (> 0)
        Calculate displays the annual balance development!";
        """;

	public static void main(String[] args) {
		launch(args);
	}



	@Override
	public void start(Stage primaryStage) {
		valueHandler = new ValueHandler();
		mainWindow(primaryStage);
	}

	private void mainWindow(Stage primaryStage) {
		//load main window
        try {


            FXMLLoader mainWindowLoader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
            Pane rootNode = mainWindowLoader.load();

            MainWindowController mainWindowController = mainWindowLoader.getController();
            mainWindowController.setValueHandler(new ValueHandler());
            mainWindowController.setHelpText(INFO);
            Scene mainWindowScene = new Scene(rootNode);

            primaryStage.setScene(mainWindowScene);
            primaryStage.setMinWidth(400);
            primaryStage.setMinHeight(320);
            primaryStage.show();
        } catch(Exception e) {
            e.printStackTrace();
        }
	}







}

