Beispiel #1
0
        private void capture(ShotType shotType)
        {
            try
            {
                CaptureForm _captureForm = new CaptureForm(shotType);

                if ((_captureForm.ShowDialog() != DialogResult.OK) || (_captureForm.Image == null))
                {
                    return;
                }

                string _filename =
                    string.Format("{0}.{1}", DateTime.Now.ToString("yyyyMMddHHmmssff"), ImageFormat.Jpeg).ToLower();

                Image _img = _captureForm.Image;

                string _pathToSave = Path.Combine(GCONST.CachePath, _filename);

                _img.Save(_pathToSave, ImageFormat.Jpeg);

                Post(new List <string> {
                    GCONST.CachePath + _filename
                }, PostType.Photo);
            }
            catch (Exception _e)
            {
                MessageBox.Show(_e.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void CaptureWithFeedback()
        {
            using (CaptureForm captureForm = new CaptureForm(capture, windows))
            {
                DialogResult result = captureForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    selectedCaptureWindow = captureForm.SelectedCaptureWindow;
                    captureRect           = captureForm.CaptureRectangle;
                    // Get title
                    if (selectedCaptureWindow != null)
                    {
                        capture.CaptureDetails.Title = selectedCaptureWindow.Text;
                    }

                    // Experimental code
                    if (capture.CaptureDetails.CaptureMode == CaptureMode.Video)
                    {
                        if (captureForm.UsedCaptureMode == CaptureMode.Window)
                        {
                            screenCapture = new ScreenCaptureHelper(selectedCaptureWindow);
                        }
                        else if (captureForm.UsedCaptureMode == CaptureMode.Region)
                        {
                            screenCapture = new ScreenCaptureHelper(captureRect);
                        }
                        if (screenCapture != null)
                        {
                            screenCapture.RecordMouse = capture.CursorVisible;
                            if (screenCapture.Start(25))
                            {
                                return;
                            }
                            // User clicked cancel or a problem occured
                            screenCapture.Stop();
                            screenCapture = null;
                            return;
                        }
                    }

                    if (captureRect.Height > 0 && captureRect.Width > 0)
                    {
                        if (windowDetailsThread != null)
                        {
                            windowDetailsThread.Join();
                        }
                        // Take the captureRect, this already is specified as bitmap coordinates
                        capture.Crop(captureRect);
                        // save for re-capturing later and show recapture context menu option
                        RuntimeConfig.LastCapturedRegion = captureRect;
                        HandleCapture();
                    }
                }
            }
        }
        private void ButtonCapture_Click(object sender, EventArgs e)
        {
            var screenbounds = WindowCapture.GetScreenBounds();
            var capture      = new Capture();

            capture.CaptureDetails.CaptureMode = CaptureMode.Region;
            WindowCapture.CaptureRectangleFromDesktopScreen(capture, screenbounds);
            var windows = InteropWindowQuery.GetTopLevelWindows().ToList();
            var form    = new CaptureForm(CoreConfiguration.Instance, capture, windows);

            form.ShowDialog();
        }
Beispiel #4
0
        private void CaptureWithFeedback()
        {
            // The following, to be precise the HideApp, causes the app to close as described in BUG-1620
            // Added check for metro (Modern UI) apps, which might be maximized and cover the screen.

            //foreach(WindowDetails app in WindowDetails.GetMetroApps()) {
            //	if (app.Maximised) {
            //		app.HideApp();
            //	}
            //}

            using (CaptureForm captureForm = new CaptureForm(_capture, _windows)) {
                // Make sure the form is hidden after showing, even if an exception occurs, so all errors will be shown
                DialogResult result;
                try {
                    result = captureForm.ShowDialog(MainForm.Instance);
                } finally {
                    captureForm.Hide();
                }
                if (result == DialogResult.OK)
                {
                    _selectedCaptureWindow = captureForm.SelectedCaptureWindow;
                    _captureRect           = captureForm.CaptureRectangle;
                    // Get title
                    if (_selectedCaptureWindow != null)
                    {
                        _capture.CaptureDetails.Title = _selectedCaptureWindow.Text;
                    }

                    if (_captureRect.Height > 0 && _captureRect.Width > 0)
                    {
                        // Take the captureRect, this already is specified as bitmap coordinates
                        _capture.Crop(_captureRect);

                        // save for re-capturing later and show recapture context menu option
                        // Important here is that the location needs to be offsetted back to screen coordinates!
                        Rectangle tmpRectangle = _captureRect;
                        tmpRectangle.Offset(_capture.ScreenBounds.Location.X, _capture.ScreenBounds.Location.Y);
                        CoreConfig.LastCapturedRegion = tmpRectangle;
                        HandleCapture();
                    }
                }
            }
        }
Beispiel #5
0
        private void CaptureScreen(int row)
        {
            DataGridViewRow currentRow = capturesDataGridView.Rows[row];

            CaptureForm captureForm = new CaptureForm(
                capturesDataGridView.Rows[row].Cells["Url"].Value.ToString(),
                (int)currentRow.Cells["BrowserWidth"].Value,
                (int)currentRow.Cells["BrowserHeight"].Value,
                (int)currentRow.Cells["ImageWidth"].Value,
                (int)currentRow.Cells["ImageHeight"].Value);

            if (captureForm.ShowDialog(this) == DialogResult.OK
                && captureForm.CancelProcess == false)
            {
                SaveToDB((long)currentRow.Cells["UrlId"].Value,
                    currentRow.Cells["Url"].Value.ToString(),
                    (int)currentRow.Cells["BrowserWidth"].Value,
                    (int)currentRow.Cells["BrowserHeight"].Value,
                    (int)currentRow.Cells["ImageWidth"].Value,
                    (int)currentRow.Cells["ImageHeight"].Value);

                RefreshGrid(currentRow.Index);

                if (Properties.Settings.Default.displayPreviewWindow)
                {
                    PreviewForm previewForm = new PreviewForm(captureForm.Screenshot, captureForm.DocumentTitle);

                    if (Properties.Settings.Default.maximizePreviewWindow == true)
                        previewForm.WindowState = FormWindowState.Maximized;

                    previewForm.ShowDialog(this);
                }

                if (Properties.Settings.Default.autoSave && Properties.Settings.Default.defaultFolder != "")
                {
                    MessageBox.Show(Properties.Settings.Default.defaultFolder + @"\" + captureForm.DocumentTitle);
                }
            }
        }
Beispiel #6
0
 /// <summary>
 /// トリミングポイントを取得する
 /// </summary>
 /// <param name="screen"></param>
 /// <returns></returns>
 public static int[] GetScreenTrimmingPoint(Screen screen, Rectangle captureArea)
 {
     try
     {
         Image  bmp      = CaptureUtil.CaptureScreen(screen, captureArea);
         string fileName = Guid.NewGuid().ToString().Replace("-", "").ToLower() + ".png";
         string filePath = Program.TMP_FOLDER + @"\" + fileName;
         bmp.Save(filePath, ImageFormat.Png);
         CaptureForm form = new CaptureForm();
         form.Init(filePath);
         form.TopMost = true;
         form.ShowDialog();
         if (form.CaptureResult == DialogResult.OK)
         {
             return(form.TrimPoint);
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Beispiel #7
0
        private void captureStartMenuItem_Click(object sender, EventArgs e)
        {
            tmpEventList.Clear();
            tmpPacketList.Clear();

            captureStartMenuItem.Enabled = false;

            object source = dataGridView.DataSource;
            dataGridView.DataSource = null;

            CaptureForm frm = new CaptureForm(listener, swForm.GetRules());
            frm.ShowDialog(this);

            dataGridView.DataSource = null;

            ProgressForm progFrm = new ProgressForm("Analyzing data");

            Thread th = new Thread(new ParameterizedThreadStart(DoPostAnalysis));
            th.Start(progFrm);

            progFrm.ShowDialog(this);
        }
Beispiel #8
0
        private void CaptureWithFeedback()
        {
            // The following, to be precise the HideApp, causes the app to close as described in BUG-1620
            // Added check for metro (Modern UI) apps, which might be maximized and cover the screen.

            //foreach(WindowDetails app in WindowDetails.GetMetroApps()) {
            //	if (app.Maximised) {
            //		app.HideApp();
            //	}
            //}

            using (CaptureForm captureForm = new CaptureForm(_capture, _windows)) {
                DialogResult result = captureForm.ShowDialog();
                if (result == DialogResult.OK) {
                    _selectedCaptureWindow = captureForm.SelectedCaptureWindow;
                    _captureRect = captureForm.CaptureRectangle;
                    // Get title
                    if (_selectedCaptureWindow != null) {
                        _capture.CaptureDetails.Title = _selectedCaptureWindow.Text;
                    }

                    if (_captureRect.Height > 0 && _captureRect.Width > 0) {
                        // Take the captureRect, this already is specified as bitmap coordinates
                        _capture.Crop(_captureRect);

                        // save for re-capturing later and show recapture context menu option
                        // Important here is that the location needs to be offsetted back to screen coordinates!
                        Rectangle tmpRectangle = _captureRect;
                        tmpRectangle.Offset(_capture.ScreenBounds.Location.X, _capture.ScreenBounds.Location.Y);
                        conf.LastCapturedRegion = tmpRectangle;
                        HandleCapture();
                    }
                }
            }
        }
Beispiel #9
0
        // Show the capture form and allow user to locate gem grid
        private void captureButton_Click(object sender, EventArgs e)
        {
            var cf = new CaptureForm();

            if (cf.ShowDialog() == DialogResult.OK)
            {
                // size is how big an area of the screen to capture
                // origin is the upper left corner of the area to capture
                // startPoint is the point we start sampling colour pixels from within that area
                // capturedArea holds the bitmap data for the current iteration

                origin = cf.Coordinate; // Get the coordinate clicked in the capture form and set it as the origin
                var start = cf.Coordinate; // Get the coordinate clicked in the capture form and set it as the origin

                capturedArea = new Bitmap(size.Width, size.Height);

                CaptureArea(); // Get an initial snapshot where clicked

                // Seek for the top left corner of the gem grid, with a tolerance of 50 pixels
                // This means you only have to approximately click the top left corner
                // Down
                for (int y = 0; y < 50; y++)
                {
                    // Across
                    for (int x = 0; x < 50; x++)
                    {
                        Color c1 = capturedArea.GetPixel(x, y);

                        // If we've found a pixel that matches our top left pixel colour
                        if(c1.R == 70 && c1.G == 33 && c1.B == 10)
                        {
                            Color c2 = capturedArea.GetPixel(x, (y + 1));

                            // And the pixel directly below that matches this
                            if (c2.R == 43 && c2.G == 23 && c2.B == 13)
                            {
                                Color c3 = capturedArea.GetPixel(x, (y + 2));

                                // And the pixel directly below that matches this
                                if (c3.R == 23 && c3.G == 21 && c3.B == 32)
                                {
                                    // This is our top left pixel
                                    origin.X += x;
                                    origin.Y += y;
                                }
                            }
                        }
                    }
                }

                startPoint = new Point(origin.X + leftOffset, origin.Y + topOffset);

                CaptureArea();
                ScanGrid(true);

                // Show the preview so user can check selection is correct
                preview.Image = capturedArea;
            }
        }
 private void ButtonCaptureClick(object sender, EventArgs e)
 {
     Editor.MainInstance.Visible = false;
     Visible = false;
     Thread.Sleep(500);
     using (var captureForm = new CaptureForm())
     {
         captureForm.TakeSnapShot();
         captureForm.ShowDialog();
         this.Color = captureForm.CaptureColor;
         this.SetRGBLabels(this._argb);
         this.SetHSVLabels(this._hsv);
         this.SetRGB(this._argb);
         this.SetHSV(this._hsv);
     }
     Editor.MainInstance.Visible = true;
     Visible = true;
 }
Beispiel #11
0
        private void 截图CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CaptureForm c = new CaptureForm();

            c.ShowDialog();
        }
        private void CaptureWithFeedback()
        {
            using (CaptureForm captureForm = new CaptureForm(capture, windows))
            {
                DialogResult result = captureForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    selectedCaptureWindow = captureForm.SelectedCaptureWindow;
                    captureRect = captureForm.CaptureRectangle;
                    // Get title
                    if (selectedCaptureWindow != null)
                    {
                        capture.CaptureDetails.Title = selectedCaptureWindow.Text;
                    }

                    // Experimental code
                    if (capture.CaptureDetails.CaptureMode == CaptureMode.Video)
                    {
                        if (captureForm.UsedCaptureMode == CaptureMode.Window)
                        {
                            screenCapture = new ScreenCaptureHelper(selectedCaptureWindow);
                        }
                        else if (captureForm.UsedCaptureMode == CaptureMode.Region)
                        {
                            screenCapture = new ScreenCaptureHelper(captureRect);
                        }
                        if (screenCapture != null)
                        {
                            screenCapture.RecordMouse = capture.CursorVisible;
                            if (screenCapture.Start(25))
                            {
                                return;
                            }
                            // User clicked cancel or a problem occured
                            screenCapture.Stop();
                            screenCapture = null;
                            return;
                        }
                    }

                    if (captureRect.Height > 0 && captureRect.Width > 0)
                    {
                        if (windowDetailsThread != null)
                        {
                            windowDetailsThread.Join();
                        }
                        // Take the captureRect, this already is specified as bitmap coordinates
                        capture.Crop(captureRect);
                        // save for re-capturing later and show recapture context menu option
                        RuntimeConfig.LastCapturedRegion = captureRect;
                        HandleCapture();
                    }
                }
            }
        }