/// <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; }
/// <summary> /// Create an animation for the zoomer, depending on if it's active or not. /// </summary> private void InitializeZoomer(bool isOn) { if (isOn) { // Initialize the zoom with a invalid position _zoomAnimator = new RectangleAnimator(NativeRect.Empty, new NativeRect(int.MaxValue, int.MaxValue, NativeSize.Empty), FramesForMillis(1000), EasingTypes.Quintic, EasingModes.EaseOut); VerifyZoomAnimation(_cursorPos, false); } else { _zoomAnimator?.ChangeDestination(new NativeRect(NativePoint.Empty, NativeSize.Empty), FramesForMillis(1000)); } }
/// <summary> /// Create an animation for the zoomer, depending on if it's active or not. /// </summary> void InitializeZoomer(bool isOn) { if (isOn) { // Initialize the zoom with a invalid position zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut); VerifyZoomAnimation(cursorPos, false); } else if (zoomAnimator != null) { zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000)); } }
/// <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; }
/// <summary> /// Create an animation for the zoomer, depending on if it's active or not. /// </summary> private void InitializeZoomer(bool isOn) { if (isOn) { var screenBounds = DisplayInfo.GetBounds(MousePosition); var zoomerSize = CalculateZoomSize(screenBounds); var initialPosition = new NativePoint(20, 20); // Initialize the zoom with an initial position _zoomAnimator = new RectangleAnimator(new NativeRect(initialPosition, NativeSize.Empty), new NativeRect(initialPosition, zoomerSize), FramesForMillis(1000), EasingTypes.Quintic, EasingModes.EaseOut); VerifyZoomAnimation(_cursorPos, false); } else { _zoomAnimator?.ChangeDestination(new NativeRect(NativePoint.Empty, NativeSize.Empty), FramesForMillis(1000)); } }
/// <summary> /// This creates the capture form /// </summary> /// <param name="coreConfiguration">ICoreConfiguration</param> /// <param name="capture">ICapture</param> /// <param name="windows">IList of IInteropWindow</param> public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList <IInteropWindow> windows) : base(coreConfiguration, null) { _coreConfiguration = coreConfiguration; _isZoomerTransparent = _coreConfiguration.ZoomerOpacity < 1; ManualLanguageApply = true; ManualStoreFields = true; // Enable the AnimatingForm EnableAnimation = true; _capture = capture; _windows = windows; UsedCaptureMode = capture.CaptureDetails.CaptureMode; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); Text = "Greenshot capture form"; // Log at close if (Log.IsDebugEnabled()) { FormClosing += (s, e) => Log.Debug().WriteLine("Closing captureform"); } // set cursor location _cursorPos = _mouseMovePos = 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(_coreConfiguration.ZoomerEnabled); Bounds = capture.ScreenBounds; // Fix missing focus ToFront = true; TopMost = true; }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CaptureFormKeyDown(object sender, KeyEventArgs e) { var step = _isCtrlPressed ? 10 : 1; switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - step); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + step); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - step, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + step, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (_fixMode == FixMode.None) { _fixMode = FixMode.Initiated; } break; case Keys.ControlKey: _isCtrlPressed = true; break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor _capture.CursorVisible = !_capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (UsedCaptureMode == CaptureMode.Region) { // Toggle zoom Conf.ZoomerEnabled = !Conf.ZoomerEnabled; InitializeZoomer(Conf.ZoomerEnabled); Invalidate(); } break; case Keys.D: if (UsedCaptureMode == CaptureMode.Window) { // Toggle debug _showDebugInfo = !_showDebugInfo; Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (UsedCaptureMode) { case CaptureMode.Region: // Set the window capture mode UsedCaptureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window _windowAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), _captureRect, FramesForMillis(700), EasingTypes.Quintic, EasingModes.EaseOut); _captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode UsedCaptureMode = CaptureMode.Region; // "Fade out" window _windowAnimator.ChangeDestination(new NativeRect(_cursorPos, NativeSize.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(Conf.ZoomerEnabled); _captureRect = Rectangle.Empty; Invalidate(); break; } SelectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (UsedCaptureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } else if (!_mouseDown) { StartSelecting(); } else { FinishSelecting(); } break; case Keys.F: ToFront = !ToFront; TopMost = !TopMost; break; } }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CaptureFormKeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 1); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 1); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - 1, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (fixMode == FixMode.None) { fixMode = FixMode.Initiated; return; } break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor capture.CursorVisible = !capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (captureMode == CaptureMode.Region) { // Toggle zoom conf.ZoomerEnabled = !conf.ZoomerEnabled; InitializeZoomer(conf.ZoomerEnabled); Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (captureMode) { case CaptureMode.Region: // Set the window capture mode captureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode captureMode = CaptureMode.Region; // "Fade out" window windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(conf.ZoomerEnabled); captureRect = Rectangle.Empty; Invalidate(); break; } selectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } break; } }
/// <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; }
/// <summary> /// Constructor /// </summary> public AboutForm() { // Make sure our resources are removed again. Disposed += Cleanup; FormClosing += Cleanup; // Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded. EnableAnimation = true; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // Only use double-buffering when we are NOT in a Terminal Server session DoubleBuffered = !isTerminalServerSession; // Use the self drawn image, first we create the background to be the backcolor (as we animate from this) gBitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96); pictureBox1.Image = gBitmap; Version v = Assembly.GetExecutingAssembly().GetName().Version; // Format is like this: AssemblyVersion("Major.Minor.Build.Revision")] lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OSInfo.Bits + " bit)"); //Random rand = new Random(); // Number of frames the pixel animation takes int frames = FramesForMillis(2000); // The number of frames the color-cycle waits before it starts waitFrames = FramesForMillis(6000); // Every pixel is created after pixelWaitFrames frames, which is increased in the loop. int pixelWaitFrames = FramesForMillis(2000); // Create pixels for (int index = 0; index < gSpots.Count; index++) { // Read the pixels in the order of the flow Point gSpot = gSpots[flowOrder[index]]; // Create the animation, first we do nothing (on the final destination) RectangleAnimator pixelAnimation; // Make the pixel grom from the middle, if this offset isn't used it looks like it's shifted int offset = (w - 2) / 2; // If the optimize for Terminal Server is set we make the animation without much ado if (isTerminalServerSession) { // No animation pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), 1, EasingType.Cubic, EasingMode.EaseIn); } else { // Create the animation, first we do nothing (on the final destination) Rectangle standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0); pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingType.Quintic, EasingMode.EaseIn); // And than we size to the wanted size. pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames); } // Increase the wait frames pixelWaitFrames += FramesForMillis(100); // Add to the list of to be animated pixels pixels.Add(pixelAnimation); // Add a color to the list for this pixel. pixelColors.Add(pixelColor); } // Make sure the frame "loop" knows we have to animate hasAnimationsLeft = true; // Pixel Color cycle colors, here we use a pre-animated loop which stores the values. ColorAnimator pixelColorAnimator = new ColorAnimator(pixelColor, Color.FromArgb(255, 255, 255), 6, EasingType.Quadratic, EasingMode.EaseIn); pixelColorAnimator.QueueDestinationLeg(pixelColor, 6, EasingType.Quadratic, EasingMode.EaseOut); do { colorFlow.Add(pixelColorAnimator.Current); pixelColorAnimator.Next(); } while (pixelColorAnimator.hasNext); // color animation for the background backgroundAnimation = new ColorAnimator(BackColor, backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn); }
/// <summary> /// Handle the key down event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CaptureFormKeyDown(object sender, KeyEventArgs e) { int step = _isCtrlPressed ? 10 : 1; switch (e.KeyCode) { case Keys.Up: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - step); break; case Keys.Down: Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + step); break; case Keys.Left: Cursor.Position = new Point(Cursor.Position.X - step, Cursor.Position.Y); break; case Keys.Right: Cursor.Position = new Point(Cursor.Position.X + step, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode if (_fixMode == FixMode.None) { _fixMode = FixMode.Initiated; } break; case Keys.ControlKey: _isCtrlPressed = true; break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; break; case Keys.M: // Toggle mouse cursor _capture.CursorVisible = !_capture.CursorVisible; Invalidate(); break; //// TODO: Enable when the screen capture code works reliable //case Keys.V: // // Video // if (capture.CaptureDetails.CaptureMode != CaptureMode.Video) { // capture.CaptureDetails.CaptureMode = CaptureMode.Video; // } else { // capture.CaptureDetails.CaptureMode = captureMode; // } // Invalidate(); // break; case Keys.Z: if (_captureMode == CaptureMode.Region) { // Toggle zoom Conf.ZoomerEnabled = !Conf.ZoomerEnabled; InitializeZoomer(Conf.ZoomerEnabled); Invalidate(); } break; case Keys.Space: // Toggle capture mode switch (_captureMode) { case CaptureMode.Region: // Set the window capture mode _captureMode = CaptureMode.Window; // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window _windowAnimator = new RectangleAnimator(new Rectangle(_cursorPos, Size.Empty), _captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); _captureRect = Rectangle.Empty; Invalidate(); break; case CaptureMode.Window: // Set the region capture mode _captureMode = CaptureMode.Region; // "Fade out" window _windowAnimator.ChangeDestination(new Rectangle(_cursorPos, Size.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(Conf.ZoomerEnabled); _captureRect = Rectangle.Empty; Invalidate(); break; } _selectedCaptureWindow = null; OnMouseMove(this, new MouseEventArgs(MouseButtons.None, 0, Cursor.Position.X, Cursor.Position.Y, 0)); break; case Keys.Return: // Confirm if (_captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; } else if (!_mouseDown) { HandleMouseDown(); } else if (_mouseDown) { HandleMouseUp(); } break; } }
/// <summary> /// Create an animation for the zoomer, depending on if it's active or not. /// </summary> void InitializeZoomer(bool isOn) { if (isOn) { // Initialize the zoom with a invalid position _zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut); VerifyZoomAnimation(_cursorPos, false); } else if (_zoomAnimator != null) { _zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000)); } }
/// <summary> /// Constructor /// </summary> public AboutForm() { // Make sure our resources are removed again. Disposed += Cleanup; FormClosing += Cleanup; // Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded. EnableAnimation = true; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // Only use double-buffering when we are NOT in a Terminal Server session DoubleBuffered = !isTerminalServerSession; // Not needed for a Tool Window, but still for the task manager it's important Icon = GreenshotResources.getGreenshotIcon(); // Use the self drawn image, first we create the background to be the backcolor (as we animate from this) gBitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96); pictureBox1.Image = gBitmap; Version v = Assembly.GetExecutingAssembly().GetName().Version; // Format is like this: AssemblyVersion("Major.Minor.Build.Revision")] lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OSInfo.Bits + " bit)"); //Random rand = new Random(); // Number of frames the pixel animation takes int frames = FramesForMillis(2000); // The number of frames the color-cycle waits before it starts waitFrames = FramesForMillis(6000); // Every pixel is created after pixelWaitFrames frames, which is increased in the loop. int pixelWaitFrames = FramesForMillis(2000); // Create pixels for (int index = 0; index < gSpots.Count; index++) { // Read the pixels in the order of the flow Point gSpot = gSpots[flowOrder[index]]; // Create the animation, first we do nothing (on the final destination) RectangleAnimator pixelAnimation; // Make the pixel grom from the middle, if this offset isn't used it looks like it's shifted int offset = (w - 2) / 2; // If the optimize for Terminal Server is set we make the animation without much ado if (isTerminalServerSession) { // No animation pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), 1, EasingType.Cubic, EasingMode.EaseIn); } else { // Create the animation, first we do nothing (on the final destination) Rectangle standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0); pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingType.Quintic, EasingMode.EaseIn); // And than we size to the wanted size. pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames); } // Increase the wait frames pixelWaitFrames += FramesForMillis(100); // Add to the list of to be animated pixels pixels.Add(pixelAnimation); // Add a color to the list for this pixel. pixelColors.Add(pixelColor); } // Make sure the frame "loop" knows we have to animate hasAnimationsLeft = true; // Pixel Color cycle colors, here we use a pre-animated loop which stores the values. ColorAnimator pixelColorAnimator = new ColorAnimator(pixelColor, Color.FromArgb(255, 255, 255), 6, EasingType.Quadratic, EasingMode.EaseIn); pixelColorAnimator.QueueDestinationLeg(pixelColor, 6, EasingType.Quadratic, EasingMode.EaseOut); do { colorFlow.Add(pixelColorAnimator.Current); pixelColorAnimator.Next(); } while (pixelColorAnimator.hasNext); // color animation for the background backgroundAnimation = new ColorAnimator(BackColor, backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn); }
/// <summary> /// Constructor /// </summary> public AboutForm( ICoreConfiguration coreConfiguration, IGreenshotLanguage greenshotlanguage, IVersionProvider versionProvider ) : base(coreConfiguration, greenshotlanguage) { _greenshotlanguage = greenshotlanguage; // Make sure our resources are removed again. Disposed += Cleanup; FormClosing += Cleanup; // Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded. EnableAnimation = true; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // Use the self drawn image, first we create the background to be the backcolor (as we animate from this) _bitmap = BitmapFactory.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor); pictureBox1.Image = _bitmap; _dpiSubscription = FormDpiHandler.OnDpiChanged.Subscribe(info => { pictureBox1.Size = FormDpiHandler.ScaleWithCurrentDpi(new NativeSize(90, 90)); }); var versionInfo = $@"Greenshot {versionProvider.CurrentVersion} {(coreConfiguration.IsPortable ? " Portable" : "")} ({OsInfo.Bits} bit)"; if (versionProvider.IsUpdateAvailable) { versionInfo += $" latest is: {versionProvider.LatestVersion}"; } lblTitle.Text = versionInfo; // Number of frames the pixel animation takes var frames = FramesForMillis(2000); // The number of frames the color-cycle waits before it starts _waitFrames = FramesForMillis(6000); // Every pixel is created after pixelWaitFrames frames, which is increased in the loop. var pixelWaitFrames = FramesForMillis(2000); // Create pixels for (var index = 0; index < _gSpots.Count; index++) { // Read the pixels in the order of the flow var gSpot = _gSpots[_flowOrder[index]]; // Create the animation, first we do nothing (on the final destination) RectangleAnimator pixelAnimation; // Make the pixel grom from the middle, if this offset isn't used it looks like it's shifted var offset = (w - 2) / 2; // If the optimize for Terminal Server is set we make the animation without much ado if (IsTerminalServerSession) { // No animation pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), 1, EasingTypes.Cubic); } else { // Create the animation, first we do nothing (on the final destination) var standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0); pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingTypes.Quintic); // And than we size to the wanted size. pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames); } // Increase the wait frames pixelWaitFrames += FramesForMillis(100); // Add to the list of to be animated pixels _pixels.Add(pixelAnimation); // Add a color to the list for this pixel. _pixelColors.Add(_pixelColor); } // Make sure the frame "loop" knows we have to animate _hasAnimationsLeft = true; // Pixel Color cycle colors, here we use a pre-animated loop which stores the values. var pixelColorAnimator = new ColorAnimator(_pixelColor, Color.FromArgb(255, 255, 255), 6, EasingTypes.Quadratic); pixelColorAnimator.QueueDestinationLeg(_pixelColor, 6, EasingTypes.Quadratic, EasingModes.EaseOut); do { _colorFlow.Add(pixelColorAnimator.Current); pixelColorAnimator.Next(); } while (pixelColorAnimator.HasNext); // color animation for the background _backgroundAnimation = new ColorAnimator(BackColor, _backColor, FramesForMillis(5000)); }
/// <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; }