protected ImageInfo ExecuteRegionCapture(TaskSettings taskSettings) { ImageInfo imageInfo = new ImageInfo(); RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; Image img = screenshot.CaptureFullscreen(); CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, img)) { if (cursorData != null && cursorData.IsValid) { form.AddCursor(cursorData.Handle, cursorData.Position); cursorData.Dispose(); } form.ShowDialog(); imageInfo.Image = form.GetResultImage(); if (imageInfo.Image != null) { if (form.IsModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern) { WindowInfo windowInfo = form.GetWindowInfo(); imageInfo.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; } } return(imageInfo); }
protected TaskMetadata ExecuteRegionCapture(TaskSettings taskSettings) { TaskMetadata metadata = new TaskMetadata(); RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; Bitmap bmp = screenshot.CaptureFullscreen(); CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, bmp)) { if (cursorData != null && cursorData.IsVisible) { form.AddCursor(cursorData.Handle, CaptureHelpers.ScreenToClient(cursorData.Position)); } form.ShowDialog(); metadata.Image = form.GetResultImage(); if (metadata.Image != null) { if (form.IsImageModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region) { WindowInfo windowInfo = form.GetWindowInfo(); metadata.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; } } return(metadata); }
public static void CaptureRegion(TaskSettings taskSettings, bool autoHideForm = true) { RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } RegionCaptureForm form = new RegionCaptureForm(mode); DoCapture(() => { Image img = null; try { form.Config = taskSettings.CaptureSettingsReference.SurfaceOptions; form.Prepare(TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen()); form.ShowDialog(); img = form.GetResultImage(); if (img != null) { if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern) { WindowInfo windowInfo = form.GetWindowInfo(); if (windowInfo != null) { img.Tag = new ImageTag { WindowTitle = windowInfo.Text, ProcessName = windowInfo.ProcessName }; } } lastRegionCaptureType = LastRegionCaptureType.Default; } } finally { if (form != null) { form.Dispose(); } } return(img); }, CaptureType.Region, taskSettings, autoHideForm); }
protected ImageInfo ExecuteRegionCapture(TaskSettings taskSettings) { ImageInfo imageInfo = new ImageInfo(); RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } RegionCaptureForm form = new RegionCaptureForm(mode); try { form.Config = taskSettings.CaptureSettingsReference.SurfaceOptions; Image img = TaskHelpers.GetScreenshot(taskSettings).CaptureFullscreen(); form.Prepare(img); form.ShowDialog(); imageInfo.Image = form.GetResultImage(); if (imageInfo.Image != null) { if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern) { WindowInfo windowInfo = form.GetWindowInfo(); if (windowInfo != null) { imageInfo.WindowTitle = windowInfo.Text; imageInfo.ProcessName = windowInfo.ProcessName; } } lastRegionCaptureType = RegionCaptureType.Default; } } finally { if (form != null) { form.Dispose(); } } return(imageInfo); }
protected TaskMetadata ExecuteRegionCapture(TaskSettings taskSettings) { RegionCaptureMode mode; if (taskSettings.AdvancedSettings.RegionCaptureDisableAnnotation) { mode = RegionCaptureMode.Default; } else { mode = RegionCaptureMode.Annotation; } Bitmap canvas; Screenshot screenshot = TaskHelpers.GetScreenshot(taskSettings); screenshot.CaptureCursor = false; if (taskSettings.CaptureSettings.SurfaceOptions.ActiveMonitorMode) { canvas = screenshot.CaptureActiveMonitor(); } else { canvas = screenshot.CaptureFullscreen(); } CursorData cursorData = null; if (taskSettings.CaptureSettings.ShowCursor) { cursorData = new CursorData(); } using (RegionCaptureForm form = new RegionCaptureForm(mode, taskSettings.CaptureSettingsReference.SurfaceOptions, canvas)) { if (cursorData != null && cursorData.IsVisible) { form.AddCursor(cursorData.ToBitmap(), form.PointToClient(cursorData.DrawPosition)); } form.ShowDialog(); Bitmap result = form.GetResultImage(); if (result != null) { TaskMetadata metadata = new TaskMetadata(result); if (form.IsImageModified) { AllowAnnotation = false; } if (form.Result == RegionResult.Region) { WindowInfo windowInfo = form.GetWindowInfo(); metadata.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; return(metadata); } } return(null); }