示例#1
0
        private void _miCaptureOptions_Click(object sender, EventArgs e)
        {
            bool bTopMost = logWindow.TopMost;

            logWindow.TopMost = false;
            if (_captureType != CaptureType.None)
            {
                _captureType = CaptureType.None;
                _engine.StopCapture();
                UpdateScreenCaptureItems();
            }

            try
            {
                _options = _engine.ShowCaptureOptionsDialog(this, ScreenCaptureDialogFlags.None, _options, null);
                _engine.CaptureOptions = _options;
                _isHotKeyEnabled       = (_options.Hotkey == Keys.None) ? false : true;
            }
            catch (Exception ex)
            {
                if (ex.Message != "UserAbort" && ex.Message != "User has aborted operation")
                {
                    Messager.ShowError(this, ex);
                }
            }
            logWindow.TopMost = bTopMost;
        }
示例#2
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;
 }
示例#3
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();
        }
示例#4
0
        // Use LEADTOOLS to capture an area of the screen
        private RasterImage DoCapture(bool useHotkey)
        {
            // Use default options for the capture process
            ScreenCaptureOptions screenCaptureOptions = _screenCaptureEngine.CaptureOptions;
            // Use default options for the area to capture
            ScreenCaptureAreaOptions screenCaptureAreaOptions = ScreenCaptureEngine.DefaultCaptureAreaOptions;

            if (useHotkey)
            {
                screenCaptureOptions.Hotkey = Keys.F11;
            }
            else
            {
                screenCaptureOptions.Hotkey = Keys.None;
            }

            _screenCaptureEngine.CaptureOptions = screenCaptureOptions;

            switch (selectedScreenCapture)
            {
            case "rectangularArea":
                screenCaptureAreaOptions.AreaType = ScreenCaptureAreaType.Rectangle;
                return(_screenCaptureEngine.CaptureArea(screenCaptureAreaOptions, null));

            case "freehandArea":
                screenCaptureAreaOptions.AreaType = ScreenCaptureAreaType.Freehand;
                return(_screenCaptureEngine.CaptureArea(screenCaptureAreaOptions, null));

            case "windowCapture":
                ScreenCaptureObjectOptions objectOptions = ScreenCaptureEngine.DefaultCaptureObjectOptions;
                return(_screenCaptureEngine.CaptureSelectedObject(objectOptions, null));

            case "fullscreenCapture":
                return(_screenCaptureEngine.CaptureFullScreen(null));

            default:
                return(_screenCaptureEngine.CaptureArea(screenCaptureAreaOptions, null));
            }
        }
示例#5
0
        // Options Menu - Capture Options ...
        private void _miOptionsCaptureOptions_Click(object sender, EventArgs e)
        {
            if (_captureType != CaptureType.None)
            {
                _captureType = CaptureType.None;
                _engine.StopCapture();
                UpdateMyControls();
                UpdateStatusBarText();
            }

            try
            {
                _options = _engine.ShowCaptureOptionsDialog(this, ScreenCaptureDialogFlags.None, _options, null);
                _engine.CaptureOptions = _options;
                _isHotKeyEnabled       = (_options.Hotkey == Keys.None) ? false : true;
            }
            catch (Exception ex)
            {
                if (ex.Message != "UserAbort" && ex.Message != "User has aborted operation")
                {
                    Messager.ShowError(this, ex);
                }
            }
        }
示例#6
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));
            }
        }