コード例 #1
0
ファイル: Surface.cs プロジェクト: yoykiee/ShareX
        public Surface(Image backgroundImage = null)
        {
            ScreenRectangle = CaptureHelpers.GetScreenBounds();
            ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle);

            InitializeComponent();

            using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
            {
                Cursor = new Cursor(cursorStream);
            }

            if (backgroundImage != null)
            {
                SurfaceImage = backgroundImage;
                Prepare();
            }

            DrawableObjects = new List<DrawableObject>();
            Config = new SurfaceOptions();
            timer = new Stopwatch();

            borderPen = new Pen(Color.Black);
            borderDotPen = new Pen(Color.Black, 1);
            borderDotPen2 = new Pen(Color.White, 1);
            borderDotPen2.DashPattern = new float[] { 5, 5 };
            nodeBackgroundBrush = new SolidBrush(Color.White);
            textFont = new Font("Arial", 17, FontStyle.Bold);
        }
コード例 #2
0
ファイル: ScreenColorPicker.cs プロジェクト: TreeSeed/ShareX
        public ScreenColorPicker(TaskSettings taskSettings)
        {
            if (taskSettings != null)
            {
                surfaceOptions = taskSettings.CaptureSettings.SurfaceOptions;
            }
            else
            {
                surfaceOptions = new SurfaceOptions();
            }

            InitializeComponent();
            colorPicker.DrawCrosshair = true;
            colorTimer.Tick += colorTimer_Tick;

            UpdateControls(true);

            foreach (Control control in Controls)
            {
                if (control is NumericUpDown || control is TextBox)
                {
                    control.DoubleClick += CopyToClipboard;
                }
            }
        }
コード例 #3
0
        public Surface(Image backgroundImage = null)
        {
            ScreenRectangle       = CaptureHelpers.GetScreenBounds();
            ScreenRectangle0Based = CaptureHelpers.ScreenToClient(ScreenRectangle);

            InitializeComponent();

            using (MemoryStream cursorStream = new MemoryStream(Resources.Crosshair))
            {
                Cursor = new Cursor(cursorStream);
            }

            if (backgroundImage != null)
            {
                SurfaceImage = backgroundImage;
                Prepare();
            }

            DrawableObjects = new List <DrawableObject>();
            Config          = new SurfaceOptions();
            timer           = new Stopwatch();

            borderPen                 = new Pen(Color.Black);
            borderDotPen              = new Pen(Color.Black, 1);
            borderDotPen2             = new Pen(Color.White, 1);
            borderDotPen2.DashPattern = new float[] { 5, 5 };
            nodeBackgroundBrush       = new SolidBrush(Color.White);
            textFont = new Font("Arial", 17, FontStyle.Bold);
        }
コード例 #4
0
        public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options)
        {
            if (regionFillPath != null)
            {
                Image img;

                Rectangle regionArea = Rectangle.Round(regionFillPath.GetBounds());
                Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
                Rectangle newRegionArea = Rectangle.Intersect(regionArea, screenRectangle);

                using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
                {
                    MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                    img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp);

                    if (options.DrawBorder)
                    {
                        GraphicsPath gpOutline = regionDrawPath ?? regionFillPath;

                        using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone())
                        {
                            MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                            img = ImageHelpers.DrawOutline(img, gp2);
                        }
                    }
                }

                return img;
            }

            return null;
        }
コード例 #5
0
        public RegionCapturePreview(SurfaceOptions surfaceConfig)
        {
            InitializeComponent();

            screenshot = Screenshot.CaptureFullscreen();
            SurfaceConfig = surfaceConfig;
            pgSurfaceConfig.SelectedObject = SurfaceConfig;
        }
コード例 #6
0
        public RegionCapturePreview(SurfaceOptions surfaceConfig)
        {
            InitializeComponent();

            screenshot    = Screenshot.CaptureFullscreen();
            SurfaceConfig = surfaceConfig;
            pgSurfaceConfig.SelectedObject = SurfaceConfig;
        }
コード例 #7
0
ファイル: ShapeCaptureHelpers.cs プロジェクト: Z1ni/ShareX
        public static Image GetRegionImage(Image surfaceImage, GraphicsPath regionFillPath, GraphicsPath regionDrawPath, SurfaceOptions options)
        {
            if (regionFillPath != null)
            {
                Image img;

                Rectangle regionArea      = Rectangle.Round(regionFillPath.GetBounds());
                Rectangle screenRectangle = CaptureHelpers.GetScreenBounds0Based();
                Rectangle newRegionArea   = Rectangle.Intersect(regionArea, screenRectangle);

                using (GraphicsPath gp = (GraphicsPath)regionFillPath.Clone())
                {
                    MoveGraphicsPath(gp, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                    img = ImageHelpers.CropImage(surfaceImage, newRegionArea, gp);

                    if (options.DrawBorder)
                    {
                        GraphicsPath gpOutline = regionDrawPath ?? regionFillPath;

                        using (GraphicsPath gp2 = (GraphicsPath)gpOutline.Clone())
                        {
                            MoveGraphicsPath(gp2, -Math.Max(0, regionArea.X), -Math.Max(0, regionArea.Y));
                            img = ImageHelpers.DrawOutline(img, gp2);
                        }
                    }
                }

                return(img);
            }

            return(null);
        }
コード例 #8
0
ファイル: TaskHelpers.cs プロジェクト: jasonlamb/ShareX
        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;
        }