Ejemplo n.º 1
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            StopDrawing();

            //// Clean up
            DeleteObject(_highlightWin32Pen);
            DeleteObject(_redWin32Pen);

            ScreenCaptureEngine.Shutdown();

            if (_ocrEngine != null)
            {
                _ocrEngine.Shutdown();
            }

            if (_svgViewer != null && _svgViewer.HasDocument)
            {
                string temp = _svgViewer.Document.GetDocumentFileName();
                if (File.Exists(temp))
                {
                    File.Delete(temp);
                }
            }

            Properties.Settings mySettings = new Properties.Settings();
            mySettings.UseHotKey   = _tsUseHotkey.Checked;
            mySettings.CaptureArea = selectedScreenCapture;
            mySettings.Save();
        }
Ejemplo n.º 2
0
        public void Open(InputSetup setup)
        {
            var  req     = (ScreenCaptureRequest)setup.ObjectInput;
            bool directX = setup.Dx != null;

            _capture = new ScreenCaptureEngine(req, setup.Dx, sz => OnSizeChanged(sz, directX));
            SetConfig(req.InitialSize, directX);
        }
Ejemplo n.º 3
0
 private void InitializeScreenCapture()
 {
     ScreenCaptureEngine.Startup();
     // initialize Screen Capture Variables
     _engine = new ScreenCaptureEngine();
     _engine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(_engine_CaptureInformation);
     _areaOptions     = ScreenCaptureEngine.DefaultCaptureAreaOptions;
     _objectOptions   = ScreenCaptureEngine.DefaultCaptureObjectOptions;
     _options         = _engine.CaptureOptions;
     _isHotKeyEnabled = true;
 }
Ejemplo n.º 4
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.MinimumSize = new Size(545, 455);

            IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false);

            InsertMenu(sysMenuHandle, -1, MF_BYPOSITION | MF_SEPARATOR, 0, string.Empty);
            InsertMenu(sysMenuHandle, -1, MF_BYPOSITION, IDM_ABOUT, "About...");

            try
            {
                // Set up the Screen Capture
                ScreenCaptureEngine.Startup();
                _screenCaptureEngine = new ScreenCaptureEngine();
                _screenCaptureEngine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(captureCallback);

                // Set up the OCR
                _ocrEngine = OcrEngineManager.CreateEngine(OcrEngineType.LEAD, false);

                // Start up the OCR engine
#if LT_CLICKONCE
                _ocrEngine.Startup(null, null, null, Application.StartupPath + @"\OCR Engine");
#else
                _ocrEngine.Startup(null, null, null, null);
#endif // #if LT_CLICKONCE

                // Load the OCR settings
                LoadOcrSettings(_ocrEngine);

                _ocrEngine.SettingManager.SetBooleanValue("Recognition.ModifyProcessingImage", false);
                _ocrEngine.SettingManager.SetEnumValue("Recognition.RecognitionModuleTradeoff", 0);
                _ocrEngine.SettingManager.SetBooleanValue("Recognition.DetectColors", false);
                _ocrEngine.SettingManager.SetEnumValue("Recognition.Fonts.DetectFontStyles", "Bold,Italic,Underline,SansSerif,Serif,Proportional,Superscript,Subscript");
                _ocrEngine.SettingManager.SetBooleanValue("Recognition.ShareOriginalImage", false);//this demo does not support the sharing mode

                // Load application settings
                Properties.Settings mySettings = new Properties.Settings();
                foreach (ToolStripMenuItem ts in _tsCaptureBtn.DropDownItems)
                {
                    selectedScreenCapture = mySettings.CaptureArea;
                    if (ts.Name == selectedScreenCapture)
                    {
                        ts.Checked = true;
                    }
                }
                _tsUseHotkey.Checked = mySettings.UseHotKey;
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }
        }
Ejemplo n.º 5
0
        // **************************
        // PROGRAM SPECIFIC FUNCTIONS
        // **************************

        private void MainForm_Load(object sender, EventArgs e)
        {
            // setup our caption
            Messager.Caption = "LEADTOOLS C# Screen Capture Demo";
            Text             = Messager.Caption;

            // what to capture
            _captureType = CaptureType.None;

            // set the current window state
            _previousWindowState = this.WindowState;

            // as a start, do not beep when capturing
            _isBeepOn = false;

            // minimize window on capturing
            _minimizeOnCapture = true;

            // activate window after capturing
            _activateAfterCapture = true;

            // beeping is off
            _isBeepOn = false;

            // no cut is active
            _cutImage = false;

            // initialize the codecs object
            _codecs = new RasterCodecs();

            // no opened images for now
            _countOfOpenedImages = 0;

            // startup the engine
            ScreenCaptureEngine.Startup();

            // initialize Screen Capture Variables
            _engine = new ScreenCaptureEngine();
            _engine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(_engine_CaptureInformation);
            _areaOptions        = ScreenCaptureEngine.DefaultCaptureAreaOptions;
            _objectOptions      = ScreenCaptureEngine.DefaultCaptureObjectOptions;
            _options            = _engine.CaptureOptions;
            _captureInformation = null;
            _isHotKeyEnabled    = true;

            UpdateMyControls();
            UpdateStatusBarText();
        }
Ejemplo n.º 6
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     ScreenCaptureEngine.Shutdown();
 }
Ejemplo n.º 7
0
        private void Form1_Load(object sender, EventArgs e)
        {
            viewer      = new ImageViewer();
            viewer.Dock = DockStyle.Fill;

            automationControl             = new ImageViewerAutomationControl();
            automationControl.ImageViewer = viewer;

            ScreenCaptureEngine.Startup();
            scEngine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(scEngine_CaptureInformation);
            ScreenCaptureOptions captureOptions = scEngine.CaptureOptions;

            captureOptions.Hotkey   = Keys.None;
            scEngine.CaptureOptions = captureOptions;

            // initialize a new RasterCodecs object
            RasterCodecs codecs = new RasterCodecs();

            // load the main image into the viewer
            viewer.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\OCR1.TIF");
            viewer.Zoom(ControlSizeMode.FitAlways, 1.0, viewer.DefaultZoomOrigin);

            // initialize the interactive mode for the viewer
            AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();

            automationInteractiveMode.AutomationControl = automationControl;

            // add the interactive mode to the viewer
            viewer.InteractiveModes.BeginUpdate();
            viewer.InteractiveModes.Add(automationInteractiveMode);
            viewer.InteractiveModes.EndUpdate();

            if (viewer.Image != null)
            {
                // create and set up the automation manager
                annAutomationManager = new AnnAutomationManager();
                annAutomationManager.RestrictDesigners   = true;
                annAutomationManager.EditObjectAfterDraw = false;

                // Instruct the manager to create all of the default automation objects.
                annAutomationManager.CreateDefaultObjects();

                AnnObservableCollection <AnnAutomationObject> annObservable = annAutomationManager.Objects;
                foreach (AnnAutomationObject annObject in annObservable)
                {
                    if (annObject.Id != AnnObject.SelectObjectId)
                    {
                        //  annObservable.Remove(annObject);
                        // annAutomationManager.Objects.Remove(annObject);
                    }
                }


                // initialize the manager helper and create the toolbar and add it then the viewer to the controls
                AutomationManagerHelper managerHelper = new AutomationManagerHelper(annAutomationManager);
                managerHelper.CreateToolBar();
                managerHelper.ToolBar.Dock = DockStyle.Right;
                Controls.Add(managerHelper.ToolBar);
                Controls.Add(viewer);


                // set up the automation (it will create the container as well)
                automation              = new AnnAutomation(annAutomationManager, automationControl);
                automation.EditContent += new EventHandler <AnnEditContentEventArgs>(automation_EditContent);
                // set this automation as the active one
                automation.Active = true;

                //set the size of the container to the size of the viewer
                automation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight));
            }
        }
Ejemplo n.º 8
0
 public void Dispose()
 {
     _capture?.Dispose();
     _capture = null;
 }
Ejemplo n.º 9
0
 private static void FinilizeScreenCapture()
 {
     ScreenCaptureEngine.Shutdown();
 }