Пример #1
0
        private void PbCaptureBox_MouseMove(object sender, MouseEventArgs e) //영역그리는 중
        {
            if (drawingCaptureBoxsStart && captureMouseDown)
            {
                mousePosition = e.Location;

                captureMouseMove = true;
                PbCaptureBox.Invalidate();
            }
        }
Пример #2
0
        private void InitializeCapturing() //캡처 초기화
        {
            PbCaptureBox.Invalidate();
            PbCaptureBox.Location = new Point(0, 0);
            PbCaptureBox.Size     = new Size(0, 0);
            PbCaptureBox.Visible  = false;

            drawingCaptureBoxsStart = false;
            captureMouseDown        = false;
            captureMouseMove        = false;

            PbCaptureBox.SendToBack();
        }
Пример #3
0
        private void PbCaptureBox_MouseUp(object sender, MouseEventArgs e) //영역 지정 완료
        {
            PbCaptureBox.Invalidate();

            captureTargetSet = false;

            if (drawingCaptureBoxsStart && captureMouseDown && captureMouseMove)
            {
                try
                {
                    Rectangle capturedImgBox = CreateRectangle();

                    Bitmap capturedImgBitMap = new Bitmap(capturedImgBox.Width - 1, capturedImgBox.Height - 1);

                    Graphics capturedImgCanvas = Graphics.FromImage(capturedImgBitMap);
                    capturedImgCanvas.CopyFromScreen(capturedImgBox.Left + 1, capturedImgBox.Top + 1, 0, 0, capturedImgBitMap.Size);

                    PbCapturedImg.Image = capturedImgBitMap;

                    captureTarget = new Rectangle(new Point(capturedImgBox.Left + 1, capturedImgBox.Top + 1), capturedImgBitMap.Size);

                    captureTargetSet = true;

                    BtnStartCapture.BackColor = Color.Aquamarine;
                }
                catch (Exception ex)
                {
                    logger.Fatal("Exception Occured at MouseUp Process : " + ex.Message);
                    StopCapturing();
                }
                finally
                {
                    StopCapturing();
                }
            }
        }