Exemple #1
0
        private bool ShowImageCaptureDialog(out string filepath, out Rectangle rect)
        {
            filepath = null;
            var screen = ImageCapture.BitmapFromScreen();

            // スクリーン範囲ドラッグ
            var cs = new ScreenSelection();

            rect = cs.ShowGetRectDialog(screen, "画像領域をドラッグしてください");
            if (rect.IsEmpty)
            {
                return(false);
            }

            // 指定範囲をファイルに保存
            filepath = ShowSaveFileDialog();
            if (filepath == null)
            {
                return(false);
            }
            Bitmap bmp = screen.Clone(rect, screen.PixelFormat);

            bmp.Save(filepath, ImageFormat.Bmp);
            return(true);
        }
Exemple #2
0
        private void ShowGetDragDialog(out System.Drawing.Point[] line)
        {
            // スクリーン範囲ドラッグ
            var cs = new ScreenSelection();

            line = cs.ShowGetLineDialog(ImageCapture.BitmapFromScreen(), "ドラッグしてください");
        }
Exemple #3
0
        /// <summary>
        /// 画像キャプチャとそこからのクリックオフセット位置を取得するダイアログ
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="offset"></param>
        private void ShowGetClickOffsetFromCapture(out string filepath, out System.Drawing.Point offset)
        {
            filepath = null;
            offset   = System.Drawing.Point.Empty;
            var screen = ImageCapture.BitmapFromScreen();

            // スクリーン範囲ドラッグ
            var cs          = new ScreenSelection();
            var captureRect = cs.ShowGetRectDialog(screen, "画像領域をドラッグしてください");

            if (captureRect.IsEmpty)
            {
                return;
            }

            // 指定範囲をファイルに保存
            filepath = ShowSaveFileDialog();
            if (filepath == null)
            {
                return;
            }
            Bitmap bmp = screen.Clone(captureRect, screen.PixelFormat);

            bmp.Save(filepath, ImageFormat.Bmp);

            // 相対クリック一取得
            cs = new ScreenSelection();
            var clickPoint = cs.ShowGetPointDialog(screen, "クリックする座標を指定してください");

            if (clickPoint.IsEmpty)
            {
                return;
            }

            // 画像の切り出し
            offset   = new System.Drawing.Point();
            offset.X = clickPoint.X - captureRect.X;
            offset.Y = clickPoint.Y - captureRect.Y;
        }
Exemple #4
0
        /// <summary>
        /// 画像キャプチャとそこからのドラッグ位置を取得する
        /// </summary>
        /// <param name="filepath"></param>
        /// <param name="offset"></param>
        private void ShowGetDragOffsetFromCapture(out string filepath, out System.Drawing.Point[] line)
        {
            filepath = null;
            line     = null;

            var screen = ImageCapture.BitmapFromScreen();

            // スクリーン範囲ドラッグ
            var cs          = new ScreenSelection();
            var captureRect = cs.ShowGetRectDialog(screen, "画像領域をドラッグしてください");

            if (captureRect.IsEmpty)
            {
                return;
            }

            // 指定範囲をファイルに保存
            filepath = ShowSaveFileDialog();
            if (filepath == null)
            {
                return;
            }
            Bitmap bmp = screen.Clone(captureRect, screen.PixelFormat);

            bmp.Save(filepath, ImageFormat.Bmp);

            // 相対クリック一取得
            cs = new ScreenSelection();
            var absLine = cs.ShowGetLineDialog(screen, "ドラッグしてください");

            // 画像の切り出し
            line      = new System.Drawing.Point[2];
            line[0].X = absLine[0].X - captureRect.X;
            line[0].Y = absLine[0].Y - captureRect.Y;
            line[1].X = absLine[1].X - captureRect.X;
            line[1].Y = absLine[1].Y - captureRect.Y;
        }
Exemple #5
0
        private void ShowGetClickPosDialog(out System.Drawing.Point pos)
        {
            var cs = new ScreenSelection();

            pos = cs.ShowGetPointDialog(ImageCapture.BitmapFromScreen(), "クリックする座標を指定してください");
        }