private void _miCaptureObjectOptions_Click(object sender, EventArgs e) { bool bTopMost = logWindow.TopMost; logWindow.TopMost = false; if (_captureType != CaptureType.None) { _captureType = CaptureType.None; _engine.StopCapture(); UpdateScreenCaptureItems(); } try { _objectOptions = _engine.ShowCaptureObjectOptionsDialog(this, ScreenCaptureDialogFlags.None, _objectOptions, false, null); } catch (Exception ex) { if (ex.Message != "UserAbort" && ex.Message != "User has aborted operation") { Messager.ShowError(this, ex); } } logWindow.TopMost = bTopMost; }
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; }
// ************************** // 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(); }
// Options - Capture Object Options ... private void _miOptionsCaptureObjectOptions_Click(object sender, EventArgs e) { if (_captureType != CaptureType.None) { _captureType = CaptureType.None; _engine.StopCapture(); UpdateMyControls(); UpdateStatusBarText(); } try { _objectOptions = _engine.ShowCaptureObjectOptionsDialog(this, ScreenCaptureDialogFlags.None, _objectOptions, false, null); } catch (Exception ex) { if (ex.Message != "UserAbort" && ex.Message != "User has aborted operation") { Messager.ShowError(this, ex); } } }
// 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)); } }