Skip to content

Commit

Permalink
Add take screenshot function, closes #77
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Feb 22, 2024
1 parent 05f7330 commit 2bac709
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/main/java/mpo/dayon/assistant/gui/AssistantFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;

import static java.awt.event.KeyEvent.VK_CONTROL;
import static java.awt.event.KeyEvent.VK_WINDOWS;
import static java.awt.event.KeyEvent.*;
import static java.lang.String.format;
import static mpo.dayon.common.babylon.Babylon.translate;
import static mpo.dayon.common.gui.common.ImageUtilities.getOrCreateIcon;
Expand Down Expand Up @@ -60,6 +59,8 @@ class AssistantFrame extends BaseFrame {

private final JButton stopButton;

private final JButton prtScrKeyButton;

private final AtomicBoolean controlActivated = new AtomicBoolean(false);

private final AtomicBoolean windowsKeyActivated = new AtomicBoolean(false);
Expand Down Expand Up @@ -94,6 +95,7 @@ class AssistantFrame extends BaseFrame {
this.keepAspectRatioToggleButton = createToggleButton(createToggleKeepAspectRatioAction(), false);
this.windowsKeyToggleButton = createToggleButton(createSendWindowsKeyAction());
this.ctrlKeyToggleButton = createToggleButton(createSendCtrlKeyAction());
this.prtScrKeyButton = createButton(createSendPrtScrKeyAction());
this.languageSelection = languageSelection;
setupToolBar(createToolBar());
setupStatusBar(createStatusBar(counters));
Expand Down Expand Up @@ -241,6 +243,7 @@ private JTabbedPane createTabbedPane() {
sessionPanel.add(createButton(actions.getRemoteClipboardSetAction()));
sessionPanel.add(windowsKeyToggleButton);
sessionPanel.add(ctrlKeyToggleButton);
sessionPanel.add(prtScrKeyButton);
sessionPanel.add(createButton(actions.getResetAction()));

JPanel settingsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
Expand Down Expand Up @@ -294,6 +297,7 @@ public void actionPerformed(ActionEvent ev) {
controlActivated.set(!controlActivated.get());
windowsKeyToggleButton.setEnabled(controlActivated.get());
ctrlKeyToggleButton.setEnabled(controlActivated.get());
prtScrKeyButton.setEnabled(controlActivated.get());
}
};
remoteControl.putValue(Action.SHORT_DESCRIPTION, translate("control.mode"));
Expand Down Expand Up @@ -335,6 +339,24 @@ public void actionPerformed(ActionEvent ev) {
return sendCtrlKey;
}

private Action createSendPrtScrKeyAction() {
final Action sendPrtScrKey = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent ev) {
fireOnKeyPressed(VK_PRINTSCREEN, ' ');
try {
Thread.sleep(10L);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
fireOnKeyReleased(VK_PRINTSCREEN, ' ');
}
};
sendPrtScrKey.putValue(Action.SHORT_DESCRIPTION, translate("send.prtScrKey"));
sendPrtScrKey.putValue(Action.SMALL_ICON, getOrCreateIcon(ImageNames.CAM));
return sendPrtScrKey;
}

private Action createToggleFixScreenAction() {
final Action fitScreen = new AbstractAction() {
@Override
Expand Down Expand Up @@ -542,6 +564,7 @@ private void disableControls() {
controlToggleButton.setEnabled(false);
windowsKeyToggleButton.setEnabled(false);
ctrlKeyToggleButton.setEnabled(false);
prtScrKeyButton.setEnabled(false);
disableTransferControls();
}

Expand All @@ -555,6 +578,7 @@ private void enableControls() {
controlToggleButton.setEnabled(true);
windowsKeyToggleButton.setSelected(false);
ctrlKeyToggleButton.setSelected(false);
prtScrKeyButton.setEnabled(false);
enableTransferControls();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/mpo/dayon/common/gui/common/ImageNames.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ private ImageNames() {

public static final String APP = "app.png";
public static final String APP_LARGE = "app_l.png";
public static final String CAM = "cam.png";
public static final String CAPTURE_SETTINGS = "capture_settings.png";
public static final String COMPATIBILITY = "compatibility.png";
public static final String COMPRESSION_SETTINGS = "compression_settings.png";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/Babylon.properties
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ clipboard.getRemote = Get assisted clipboard
clipboard.setRemote = Set assisted clipboard

send.ctrlKey = Send Ctrl key
send.prtScrKey = Take a screenshot
send.windowsKey = Send Windows key

toggle.screen.mode = Toggle fit screen mode
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Unterschiedliche Programmversionen

clipboard.getRemote = Zwischenablage des Assistierten \u00FCbertragen
clipboard.setRemote = Zwischenablage an Assistierten \u00FCbertragen

send.ctrlKey = Ctrl-Taste senden
send.prtScrKey = Bildschirmfoto aufnehmen
send.windowsKey = Windowstaste senden

toggle.screen.mode = Anzeigemodus umschalten
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Versiones de programa diferentes

clipboard.getRemote = Pegar portapapeles del asistido
clipboard.setRemote = Copiar al portapapeles del asistido

send.ctrlKey = Enviar la tecla Ctrl
send.prtScrKey = Tomar una captura de pantalla
send.windowsKey = Enviar la tecla Windows

toggle.screen.mode = Cambiar modo de visualizaci\u00F3n
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_fr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Versions diff\u00E9rentes

clipboard.getRemote = Obtenir planchette de l'assist\u00E9
clipboard.setRemote = Copier planchette vers l'assist\u00E9

send.ctrlKey = Envoyer la cl\u00E9 Ctrl
send.prtScrKey = Prendre une capture d'\u00E9cran
send.windowsKey = Envoyer la cl\u00E9 Windows

toggle.screen.mode = Ajuster le mode \u00E9cran
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_it.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Versioni del programma diverse

clipboard.getRemote = Ottieni appunti assistiti
clipboard.setRemote = Imposta appunti assistiti

send.ctrlKey = Invia il tasto Ctrl
send.prtScrKey = Fare uno screenshot
send.windowsKey = Invia il tasto Windows

toggle.screen.mode = Attiva/disattiva la modalit\u00E0 di adattamento allo schermo
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = \u0420\u0430\u0437\u043B\u0438\u0447\u043D\u044B\u0435 \u0432\u0

clipboard.getRemote = \u041F\u043E\u043B\u0443\u0447\u0438\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 \u043F\u043E\u043C\u043E\u0433\u0430\u043B\u0430
clipboard.setRemote = \u0423\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0431\u0443\u0444\u0435\u0440 \u043E\u0431\u043C\u0435\u043D\u0430 \u043F\u043E\u043C\u043E\u0433\u0430\u043B\u0430

send.ctrlKey = \u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C \u043A\u043B\u0430\u0432\u0438\u0448\u0443 Ctrl
send.prtScrKey = \u0441\u0434\u0435\u043B\u0430\u0442\u044C \u0441\u043D\u0438\u043C\u043E\u043A \u044D\u043A\u0440\u0430\u043D\u0430
send.windowsKey = \u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C \u043A\u043B\u0430\u0432\u0438\u0448\u0443 Windows

toggle.screen.mode = \u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u0440\u0435\u0436\u0438\u043C \u043E\u0442\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u043D\u0430 \u044D\u043A\u0440\u0430\u043D\u0435
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_sv.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Annan programversion

clipboard.getRemote = H\u00E4mta urklipp fr\u00E5n hj\u00E4lptagare
clipboard.setRemote = Skicka urklipp till hj\u00E4lptagare

send.ctrlKey = Skicka Ctrl-tangent
send.prtScrKey = Ta en sk\u00E4rmbild
send.windowsKey = Skicka Windows-tangent

toggle.screen.mode = V\u00E4xla sk\u00E4rml\u00E4ge
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/Babylon_tr.properties
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ version.wrong = Farkl\u0131 versiyonlar kullan\u0131yorsunuz

clipboard.getRemote = Panodaki veriyi al
clipboard.setRemote = Panodaki veriyi g\u00F6nder

send.ctrlKey = Ctrl tu\u015Funu g\u00F6nder
send.prtScrKey = Ekran g\u00F6r\u00FCnt\u00FCs\u00FC al
send.windowsKey = Windows tu\u015Funu g\u00F6nder

toggle.screen.mode = Ekrana s\u0131\u011Fd\u0131r modunu a\u00E7/kapat
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/Babylon_zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,11 @@ version.wrong = \u7248\u672C\u4E0D\u4E00\u81F4
clipboard.getRemote = \u83B7\u53D6\u8FDC\u7A0B\u4E3B\u673A\u526A\u8D34\u677F
# Set assisted clipboard
clipboard.setRemote = \u53D1\u9001\u672C\u673A\u526A\u8D34\u677F\u5230\u8FDC\u7A0B\u4E3B\u673A

# Send Ctrl key
send.ctrlKey = \u53D1\u9001 Ctrl \u952E
# send PrtScr key
send.prtScrKey = \u622A\u56FE
# Send Windows key
send.windowsKey = \u53D1\u9001 Windows \u952E

Expand Down
Binary file added src/main/resources/images/100/cam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/125/cam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/150/cam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/175/cam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/resources/images/200/cam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2bac709

Please sign in to comment.