package project_2;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Paint;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;

public class MainScene {
	
	/*
	 * This is the main scene of GUI
	 * */
	private LinkedList<Equation> validEquation;
	private LinkedList<Equation> invalidEquation;
	private LinkedList<Equation> allEquations;
	private Stage stage = new Stage();
	private GridPane pane =new GridPane();
	private RadioButton valid = new RadioButton("print Valid Equation ");
	private RadioButton invalid = new RadioButton("Print Invalid Equation ");
	private ToggleGroup tg = new ToggleGroup();
	Button submit =new Button("Submit"); 
	Button print = new Button("Print On File");
	private Label nam = new Label("Mohammad Nabil");
	
	public MainScene(LinkedList<Equation> validEquation, LinkedList<Equation> invalidEquation,
			LinkedList<Equation> allEquations) {
		super();
		this.validEquation = validEquation;
		this.invalidEquation = invalidEquation;
		this.allEquations=allEquations;
	}

	public void show(){
		
		Text title = new Text("Choose One Of These  :");
		title.setFill(Paint.valueOf("#FF0000"));
		title.setFont(Font.font("verdana",FontWeight.BOLD,24));
		
		valid.setToggleGroup(tg);
		invalid.setToggleGroup(tg);
		
		valid.setStyle("-fx-font-size:24px;");
		invalid.setStyle("-fx-font-size:24px;");
		valid.setTextFill(Paint.valueOf("gold"));
		invalid.setTextFill(Paint.valueOf("gold"));
		
		submit.setStyle("-fx-font-size:20px;");
		print.setStyle("-fx-font-size:20px;");
		
		submit.setOnAction(e->{
			if(valid.isSelected()){
				new PrintValid(validEquation).show();
			}
			if(invalid.isSelected()){
				new PrintinValid(invalidEquation).show();
			}
		});
		
		print.setOnAction(e->{
			Alert a = new Alert(AlertType.INFORMATION);
			a.setContentText("successfully Printed :)");
			new PrintOnFile(allEquations,validEquation, invalidEquation).print();
			a.show();
		});
		
		pane.setAlignment(Pos.CENTER);
		pane.setHgap(15);
		pane.setVgap(15);
		
		nam.setTextFill(Paint.valueOf("#c0e51b"));
		nam.setFont(Font.font("algerian",FontWeight.BOLD,15));
		
		pane.add(title, 0, 0);
		pane.add(valid,0, 1);
		pane.add(invalid, 0, 2);
		pane.add(submit, 2, 3);
		pane.add(print, 2, 4);
		pane.add(nam, 0, 5);
		
		Scene s = new Scene(pane,600,400);
		 s.getStylesheets().addAll(this.getClass().getResource("application.css").toExternalForm());
		stage.setScene(s);
		stage.setTitle("Welcome :)");
		stage.show();
		
	}
}
