// Path: src/main/java/com/googlecode/eckoit/events/ScreenGrabFinishEvent.java
// public class ScreenGrabFinishEvent {
// 
// }
// 
// Path: src/main/java/com/googlecode/eckoit/events/ScreenGrabStartEvent.java
// public class ScreenGrabStartEvent {
//     private File storageDir;
//     private long intervalInMilli;
//     private boolean presentationMode = false;
//     
//     public ScreenGrabStartEvent(File storageDir) {
//         this.storageDir = storageDir;
//         intervalInMilli = 5000; // default to 5 seconds
//     }
//     public ScreenGrabStartEvent(File storageDir, long intervalInMilli) {
//         this.storageDir = storageDir;
//         this.intervalInMilli = intervalInMilli; 
//     }
//     public ScreenGrabStartEvent(File storageDir, boolean presentationMode) {
//         this.storageDir = storageDir;
//         this.presentationMode = presentationMode;
//     }
//     public long getIntervalInMilli(){
//         return this.intervalInMilli;
//     }
//     
//     public File getStorageDir() {
//         return storageDir;
//     }
// 
//     public boolean getPresentationMode() {
//         return presentationMode;
//     }
// 
// }
// 
// Path: src/main/java/com/googlecode/eckoit/events/TargetClickedEvent.java
// public class TargetClickedEvent {
// 
// }


import com.github.couchapptakeout.events.ExitApplicationMessage;
import com.googlecode.eckoit.events.ScreenGrabFinishEvent;
import com.googlecode.eckoit.events.ScreenGrabStartEvent;
import com.googlecode.eckoit.events.TargetClickedEvent;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.bushe.swing.event.EventBus;
import org.bushe.swing.event.EventSubscriber;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.eckoit.screengrab;





/**
 *
 * @author ryan
 */
public class ScreenGrabber {

    private File currentDir;
    private Timer timer;
    private boolean inPresentationMode = false;

    public ScreenGrabber() {

        EventBus.subscribeStrongly(TargetClickedEvent.class, new EventSubscriber<TargetClickedEvent>() {
            @Override
            public void onEvent(TargetClickedEvent t) {
                if (inPresentationMode) {
                    Robot robot;
                    try {
                        robot = new Robot();
                        Point last = MouseInfo.getPointerInfo().getLocation();
                        robot.mouseMove(10, 10);
                        robot.mousePress(InputEvent.BUTTON1_MASK);
                        robot.mouseRelease(InputEvent.BUTTON1_MASK);
                        robot.mouseMove(last.x, last.y);
                        System.out.println("Taking picture");
                        // wait to take the picture
                        Thread.sleep(300);
                        capture();

                    } catch (Exception ex) {
                        Logger.getLogger(ScreenGrabber.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }
            }

        });


        EventBus.subscribeStrongly(ScreenGrabStartEvent.class, new EventSubscriber<ScreenGrabStartEvent>() {
            @Override
// Path: src/main/java/com/googlecode/eckoit/events/ScreenGrabFinishEvent.java
// public class ScreenGrabFinishEvent {
// 
// }
// 
// Path: src/main/java/com/googlecode/eckoit/events/ScreenGrabStartEvent.java
// public class ScreenGrabStartEvent {
//     private File storageDir;
//     private long intervalInMilli;
//     private boolean presentationMode = false;
//     
//     public ScreenGrabStartEvent(File storageDir) {
//         this.storageDir = storageDir;
//         intervalInMilli = 5000; // default to 5 seconds
//     }
//     public ScreenGrabStartEvent(File storageDir, long intervalInMilli) {
//         this.storageDir = storageDir;
//         this.intervalInMilli = intervalInMilli; 
//     }
//     public ScreenGrabStartEvent(File storageDir, boolean presentationMode) {
//         this.storageDir = storageDir;
//         this.presentationMode = presentationMode;
//     }
//     public long getIntervalInMilli(){
//         return this.intervalInMilli;
//     }
//     
//     public File getStorageDir() {
//         return storageDir;
//     }
// 
//     public boolean getPresentationMode() {
//         return presentationMode;
//     }
// 
// }
// 
// Path: src/main/java/com/googlecode/eckoit/events/TargetClickedEvent.java
// public class TargetClickedEvent {
// 
// }


// Path: src/main/java/com/googlecode/eckoit/screengrab/ScreenGrabber.java
import com.github.couchapptakeout.events.ExitApplicationMessage;
import com.googlecode.eckoit.events.ScreenGrabFinishEvent;
import com.googlecode.eckoit.events.ScreenGrabStartEvent;
import com.googlecode.eckoit.events.TargetClickedEvent;
import java.awt.AWTException;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import org.bushe.swing.event.EventBus;
import org.bushe.swing.event.EventSubscriber;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.googlecode.eckoit.screengrab;





/**
 *
 * @author ryan
 */
public class ScreenGrabber {

    private File currentDir;
    private Timer timer;
    private boolean inPresentationMode = false;

    public ScreenGrabber() {

        EventBus.subscribeStrongly(TargetClickedEvent.class, new EventSubscriber<TargetClickedEvent>() {
            @Override
            public void onEvent(TargetClickedEvent t) {
                if (inPresentationMode) {
                    Robot robot;
                    try {
                        robot = new Robot();
                        Point last = MouseInfo.getPointerInfo().getLocation();
                        robot.mouseMove(10, 10);
                        robot.mousePress(InputEvent.BUTTON1_MASK);
                        robot.mouseRelease(InputEvent.BUTTON1_MASK);
                        robot.mouseMove(last.x, last.y);
                        System.out.println("Taking picture");
                        // wait to take the picture
                        Thread.sleep(300);
                        capture();

                    } catch (Exception ex) {
                        Logger.getLogger(ScreenGrabber.class.getName()).log(Level.SEVERE, null, ex);
                    }

                }
            }

        });


        EventBus.subscribeStrongly(ScreenGrabStartEvent.class, new EventSubscriber<ScreenGrabStartEvent>() {
            @Override
            public void onEvent(ScreenGrabStartEvent t) {