Exemple #1
0
 public void CaptureByRect(Rect rect)
 {
     if (rect.IsEmpty == false)
     {
         var image = WindowSnap.GetBitmapInCoordinates((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height) as Bitmap;
         this.SaveImage(image);
     }
 }
Exemple #2
0
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);

            _windowSnap.Snapped           -= Snapped;
            _windowSnap.Unsnapped         -= Unsnapped;
            _windowSnap.EdgeOffsetChanged -= EdgeOffsetChanged;
            _windowSnap = null;
        }
Exemple #3
0
 private void TimedScreenShot(object sender, System.Timers.ElapsedEventArgs e)
 {
     if (_selectedWindow != IntPtr.Zero)
     {
         Dispatcher.Invoke((Action)(() => { image.Source = null; }));
         var bitmap = WindowSnap.GetWindowSnap(_selectedWindow, true).Image;
         Dispatcher.Invoke((Action)(() => { image.Source = BitmapToImageSource(bitmap); }));
     }
 }
Exemple #4
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            // Must be called on source initialized event so the
            // window handle can be obtain to hook the message
            // proc handler properly
            _windowSnap = new WindowSnap(this);

            _windowSnap.Snapped           += Snapped;
            _windowSnap.Unsnapped         += Unsnapped;
            _windowSnap.EdgeOffsetChanged += EdgeOffsetChanged;
        }
Exemple #5
0
        private void CaptureArea()
        {
            this.uiWindow.HideWin();
            this.captureAreaWindow.ShowCaptureArea((Rect rect) =>
            {
                var image = WindowSnap.GetBitmapInCoordinates((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height) as Bitmap;

                // hide the current window, on complete show it back
                this.captureAreaWindow.HideCaptureArea();
                this.uiWindow.ShowWin();

                this.SaveImage(image);
            });
        }
Exemple #6
0
        /// <summary>
        /// Captures the image.
        /// </summary>
        public void CaptureImage()
        {
            Bitmap image = null;

            // if the show advanced is not visible;  then always capture the current area
            if (this.SelectedProcessItem == null || this.ShowAdvanced == false)
            {
                // capture only the background
                this.uiWindow.HideWin();
                image = WindowSnap.GetCurrentBackgroundScreenShot() as Bitmap;
                this.IsApplicationVisible = true;
                this.uiWindow.ShowWin();
            }
            else
            {
                var snap = WindowSnap.GetWindowSnap(this.SelectedProcessItem.WindowHandle, true);
                image = snap.Image;
            }

            string fileName = this.SaveImage(image as Bitmap);
        }
        public Bitmap CaptureFrame(bool backgroundMode = true, bool cache = true)
        {
            if (this.CurrentFrame != null && cache)
            {
                this.CurrentFrame.Dispose();
            }
            Bitmap bitmap;

            if (backgroundMode)
            {
                WindowSnap windowSnap = WindowSnap.GetWindowSnap(this.Handle, true);
                bitmap = windowSnap.Image;
            }
            else
            {
                bitmap = ForegroundCapture.CaptureWindow(this.Handle);
            }
            if (cache)
            {
                this.CurrentFrame = bitmap;
            }
            return(bitmap);
        }
 public static int GetPixel(WindowSnap snap, int x, int y)
 {
     return(AutoSpy.ColorToInt(snap.Image.GetPixel(x, y)));
 }
Exemple #9
0
 public SnapWrapper(WindowSnap windowSnap_)
 {
     windowSnap = windowSnap_;
 }
Exemple #10
0
 public static int GetPixel(WindowSnap snap, int x, int y)
 {
     return AutoSpy.ColorToInt(snap.Image.GetPixel(x, y));
 }