private void tsbWindowRectangle_Click(object sender, EventArgs e) { RectangleRegion rectangleRegion = new RectangleRegion(); rectangleRegion.AreaManager.WindowCaptureMode = true; CaptureRegion(rectangleRegion); }
public AreaManager(RectangleRegion surface) { this.surface = surface; ResizeManager = new ResizeManager(surface, this); MinimumSize = 10; Areas = new List <Rectangle>(); SelectedAreaIndex = -1; surface.MouseDown += surface_MouseDown; surface.MouseUp += surface_MouseUp; surface.KeyDown += surface_KeyDown; surface.KeyUp += surface_KeyUp; }
public AreaManager(RectangleRegion surface) { this.surface = surface; ResizeManager = new ResizeManager(surface, this); MinimumSize = 10; Areas = new List<Rectangle>(); SelectedAreaIndex = -1; surface.MouseDown += surface_MouseDown; surface.MouseUp += surface_MouseUp; surface.KeyDown += surface_KeyDown; surface.KeyUp += surface_KeyUp; }
public static void OpenRuler() { using (Image fullscreen = Screenshot.CaptureFullscreen()) using (RectangleRegion surface = new RectangleRegion(fullscreen)) { surface.RulerMode = true; surface.Config.QuickCrop = false; surface.Config.ShowInfo = true; surface.Prepare(); surface.ShowDialog(); } }
public static PointInfo SelectPointColor(SurfaceOptions surfaceOptions = null) { if (surfaceOptions == null) { surfaceOptions = new SurfaceOptions(); } using (Image fullscreen = Screenshot.CaptureFullscreen()) using (RectangleRegion surface = new RectangleRegion(fullscreen)) { 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)fullscreen).GetPixel(surface.OneClickPosition.X, surface.OneClickPosition.Y); return pointInfo; } } return null; }
public static bool SelectRegion(out Rectangle rect) { using (RectangleRegion surface = new RectangleRegion()) { surface.AreaManager.WindowCaptureMode = true; surface.AreaManager.IncludeControls = 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; }
private void CaptureRegion(CaptureType captureType, TaskSettings taskSettings, bool autoHideForm = true) { Surface surface; switch (captureType) { default: case CaptureType.Rectangle: surface = new RectangleRegion(); break; case CaptureType.RectangleWindow: RectangleRegion rectangleRegion = new RectangleRegion(); rectangleRegion.AreaManager.WindowCaptureMode = true; surface = rectangleRegion; break; case CaptureType.RoundedRectangle: surface = new RoundedRectangleRegion(); break; case CaptureType.Ellipse: surface = new EllipseRegion(); break; case CaptureType.Triangle: surface = new TriangleRegion(); break; case CaptureType.Diamond: surface = new DiamondRegion(); break; case CaptureType.Polygon: surface = new PolygonRegion(); break; case CaptureType.Freehand: surface = new FreeHandRegion(); break; } DoCapture(() => { Image img = null; Image screenshot = Screenshot.CaptureFullscreen(); try { surface.Config = taskSettings.CaptureSettings.SurfaceOptions; surface.SurfaceImage = screenshot; surface.Prepare(); surface.ShowDialog(); if (surface.Result == SurfaceResult.Region) { img = surface.GetRegionImage(); screenshot.Dispose(); } else if (surface.Result == SurfaceResult.Fullscreen) { img = screenshot; } if (img != null) { isLightCapture = false; } } finally { surface.Dispose(); } return img; }, captureType, taskSettings, autoHideForm); }