/// <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.Debug("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
            WindowDetails.ToForeground(Handle);
            TopMost = true;
        }
예제 #2
0
        /// <summary>
        ///     This creates the capture form
        /// </summary>
        /// <param name="capture">ICapture</param>
        /// <param name="windows">IList of IInteropWindow</param>
        public CaptureForm(ICapture capture, IList <IInteropWindow> windows)
        {
            if (_currentForm != null)
            {
                Log.Warn().WriteLine("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;
            UsedCaptureMode = capture.CaptureDetails.CaptureMode;

            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            Text = "Greenshot capture form";

            // 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 (UsedCaptureMode == CaptureMode.Window)
            {
                _windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), _captureRect, FramesForMillis(700), EasingTypes.Quintic, EasingModes.EaseOut);
            }

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

            SuspendLayout();
            Bounds = capture.ScreenBounds;
            ResumeLayout();

            // Fix missing focus
            ToFront = true;
            TopMost = true;
        }
예제 #3
0
        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);
        }
예제 #4
0
 private void ClosedHandler(object sender, EventArgs e)
 {
     Log.Debug().WriteLine("Remove CaptureForm from currentForm");
     _currentForm = null;
 }
예제 #5
0
        /// <summary>
        /// This creates the capture form
        /// </summary>
        /// <param name="capture"></param>
        /// <param name="windows"></param>
        public CaptureForm(ICapture capture, List <WindowDetails> windows) : base()
        {
            if (currentForm != null)
            {
                LOG.Debug("Found currentForm, Closing already opened CaptureForm");
                currentForm.Close();
                currentForm = null;
                Application.DoEvents();
            }
            currentForm = this;

            // Enable the AnimatingForm
            EnableAnimation = true;

            // Using 32bppPArgb speeds up the drawing.
            //capturedImage = ImageHelper.Clone(capture.Image, PixelFormat.Format32bppPArgb);
            // comment the clone, uncomment the assignment and the original bitmap is used.
            capturedImage = capture.Image;

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

            this.capture     = capture;
            this.windows     = windows;
            this.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
            this.DoubleBuffered = !isTerminalServerSession;
            this.Text           = "Greenshot capture form";

            // Make sure we never capture the captureform
            WindowDetails.RegisterIgnoreHandle(this.Handle);
            // Unregister at close
            this.FormClosing += delegate {
                // remove the buffer if it was created inside this form
                if (capturedImage != capture.Image)
                {
                    capturedImage.Dispose();
                }
                LOG.Debug("Closing captureform");
                WindowDetails.UnregisterIgnoreHandle(this.Handle);
            };

            // 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);

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

            // Fix missing focus
            WindowDetails.ToForeground(this.Handle);
            this.TopMost = true;
        }
 private void ClosedHandler(object sender, EventArgs e)
 {
     _currentForm = null;
     LOG.Debug("Remove CaptureForm from currentForm");
 }