Example #1
0
 public void Handle(IInvisibleForm form, KeyboardHook hook, Action<Bitmap> callback)
 {
     if (form == null) throw new ArgumentNullException(nameof(form));
     if (hook == null) throw new ArgumentNullException(nameof(hook));
     if (callback == null) throw new ArgumentNullException(nameof(callback));
     form.Exit();
 }
        public void Handle(IInvisibleForm form, KeyboardHook hook, Action<Bitmap> callback)
        {
            if (form == null) throw new ArgumentNullException(nameof(form));
            if (hook == null) throw new ArgumentNullException(nameof(hook));
            if (callback == null) throw new ArgumentNullException(nameof(callback));

            var windowBitmap = ScreenshotCreator.GetActiveWindow();

            callback(windowBitmap);
        }
Example #3
0
        public void Handle(IInvisibleForm form, KeyboardHook hook, Action<Bitmap> callback)
        {
            if (form == null) throw new ArgumentNullException(nameof(form));
            if (hook == null) throw new ArgumentNullException(nameof(hook));
            if (callback == null) throw new ArgumentNullException(nameof(callback));

            var fullScreen = ScreenshotCreator.GetAllMonitors();

            callback(fullScreen);
        }
 public void Handle(IInvisibleForm form, KeyboardHook hook, Action<Bitmap> callback)
 {
     if (form == null) throw new ArgumentNullException(nameof(form));
     if (hook == null) throw new ArgumentNullException(nameof(hook));
     if (callback == null) throw new ArgumentNullException(nameof(callback));
     if (!form.Visible)
     {
         _callback = callback;
         form.Explode(CaptureArea);
     }
 }
Example #5
0
        public UploaderForm()
        {
            ConfigureInvisibleForm();
            ConfigureTrayMenu();

            _config = Config.Load("config.json");
            _uploadQueue = new UploadQueue(new ServerApi(_config), new UploadResultHandler(this, _config));
            _handler = new KeyHandler(this, _uploadQueue.QueueImage);
            _hook = new KeyboardHook();
            _handler.RegisterKeys(_hook);
            _hook.KeyPressed += _handler.Handle;

            FormClosed += UploaderForm_FormClosed;
        }
        public void Handle(IInvisibleForm form, KeyboardHook hook, Action<Bitmap> callback)
        {
            if (form == null) throw new ArgumentNullException(nameof(form));
            if (hook == null) throw new ArgumentNullException(nameof(hook));
            if (callback == null) throw new ArgumentNullException(nameof(callback));
            var mouseLocation = Cursor.Position;
            foreach (var bitmap in
                (from screen in Screen.AllScreens
                where screen.Bounds.Contains(mouseLocation)
                select ScreenshotCreator.GetSingleMonitor(screen)))
            {
                callback(bitmap);

                return;
            }
        }
Example #7
0
        public void RegisterKeys(KeyboardHook hook)
        {
            if (hook == null) throw new ArgumentNullException(nameof(hook));
            _hook = hook;
            // TODO: Reflect service locator-y
            // TODO: Config based
            _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Shift, Keys.D1);
            _keyHandlers.Add(Keys.D1, new SingleMonitorHandler());

            _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Shift, Keys.D2);
            _keyHandlers.Add(Keys.D2, new CurrentWindowHandler());

            _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Shift, Keys.D3);
            _keyHandlers.Add(Keys.D3, new FullScreenHandler());

            _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Shift, Keys.D4);
            _keyHandlers.Add(Keys.D4, new SelectedAreaHandler());

            _hook.RegisterHotKey(ModifierKeys.Control | ModifierKeys.Shift, Keys.X);
            _keyHandlers.Add(Keys.X, new ExitKeyHandler());
        }