Example #1
0
        public void SaveSelection(bool showCursor)
        {
            Point curPos  = new Point(Cursor.Position.X - CurrentTopLeft.X, Cursor.Position.Y - CurrentTopLeft.Y);
            Size  curSize = new Size();

            curSize.Height = Cursor.Current.Size.Height;
            curSize.Width  = Cursor.Current.Size.Width;

            ScreenPath = "";

            if (!ScreenShot.saveToClipboard)
            {
                saveFileDialog1.DefaultExt = "bmp";
                saveFileDialog1.Filter     = "bmp files (*.bmp)|*.bmp|jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|tiff files (*.tiff)|*.tiff|png files (*.png)|*.png";
                saveFileDialog1.Title      = "Save screenshot to...";
                saveFileDialog1.ShowDialog();
                ScreenPath = saveFileDialog1.FileName;
            }


            if (ScreenPath != "" || ScreenShot.saveToClipboard)
            {
                //Allow 250 milliseconds for the screen to repaint itself (we don't want to include this form in the capture)
                System.Threading.Thread.Sleep(250);

                Point     StartPoint = new Point(CurrentTopLeft.X, CurrentTopLeft.Y);
                Rectangle bounds     = new Rectangle(CurrentTopLeft.X, CurrentTopLeft.Y, CurrentBottomRight.X - CurrentTopLeft.X, CurrentBottomRight.Y - CurrentTopLeft.Y);
                string    fi         = "";

                if (ScreenPath != "")
                {
                    fi = new FileInfo(ScreenPath).Extension;
                }

                ScreenShot.CaptureImage(showCursor, curSize, curPos, StartPoint, Point.Empty, bounds, ScreenPath, fi);


                if (ScreenShot.saveToClipboard)
                {
                    MessageBox.Show("Area saved to clipboard", "TeboScreen", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Area saved to file", "TeboScreen", MessageBoxButtons.OK);
                }


                this.InstanceRef.Show();
                this.Close();
            }

            else
            {
                MessageBox.Show("File save cancelled", "TeboScreen", MessageBoxButtons.OK);
                this.InstanceRef.Show();
                this.Close();
            }
        }
Example #2
0
        public void screenCapture(bool showCursor)
        {
            Point curPos  = new Point(Cursor.Position.X, Cursor.Position.Y);
            Size  curSize = new Size();

            curSize.Height = Cursor.Current.Size.Height;
            curSize.Width  = Cursor.Current.Size.Width;

            ScreenPath = "";

            if (!ScreenShot.saveToClipboard)
            {
                saveFileDialog1.DefaultExt = "bmp";
                saveFileDialog1.Filter     = "bmp files (*.bmp)|*.bmp|jpg files (*.jpg)|*.jpg|gif files (*.gif)|*.gif|tiff files (*.tiff)|*.tiff|png files (*.png)|*.png";
                saveFileDialog1.Title      = "Save screenshot to...";
                saveFileDialog1.ShowDialog();
                ScreenPath = saveFileDialog1.FileName;
            }



            if (ScreenPath != "" || ScreenShot.saveToClipboard)
            {
                //Conceal this form while the screen capture takes place
                this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
                this.TopMost     = false;

                //Allow 250 milliseconds for the screen to repaint itself (we don't want to include this form in the capture)
                System.Threading.Thread.Sleep(250);

                Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));
                string    fi     = "";

                if (ScreenPath != "")
                {
                    fi = new FileInfo(ScreenPath).Extension;
                }

                ScreenShot.CaptureImage(showCursor, curSize, curPos, Point.Empty, Point.Empty, bounds, ScreenPath, fi);

                //The screen has been captured and saved to a file so bring this form back into the foreground
                this.WindowState = System.Windows.Forms.FormWindowState.Normal;
                this.TopMost     = true;

                if (ScreenShot.saveToClipboard)
                {
                    MessageBox.Show("Screen saved to clipboard", "TeboScreen", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Screen saved to file", "TeboScreen", MessageBoxButtons.OK);
                }
            }
        }