Example #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);
            }
        }
Example #2
0
 private void EndCapture(CaptureForm cform)
 {
     try
     {
         Console.WriteLine("Mainform EndCapture Start---");
         if (cform.DialogResult == DialogResult.OK)
         {
             using (Bitmap bitmap = cform.ClipBitmap)
             {
                 if (bitmap != null)
                 {
                     this.scrapBook.AddScrap(bitmap, cform.ClipStart.X, cform.ClipStart.Y, cform.ClipSize.Width, cform.ClipSize.Height);
                 }
             }
         }
         cform.Hide();
         Cursor.Clip = Rectangle.Empty;
         Console.WriteLine("Mainform EndCapture End---");
     }
     catch (Exception exception)
     {
         Console.WriteLine("MainForm EndCapture Exception:" + exception.Message);
     }
     finally
     {
         this.IsCapture = false;
         if (this.frmClickCapture != null)
         {
             this.frmClickCapture.Restart();
         }
     }
 }
Example #3
0
        public void DoSnapshot(WorkMode mode, CaptureMode method)
        {
            EndDrawShape();
            EndRangeSelection();

            Opacity = 0;
            Thread.Sleep(200);

            CaptureForm.StartCapture(mode, method, (image) =>
            {
                if (image != null)
                {
                    Bitmap copiedImage = new Bitmap(image);
                    using (Graphics g = Graphics.FromImage(copiedImage))
                    {
                        g.DrawImageUnscaled(image, 0, 0);
                    }

                    AddHistory(copiedImage);
                }

                Opacity = 1;

                Activate();
                Focus();
            });
        }
Example #4
0
        protected override void OnLoad(EventArgs e)
        {
            base.Visible = false;
            this.LoadOption();
            this.InitData();

            var tDpi = Math.Max(1, DPIUtils.GetPrimaryDpi());

            this.Width  = (int)Math.Round(300 * tDpi);
            this.Height = (int)Math.Round(100 * tDpi);

            this.OptionApply();
            this.SaveOption();
            if (this.optSetuna.Setuna.ShowSplashWindow)
            {
                this.frmSplash = new SplashForm();
                base.AddOwnedForm(this.frmSplash);
                this.frmSplash.Show(this);
                this.frmSplash.SplashTimer.Start();
            }
            this.timPool.Start();
            cap_form     = new CaptureForm(this.optSetuna.Setuna);
            this.IsStart = true;

            mLayerInfo = new LayerInfo(this);

            this.UpdateTopMostTimer();
        }
Example #5
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            var captureForm = new CaptureForm();

            captureForm.OnCaptured += CaptureForm_OnCaptured;
            captureForm.Show();
        }
Example #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var mainCaptureForm = new CaptureForm();
            Application.Run(mainCaptureForm);
        }
        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();
                    }
                }
            }
        }
Example #8
0
        public override bool Execute()
        {
            SetState(State.ConnectedBusy);
            var form = new CaptureForm(_appState, _colorForm, _commsPort)
            {
                MdiParent = _mainForm, Visible = true
            };

            form.StartCapture();
            return(true);
        }
Example #9
0
 //截图方法
 private void StartCapture()
 {
     if ((frmCapture == null) || frmCapture.IsDisposed)
     {
         frmCapture             = new CaptureForm();
         frmCapture.OnCaptured += frmCapture_OnCaptured;
     }
     frmCapture.IsCaptureCursor = true;
     frmCapture.IsFromClipBoard = false;
     frmCapture.Show();
 }
        private void Backbtn_Click(object sender, EventArgs e)
        {
            capture.OnTemplate -= OnTemplate;
            capture             = new CaptureForm();
            Template            = new DPFP.Template();

            this.Hide();
            MainForm mainForm = new MainForm();

            mainForm.ShowDialog();
            this.Close();
        }
Example #11
0
 private void CommandCutRect(Rectangle rect, string fname)
 {
     using (Bitmap bitmap = new Bitmap(rect.Width, rect.Height, PixelFormat.Format24bppRgb))
     {
         Point location = new Point(rect.X, rect.Y);
         CaptureForm.CopyFromScreen(bitmap, location);
         if (fname == "")
         {
             this.AddImageList(new ScrapSourceImage(bitmap, location));
         }
     }
 }
        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();
        }
Example #13
0
 public override bool Execute()
 {
     if (_openFileDialog.ShowDialog() == DialogResult.OK)
     {
         var form = new CaptureForm(_appState, _colorForm, _commsPort)
         {
             MdiParent = _mainForm
         };
         form.Show();
         form.LoadFile(_openFileDialog.FileName);
         return(true);
     }
     return(false);
 }
Example #14
0
        public WindowHelper()
        {
            InitializeComponent();

            this.ShowInTaskbar = false;
            wd = new WeatherDescription();
            cf = new CaptureForm();
            sr = new search.search();
            x  = System.Windows.Forms.SystemInformation.WorkingArea.Width - this.Size.Width;
            y  = System.Windows.Forms.SystemInformation.WorkingArea.Height / 10;
            this.StartPosition = FormStartPosition.Manual;    //窗体的位置由Location属性决定
            this.Location      = (Point) new Size(x - 20, y); //窗体的起始位置为(x,y)
            timer1_Tick(null, null);
            timer2_Tick(null, null);
        }
        private void Save_Click(object sender, EventArgs e)
        {
            try
            {
                String name      = txtname.Text.Trim();
                String phone     = txtph.Text.Trim();
                String mail      = txtem.Text.Trim();
                String filename  = phone;
                string filePath  = path + filename + ".fpt";
                String ariveTime = textArrivalHH.Text + ":" + textArrivalMM.Text;
                String exitTime  = textExitHH.Text + ":" + textExitMM.Text;
                if (name.Length > 2 && phone.Length > 5 && mail.Length > 3 && ariveTime.Length > 1 && exitTime.Length > 1)
                {
                    // (id,name,phoneno,email,filename)
                    SqlCommand cmd = new SqlCommand("INSERT INTO [Person](name, email, phone, timeArival, timeExit) VALUES('" + name + "','" + mail + "','" + phone + "','" + ariveTime + "', '" + exitTime + "')", con);
                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();

                    //Save File on Drive
                    FileStream fs = File.Open(filePath, FileMode.Create, FileAccess.Write);
                    Template.Serialize(fs);
                    fs.Close();

                    MessageBox.Show("Record Has been saved Sucsessfully!", "Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    con.Close();
                    txtname.Text      = String.Empty;
                    txtph.Text        = String.Empty;
                    txtem.Text        = String.Empty;
                    pictureBox6.Image = null;
                }
                else
                {
                    MessageBox.Show("Record Cannot Be Added Unless it is valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                con.Close();
                MessageBox.Show("An Error occured During Saving File \n" + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                capture.OnTemplate -= OnTemplate;
                capture             = new CaptureForm();
                Template            = new DPFP.Template();
            }
        }
Example #16
0
 private void Mainform_Load(object sender, EventArgs e)
 {
     base.Visible = false;
     this.LoadOption();
     this.OptionApply();
     this.SaveOption();
     if (this.optSetuna.Setuna.ShowSplashWindow)
     {
         this.frmSplash = new SplashForm();
         base.AddOwnedForm(this.frmSplash);
         this.frmSplash.Show(this);
         this.frmSplash.SplashTimer.Start();
     }
     this.timPool.Start();
     cap_form     = new CaptureForm(this.optSetuna.Setuna);
     this.IsStart = true;
 }
Example #17
0
        public void SendKeysGrouping()
        {
            // Regression https://github.com/dotnet/winforms/issues/6666

            using var form = new CaptureForm();
            form.Show();
            form.Focus();
            SendKeys.SendWait("^(a)^(c)");

            Assert.Equal(4, form.KeyEvents.Count);
            Assert.Equal(Keys.ControlKey, form.KeyEvents[0].KeyCode);
            Assert.Equal(Keys.A, form.KeyEvents[1].KeyCode);
            Assert.Equal(Keys.Control, form.KeyEvents[1].Modifiers);
            Assert.Equal(Keys.ControlKey, form.KeyEvents[2].KeyCode);
            Assert.Equal(Keys.C, form.KeyEvents[3].KeyCode);
            Assert.Equal(Keys.Control, form.KeyEvents[3].Modifiers);
        }
Example #18
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            lang = Language.GetInstance();
            IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

            // Make sure all hotkeys pass this window!
            HotkeyControl.RegisterHotkeyHWND(this.Handle);
            RegisterHotkeys();

            tooltip = new ToolTip();

            UpdateUI();
            InitializeQuickSettingsMenu();

            captureForm = new CaptureForm();

            // Load all the plugins
            PluginHelper.instance.LoadPlugins(this, captureForm);
            SoundHelper.Initialize();

            // Enable the Greenshot icon to be visible, this prevents Problems with the context menu
            notifyIcon.Visible = true;

            // Create a new instance of the class: copyData = new CopyData();
            copyData = new CopyData();

            // Assign the handle:
            copyData.AssignHandle(this.Handle);
            // Create the channel to send on:
            copyData.Channels.Add("Greenshot");
            // Hook up received event:
            copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

            if (dataTransport != null)
            {
                HandleDataTransport(dataTransport);
            }
            ClipboardHelper.RegisterClipboardViewer(this.Handle);
        }
Example #19
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();
                    }
                }
            }
        }
        public CaptureForm(ICapture capture, List<WindowDetails> windows)
        {
            if (currentForm != null) {
                LOG.Debug("Found currentForm, Closing already opened CaptureForm");
                currentForm.Close();
                currentForm = null;
                Application.DoEvents();
            }
            currentForm = this;

            // clean up
            this.FormClosed += delegate {
                currentForm = null;
                LOG.Debug("Remove CaptureForm from currentForm");
            };

            this.capture = capture;
            this.windows = windows;
            captureMode = capture.CaptureDetails.CaptureMode;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();
            this.Text = "Greenshot capture form";

            // Make sure we never capture the captureform
            WindowDetails.RegisterIgnoreHandle(this.Handle);
            // TODO: Need to call unregister at close

            // set cursor location
            cursorPos = WindowCapture.GetCursorLocation();
            // Offset to screen coordinates
            cursorPos.Offset(-capture.ScreenBounds.X, -capture.ScreenBounds.Y);

            this.SuspendLayout();
            pictureBox.Image = capture.Image;
            this.Bounds = capture.ScreenBounds;
            this.ResumeLayout();

            // Fix missing focus
            WindowDetails.ToForeground(this.Handle);
        }
Example #21
0
        //启动截图
        public void StartCapture(bool fromClip)
        {
            CaptureForm capture = new CaptureForm();

            capture.Finishing += Capture_Finish;
            try
            {
                if (!CaptureForm.isAlive)
                {
                    capture.IsCaptureCursor = false;
                    capture.IsFromClipBoard = fromClip;
                    capture.Show();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        public CaptureHand(CaptureForm form)
            : base()
        {
            pp = new UtilMPipeline();
            pp.EnableGesture();
            pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH);

            if (pp.Init())
            {

                pp.QueryCapture().SetFilter(PXCMCapture.Device.Property.PROPERTY_DEPTH_SMOOTHING, 100);
                do
                {
                    if (!pp.AcquireFrame(true))
                    {
                        MessageBox.Show("Failed to aquire a frame.", "Kwi-S", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                        break;
                    }

                    gesture =  pp.QueryGesture();

                    gesture.QueryBlobData(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bdata);

                    gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bimage);

                    bimage.AcquireAccess(PXCMImage.Access.ACCESS_READ,out  data);
                    info = bimage.imageInfo;

                    color =(int) bdata.labelLeftHand;

                    form.setTextBox(color.ToString());

                    pp.ReleaseFrame();

                } while (color == -1);

                Coord[] locations = handLocation(data, (int)(info.width * info.height),(int) info.width);
                bitmap = createBitmap(locations, (int)info.width, (int)info.height);
                form.setImage(bitmap);
                form.bitmap = bitmap;

            }
        }
Example #23
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);
                }
            }
        }
Example #24
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);
     }
 }
Example #25
0
		private void ClosedHandler(object sender, EventArgs e) {
			_currentForm = null;
			LOG.Debug("Remove CaptureForm from currentForm");
		}
Example #26
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();
                    }
                }
            }
        }
Example #27
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;
            }
        }
Example #28
0
        private void 截图CToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CaptureForm c = new CaptureForm();

            c.ShowDialog();
        }
 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;
 }
        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();
                    }
                }
            }
        }
Example #31
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);
        }
Example #32
0
 private void systemHotkey2_Pressed(object sender, EventArgs e)
 {
     bool visible = this.Visible;
     if(visible)
         this.Hide();
     CaptureForm frm = new CaptureForm(this, visible, clipboardSender, notifyIcon);
     frm.Show();
     frm.Focus();
 }
Example #33
0
        public MainForm(CopyDataTransport dataTransport)
        {
            instance = this;
             //
             // The InitializeComponent() call is required for Windows Forms designer support.
             //
             InitializeComponent();
             lang = Language.GetInstance();
             IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);

             // Make sure all hotkeys pass this window!
             HotkeyControl.RegisterHotkeyHWND(this.Handle);
             RegisterHotkeys();

             tooltip = new ToolTip();

             UpdateUI();
             InitializeQuickSettingsMenu();

             captureForm = new CaptureForm();

             // Load all the plugins
             PluginHelper.instance.LoadPlugins(this, captureForm);
             SoundHelper.Initialize();

             // Enable the Greenshot icon to be visible, this prevents Problems with the context menu
             notifyIcon.Visible = true;

             // Create a new instance of the class: copyData = new CopyData();
             copyData = new CopyData();

             // Assign the handle:
             copyData.AssignHandle(this.Handle);
             // Create the channel to send on:
             copyData.Channels.Add("Greenshot");
             // Hook up received event:
             copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);

             if (dataTransport != null)
             {
            HandleDataTransport(dataTransport);
             }
             ClipboardHelper.RegisterClipboardViewer(this.Handle);
        }
		public void Run()
		{
			using (CaptureForm form = new CaptureForm())
			{
				const int Fps = 60;
				const double Wait = 1000.0 / Fps;

				const int CaptureTimeSec = 30;

				double endCount = System.Environment.TickCount + CaptureTimeSec * 1000;
				double nextFrame = System.Environment.TickCount + Wait;

				form.Show();
				form.BeginCapture();
				while (form.Created)
				{
					try
					{
						int now = System.Environment.TickCount;
						if (now >= nextFrame)
						{
							if (now < nextFrame + Wait)
							{
								// 更新タイミングなら更新
								form.MyUpdate();
								form.Render();
							}
							nextFrame += Wait;
						}
						int sleepTime = (int)(nextFrame - now);
						if (sleepTime > 0) Thread.Sleep(sleepTime);
						Application.DoEvents();
					}
					catch (Exception e)
					{ 
						MessageBox.Show(e.Message);
					}
				}
			}
		}
Example #35
0
        private void findGameScreenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (gameEngine != null)
                KillGameEngine();

            foreach (Screen screen in Screen.AllScreens)
            {
            #if DEBUG
                if (screen.Primary) // DEBUG
                    continue;
            #endif
                CaptureForm cf = new CaptureForm();
                cf.StartPosition = FormStartPosition.Manual;
                cf.Bounds = screen.Bounds;
                cf.WindowState = FormWindowState.Maximized;
                cf.FormClosed += new FormClosedEventHandler(CaptureForm_Closed);

                cf.Show();

                captureForms.Add(cf);

            }
        }
Example #36
-1
		/// <summary>
		/// This creates the capture form
		/// </summary>
		/// <param name="capture"></param>
		/// <param name="windows"></param>
		public CaptureForm(ICapture capture, List<WindowDetails> windows) {
			if (_currentForm != null) {
				LOG.Warn("Found currentForm, Closing already opened CaptureForm");
				_currentForm.Close();
				_currentForm = null;
				Application.DoEvents();
			}
			_currentForm = this;

			// Enable the AnimatingForm
			EnableAnimation = true;

			// clean up
			FormClosed += ClosedHandler;

			_capture = capture;
			_windows = windows;
			_captureMode = capture.CaptureDetails.CaptureMode;

			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			// Only double-buffer when we are not in a TerminalServerSession
			DoubleBuffered = !isTerminalServerSession;
			Text = "Greenshot capture form";

			// Make sure we never capture the captureform
			WindowDetails.RegisterIgnoreHandle(Handle);
			// Unregister at close
			FormClosing += ClosingHandler;

			// set cursor location
			_cursorPos = WindowCapture.GetCursorLocationRelativeToScreenBounds();

			// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor 
			if (_captureMode == CaptureMode.Window) {
				_windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut);
			}

			// Set the zoomer animation
			InitializeZoomer(Conf.ZoomerEnabled);

			SuspendLayout();
			Bounds = capture.ScreenBounds;
			ResumeLayout();
			
			// Fix missing focus
			ToFront = true;
			TopMost = true;
		}