Example #1
0
        public frmMain()
        {
            InitializeComponent();
            CheckForIllegalCrossThreadCalls = false; // For Visual Studio Debuging Only !
            serv = new HttpListener();
            serv.IgnoreWriteExceptions = true;       // Seems Had No Effect :(
            img            = new MemoryStream();
            isPrivateTask  = false;
            isPreview      = false;
            isMouseCapture = false;

            var deviceNames = ScreenFunctions.DeviceNames();

            ScreenCombo.Items.AddRange(deviceNames.ToArray());
        }
Example #2
0
        private void TakeScreenshot(bool captureMouse)
        {
            Rectangle captureBounds = ScreenFunctions.GetScreenBounds(ScreenInfo);

            if (captureMouse)
            {
                var bmp = ScreenCapturePInvoke.CaptureScreen(captureBounds, true);

                rwl.AcquireWriterLock(Timeout.Infinite);
                bmp.Save(Application.StartupPath + "/WebServer" + "/ScreenTask.jpg", ImageFormat.Jpeg);
                rwl.ReleaseWriterLock();
                if (isPreview)
                {
                    img = new MemoryStream();
                    bmp.Save(img, ImageFormat.Jpeg);
                    imgPreview.Image = new Bitmap(img);
                }
                return;
            }

            using (Bitmap bitmap = new Bitmap(captureBounds.Width, captureBounds.Height))
            {
                using (Graphics g = Graphics.FromImage(bitmap))
                {
                    g.CopyFromScreen(new Point(captureBounds.Left, captureBounds.Top), Point.Empty, captureBounds.Size);
                }
                rwl.AcquireWriterLock(Timeout.Infinite);
                bitmap.Save(Application.StartupPath + "/WebServer" + "/ScreenTask.jpg", ImageFormat.Jpeg);
                rwl.ReleaseWriterLock();

                if (isPreview)
                {
                    img = new MemoryStream();
                    bitmap.Save(img, ImageFormat.Jpeg);
                    imgPreview.Image = new Bitmap(img);
                }
            }
        }