Пример #1
0
        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;
        }
Пример #2
0
        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;
        }