protected override ImageInfo Execute(TaskSettings taskSettings) { WindowInfo windowInfo = new WindowInfo(WindowHandle); if (windowInfo.IsMinimized) { windowInfo.Restore(); } windowInfo.Activate(); Thread.Sleep(250); ImageInfo imageInfo = new ImageInfo(); imageInfo.UpdateInfo(windowInfo); if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea) { imageInfo.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindowTransparent(WindowHandle); } else { imageInfo.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindow(WindowHandle); } return(imageInfo); }
protected override ImageInfo Execute(TaskSettings taskSettings) { if (NativeMethods.IsIconic(WindowHandle)) { NativeMethods.RestoreWindow(WindowHandle); } NativeMethods.SetForegroundWindow(WindowHandle); Thread.Sleep(250); ImageInfo imageInfo = new ImageInfo(); WindowInfo windowInfo = new WindowInfo(WindowHandle); imageInfo.UpdateInfo(windowInfo); if (taskSettings.CaptureSettings.CaptureTransparent && !taskSettings.CaptureSettings.CaptureClientArea) { imageInfo.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindowTransparent(WindowHandle); } else { imageInfo.Image = TaskHelpers.GetScreenshot(taskSettings).CaptureWindow(WindowHandle); } return(imageInfo); }
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 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.IsAnnotated) { AllowAnnotation = false; } if (form.Result == RegionResult.Region && taskSettings.UploadSettings.RegionCaptureUseWindowPattern) { WindowInfo windowInfo = form.GetWindowInfo(); imageInfo.UpdateInfo(windowInfo); } lastRegionCaptureType = RegionCaptureType.Default; } } finally { if (form != null) { form.Dispose(); } } return(imageInfo); }
protected ImageInfo CreateImageInfo(Rectangle insideRect, string ignoreProcess) { ImageInfo imageInfo = new ImageInfo(); IntPtr handle = NativeMethods.GetForegroundWindow(); WindowInfo windowInfo = new WindowInfo(handle); if ((ignoreProcess == null || !windowInfo.ProcessName.Equals(ignoreProcess, StringComparison.InvariantCultureIgnoreCase)) && (insideRect.IsEmpty || windowInfo.Rectangle.Contains(insideRect))) { imageInfo.UpdateInfo(windowInfo); } return(imageInfo); }