Skip to content

Commit

Permalink
new update
Browse files Browse the repository at this point in the history
  • Loading branch information
7odaifa-ab committed Sep 26, 2021
1 parent 1a21c6e commit 2306517
Show file tree
Hide file tree
Showing 23 changed files with 787 additions and 55 deletions.
Binary file added .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions LICENSE.md

This file was deleted.

31 changes: 0 additions & 31 deletions README.md

This file was deleted.

Empty file added gradle.properties
Empty file.
73 changes: 73 additions & 0 deletions src/main/java/HuimangTech/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package HuimangTech;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicReference;

/**
* @Authour 7odaifa_ab
*/
public class App extends Application {

private static Scene scene;
public static Stage primaryStage = null;

@Override
public void start(Stage stage) throws IOException {
scene = new Scene(loadFXML("MainUI"));
stage.setScene(scene);
stage.initStyle(StageStyle.UNDECORATED);
stage.show();
primaryStage = stage;
makeStageDraggable();
}

static void setRoot(String fxml) throws IOException {
scene.setRoot(loadFXML(fxml));
}

private static Parent loadFXML(String fxml) throws IOException {
ResourceBundle bundle = ResourceBundle.getBundle("resources.bundles.TaskTimer", new Locale("en","US"));
FXMLLoader fxmlLoader = new FXMLLoader(App.class.getResource("/resources/" + fxml + ".fxml"), bundle);
return fxmlLoader.load();
}

private void makeStageDraggable() {
AtomicReference<Double> xOffset = new AtomicReference<>((double) 0);
AtomicReference<Double> yOffset = new AtomicReference<>((double) 0);

scene.setOnMousePressed(event -> {
xOffset.set(event.getSceneX());
yOffset.set(event.getSceneY());
});
scene.setOnMouseDragged(event -> {
App.primaryStage.setX(event.getScreenX() - xOffset.get());
App.primaryStage.setY(event.getScreenY() - yOffset.get());
});
scene.setOnDragDone((e) -> App.primaryStage.setOpacity(1.0f));
scene.setOnMouseDragReleased((e) -> {
if (e.isConsumed()) {
App.primaryStage.setOpacity(1.0f);
}
});
}


static public void runCMDCommand(String command) throws IOException {
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", command);
builder.redirectErrorStream(true);
builder.start();
}

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

}
61 changes: 61 additions & 0 deletions src/main/java/HuimangTech/MainUIController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package HuimangTech;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class MainUIController implements Initializable {

public MainUIController() {
}


public static String getTaskName() {
return TaskName;
}


static String TaskName = "";

@FXML
void CLOSE_APP() {
App.primaryStage.close();
System.exit(0);
}

@FXML
void MINIMIZE_APP() {
App.primaryStage.setIconified(true);
}

@FXML
void switchToShutdown() throws IOException {
TaskName = "ShutDown";
App.setRoot("Timer");
}

@FXML
void switchToRestart() throws IOException {
TaskName = "Restart";
App.setRoot("Timer");
}

@FXML
void switchToHibernate() throws IOException {
TaskName = "Hibernate";
App.setRoot("Timer");
}

@FXML
void switchToSleep() throws IOException {
TaskName = "Sleep";
App.setRoot("Timer");
}

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {

}
}
Loading

0 comments on commit 2306517

Please sign in to comment.