Printer working - User Feedback needed because of long waits until print, maybe get lpstat status, modify & display.

closed #45
This commit is contained in:
2017-06-30 20:48:07 +02:00
parent c99f9e4f9d
commit b969277877
11 changed files with 108 additions and 21 deletions
+70
View File
@@ -14,6 +14,7 @@ import javafx.scene.layout.StackPane;
import model.SOMEvent;
import model.SOMImage;
import model.SOMLayout;
import workers.FilesWorker;
import workers.ScaleWorker;
import java.util.List;
@@ -34,10 +35,17 @@ public class PictureCtl {
public Button seriesBtn;
@FXML
public Button galleryBtn;
@FXML
public Button printBtn;
@FXML
public ImageView image;
// Get the Event Images
List<SOMImage> somImageList = SOMEvent.getInstance().getImages();
int numberOfImages = somImageList.size();
public void initialize() {
// Basic Layout setup
@@ -48,6 +56,7 @@ public class PictureCtl {
setGalleryBtn();
setSeriesBtn();
setSingleBtn();
setPrintBtn();
// Image Setup
setImage();
@@ -239,6 +248,58 @@ public class PictureCtl {
});
}
private void setPrintBtn() {
// get the button height & width
int height = (SOMLayout.screenHeight / 4);
// set the Button height & width
printBtn.setPrefSize(height, height);
// Make it a circle
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(height / 2));
//Set Text Color
printBtn.setTextFill(SOMLayout.WHITE);
printBtn.setText(null);
// Set Image
ImageView imageView = new ImageView(SOMLayout.PRINT_IMAGE);
printBtn.setGraphic(imageView);
// Set Mouse Press Action
printBtn.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG20rounded(SOMLayout.screenHeight / 4));
}
});
// Check if active
if (numberOfImages == 0) {
printBtn.setDisable(true);
} else {
printBtn.setDisable(false);
}
// Set Mouse Release Action
printBtn.setOnMouseReleased(new EventHandler<MouseEvent>() {
public void handle(MouseEvent event) {
// Feedback
printBtn.setBackground(SOMLayout.getTransparentBG10rounded(SOMLayout.screenHeight / 4));
// Action
action();
}
// Action Performed
private void action() {
FilesWorker.print();
}
});
}
private void setImage() {
// // Set the image aspect ratio to be preserved
// image.setPreserveRatio(true);
@@ -283,6 +344,15 @@ public class PictureCtl {
// set the Image to UI
image.setImage(new Image(somImage.getPrv().toURI().toString()));
// If the current image is not already set, set the last image
if (SOMEvent.getInstance().getCurrentimage() == null) {
SOMEvent event = SOMEvent.getInstance();
event.createAndSetLastImage();
event.createAndSetImage(event.getLastImage());
}
}
}
}