Esempio n. 1
0
        private static void ScreenshotPacketHandler(byte[] receivedPacket, Socket clientSocket)
        {
            ScreenshotPackage screenshotPackage = new ScreenshotPackage(receivedPacket);
            ScreenshotForm    NewScreenshotForm = new ScreenshotForm();

            NewScreenshotForm.ReceiveScreenshot(screenshotPackage.screenShot);
            NewScreenshotForm.ShowDialog();
            NewScreenshotForm.Focus();
            //Application.Run();
        }
Esempio n. 2
0
        private void ProcessFrame(bool instant)
        {
            if (!btnScreenshot.Enabled)
            {
                return;
            }
            if (!File.Exists(openFileDialogTesseract.FileName))
            {
                MessageBox.Show(this, "Tesseract-OCR path not configured!", "Screenulate",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            tesseractProgress.Style = ProgressBarStyle.Marquee;
            btnScreenshot.Enabled   = false;

            var screenshotForm = new ScreenshotForm {
                Rectangle = _lastScreenshotRect
            };

            if (instant)
            {
                screenshotForm.CaptureImage(_lastScreenshotRect);
            }
            else
            {
                screenshotForm.ShowDialog(this);
            }

            if (screenshotForm.Bitmap == null)
            {
                tesseractProgress.Style = ProgressBarStyle.Blocks;
                btnScreenshot.Enabled   = true;
                return;
            }

            _lastScreenshotRect = screenshotForm.Rectangle;

            IImage oldImage = previewBox.Image;

            previewBox.Image = new Image <Bgr, byte>(screenshotForm.Bitmap);
            oldImage?.Dispose();
            var processor = new TesseractProcessor(openFileDialogTesseract.FileName, previewBox.DisplayedImage);

            processor.Process();

            processor.Completed += TesseractProcessor_Completed;
            processor.Finished  += TesseractProcessor_Finished;
            processor.Error     += (sender, args) =>
            {
                MessageBox.Show($@"{args.GetException().Message}", "Screenulate", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            };
        }
        protected override void OnExecute(NameValueMap context)
        {
            log.Info("ScreenGrab started...");
            if (_screenShotForm == null)
            {
                _screenShotForm      = new ScreenshotForm(Application);
                _screenShotForm.Left = Convert.ToInt32(Application.Left + (Application.Width - _screenShotForm.Width) / 2.0);
                _screenShotForm.Top  = Convert.ToInt32(Application.Top + (Application.Height - _screenShotForm.Height) / 2.0);
            }
            _screenShotForm.prepareBitmapsBeforeLoadDialog();
            do
            {
                _screenShotForm.bTakeSnapShot = false;
                _screenShotForm.ShowDialog();

                if (_screenShotForm.bTakeSnapShot)
                {
                    //delay for specific machine. adjust the value in app.config.
                    try
                    {
                        System.Threading.Thread.Sleep(Properties.Settings.Default.delayTime);
                    }
                    catch (Exception ex)
                    {
                        System.Threading.Thread.Sleep(MDelaytime);
                        log.Error("Problem getting delaytime from app.config. " + ex);
                    }

                    _screenShotForm.DoSelect();
                }
            } while ((_screenShotForm.bTakeSnapShot));

            Terminate();
            Application.CommandManager.StopActiveCommand();
            log.Info("ScreenGrab completed.");
        }
Esempio n. 4
0
 private static void ScreenshotPacketHandler(byte[] receivedPacket, Socket clientSocket)
 {
     ScreenshotPackage screenshotPackage = new ScreenshotPackage(receivedPacket);
     ScreenshotForm NewScreenshotForm = new ScreenshotForm();
     NewScreenshotForm.ReceiveScreenshot(screenshotPackage.screenShot);
     NewScreenshotForm.ShowDialog();
     NewScreenshotForm.Focus();
     //Application.Run();
 }