public static bool SelectRegion(out Rectangle rect) { using (RectangleRegion surface = new RectangleRegion()) { surface.AreaManager.WindowCaptureMode = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { if (surface.AreaManager.IsCurrentAreaValid) { rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentArea); return(true); } } else if (surface.Result == SurfaceResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null) { using (Image fullscreen = Screenshot.CaptureFullscreen()) using (RectangleRegion surface = new RectangleRegion(fullscreen)) { if (surfaceOptions != null) { surface.Config = new SurfaceOptions { MagnifierPixelCount = surfaceOptions.MagnifierPixelCount, MagnifierPixelSize = surfaceOptions.MagnifierPixelSize }; } surface.OneClickMode = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { PointInfo pointInfo = new PointInfo(); pointInfo.Position = CaptureHelpers.ClientToScreen(surface.OneClickPosition); pointInfo.Color = ((Bitmap)fullscreen).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y); return(pointInfo); } } return(null); }
public static bool SelectRegion(out Rectangle rect, TaskSettings taskSettings) { using (RectangleRegion surface = new RectangleRegion()) { surface.Config = taskSettings.CaptureSettings.SurfaceOptions; surface.Config.QuickCrop = true; surface.Config.ForceWindowCapture = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { if (surface.AreaManager.IsCurrentAreaValid) { rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentArea); return(true); } } else if (surface.Result == SurfaceResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null) { if (surfaceOptions == null) { surfaceOptions = new SurfaceOptions(); } using (RectangleRegion surface = new RectangleRegion()) { surface.Config = surfaceOptions; surface.OneClickMode = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { PointInfo pointInfo = new PointInfo(); pointInfo.Position = CaptureHelpers.ClientToScreen(surface.OneClickPosition); pointInfo.Color = ((Bitmap)surface.SurfaceImage).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y); return(pointInfo); } } return(null); }
public static bool SelectRegion(out Rectangle rect, TaskSettings taskSettings) { using (RectangleRegion surface = new RectangleRegion()) { surface.Config = taskSettings.CaptureSettings.SurfaceOptions; surface.Config.ShowTips = false; surface.Config.QuickCrop = true; surface.Config.ForceWindowCapture = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { if (surface.AreaManager.IsCurrentAreaValid) { rect = CaptureHelpers.ClientToScreen(surface.AreaManager.CurrentArea); return(true); } } else if (surface.Result == SurfaceResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } else if (surface.Result == SurfaceResult.Monitor) { Screen[] screens = Screen.AllScreens; if (surface.MonitorIndex < screens.Length) { Screen screen = screens[surface.MonitorIndex]; rect = screen.Bounds; return(true); } } else if (surface.Result == SurfaceResult.ActiveMonitor) { rect = CaptureHelpers.GetActiveScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public static bool GetRectangleRegion(out Rectangle rect, RegionCaptureOptions options) { RegionCaptureOptions newOptions = GetRegionCaptureOptions(options); newOptions.ShowHotkeys = false; using (RegionCaptureForm form = new RegionCaptureForm(RegionCaptureMode.Default, newOptions)) { form.Prepare(); form.ShowDialog(); if (form.Result == RegionResult.Region) { if (form.ShapeManager.IsCurrentShapeValid) { rect = CaptureHelpers.ClientToScreen(form.ShapeManager.CurrentRectangle); return(true); } } else if (form.Result == RegionResult.Fullscreen) { rect = CaptureHelpers.GetScreenBounds(); return(true); } else if (form.Result == RegionResult.Monitor) { Screen[] screens = Screen.AllScreens; if (form.MonitorIndex < screens.Length) { Screen screen = screens[form.MonitorIndex]; rect = screen.Bounds; return(true); } } else if (form.Result == RegionResult.ActiveMonitor) { rect = CaptureHelpers.GetActiveScreenBounds(); return(true); } } rect = Rectangle.Empty; return(false); }
public static PointInfo SelectPointColor() { using (RectangleRegion surface = new RectangleRegion()) { surface.OneClickMode = true; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { PointInfo pointInfo = new PointInfo(); pointInfo.Position = CaptureHelpers.ClientToScreen(surface.CurrentPosition); pointInfo.Color = surface.CurrentColor; return(pointInfo); } } return(null); }