-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
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(); | ||
} | ||
|
||
} |
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) { | ||
|
||
} | ||
} |