You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.5 KiB
73 lines
1.5 KiB
package com.example.jmacro.wjdr;
|
|
|
|
import com.example.jmacro.wjdr.base.ViewRect;
|
|
import com.example.jmacro.wjdr.util.Capture;
|
|
import com.example.jmacro.wjdr.util.Dialog;
|
|
import javafx.fxml.FXML;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.image.ImageView;
|
|
|
|
import java.awt.*;
|
|
import java.io.File;
|
|
|
|
/**
|
|
* UI控制器
|
|
*
|
|
* @author wangbing
|
|
* @version 0.0.1
|
|
* @since 1.8
|
|
*/
|
|
public class JMainController {
|
|
|
|
@FXML
|
|
private Button start;
|
|
@FXML
|
|
private Button stop;
|
|
@FXML
|
|
private Button capture;
|
|
@FXML
|
|
private ImageView preview;
|
|
|
|
/**
|
|
* 截图
|
|
*/
|
|
@FXML
|
|
private void onCapture() {
|
|
ViewRect screen = JMainService.getInstance().getMacroThread().getViewRect();
|
|
File legend = JMainService.getInstance().getMacro().getLegend();
|
|
if (screen == null) {
|
|
Dialog.alert("未定位到视口,请稍后再试!");
|
|
return;
|
|
}
|
|
try {
|
|
new Capture(screen.getLeft(), screen.getTop(), legend);
|
|
} catch (AWTException awtException) {
|
|
awtException.printStackTrace();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 截图
|
|
*/
|
|
@FXML
|
|
private void onStart() {
|
|
boolean start = JMainService.start();
|
|
this.start.setDisable(start);
|
|
this.stop.setDisable(!start);
|
|
}
|
|
|
|
/**
|
|
* 截图
|
|
*/
|
|
@FXML
|
|
private void onStop() {
|
|
boolean stop = JMainService.stop();
|
|
this.start.setDisable(!stop);
|
|
this.stop.setDisable(stop);
|
|
}
|
|
|
|
public ImageView getPreview() {
|
|
return preview;
|
|
}
|
|
}
|