diff --git a/Greenshot/Forms/AboutForm.cs b/Greenshot/Forms/AboutForm.cs index de819451a..156e20e0b 100644 --- a/Greenshot/Forms/AboutForm.cs +++ b/Greenshot/Forms/AboutForm.cs @@ -40,12 +40,11 @@ namespace Greenshot { /// public partial class AboutForm : AnimatingBaseForm { private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AboutForm)); - private Bitmap gBitmap = new Bitmap(90, 90, PixelFormat.Format32bppRgb); + private Bitmap gBitmap; private ColorAnimator backgroundAnimation; private List pixels = new List(); private List colorFlow = new List(); private List pixelColors = new List(); - //private IntAnimator angleAnimator; private Random rand = new Random(); private readonly Color backColor = Color.FromArgb(61, 61, 61); private readonly Color pixelColor = Color.FromArgb(138, 255, 0); @@ -121,17 +120,21 @@ namespace Greenshot { /// Constructor /// public AboutForm() { + // 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(); - DoubleBuffered = !OptimizeForTerminalServer; + + // 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 this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); - // Use the self drawn image + // 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, this.BackColor, 96, 96); this.pictureBox1.Image = gBitmap; Version v = Assembly.GetExecutingAssembly().GetName().Version; @@ -140,13 +143,13 @@ namespace Greenshot { //Random rand = new Random(); - // Number of frames the "fade-in" takes - int frames = CalculateFrames(2000); + // Number of frames the pixel animation takes + int frames = FramesForMillis(2000); // The number of frames the color-cycle waits before it starts - waitFrames = CalculateFrames(6000); + waitFrames = FramesForMillis(6000); // Every pixel is created after pixelWaitFrames frames, which is increased in the loop. - int pixelWaitFrames = 0; + int pixelWaitFrames = FramesForMillis(2000); // Create pixels for (int index = 0; index < gSpots.Count; index++) { // Read the pixels in the order of the flow @@ -158,7 +161,7 @@ namespace Greenshot { int offset = (w - 2) / 2; // If the optimize for Terminal Server is set we make the animation without much ado - if (OptimizeForTerminalServer) { + 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 { @@ -169,7 +172,7 @@ namespace Greenshot { pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames); } // Increase the wait frames - pixelWaitFrames += CalculateFrames(100); + pixelWaitFrames += FramesForMillis(100); // Add to the list of to be animated pixels pixels.Add(pixelAnimation); // Add a color to the list for this pixel. @@ -187,9 +190,7 @@ namespace Greenshot { } while (pixelColorAnimator.hasNext); // color animation for the background - backgroundAnimation = new ColorAnimator(this.BackColor, backColor, frames, EasingType.Linear, EasingMode.EaseIn); - // Angle animation - // angleAnimator = new IntAnimator(-30, 20, frames, EasingType.Sine, EasingMode.EaseIn); + backgroundAnimation = new ColorAnimator(this.BackColor, backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn); } /// @@ -213,7 +214,7 @@ namespace Greenshot { /// Called from the AnimatingForm, for every frame /// protected override void Animate() { - if (!OptimizeForTerminalServer) { + if (!isTerminalServerSession) { // Color cycle if (waitFrames != 0) { waitFrames--; @@ -233,7 +234,7 @@ namespace Greenshot { scrollCount++; } else { // Reset values, wait X time for the next one - waitFrames = CalculateFrames(3000 + rand.Next(35000)); + waitFrames = FramesForMillis(3000 + rand.Next(35000)); colorIndex = 0; scrollCount = 0; // Check if there is something else to do, if not we return so we don't occupy the CPU @@ -255,7 +256,6 @@ namespace Greenshot { graphics.Clear(backgroundAnimation.Next()); graphics.TranslateTransform(2, -2); - //graphics.RotateTransform(angleAnimator.Next()); graphics.RotateTransform(20); using (SolidBrush brush = new SolidBrush(pixelColor)) { diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index 7e8ecc2c5..9f274b726 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -150,7 +150,7 @@ namespace Greenshot.Forms { // InitializeComponent(); // Only double-buffer when we are not in a TerminalServerSession - this.DoubleBuffered = !OptimizeForTerminalServer; + this.DoubleBuffered = !isTerminalServerSession; this.Text = "Greenshot capture form"; // Make sure we never capture the captureform @@ -170,7 +170,7 @@ namespace Greenshot.Forms { // 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, CalculateFrames(700), EasingType.Quintic, EasingMode.EaseOut); + windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); } // Set the zoomer animation @@ -191,10 +191,10 @@ namespace Greenshot.Forms { 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), CalculateFrames(1000), EasingType.Quintic, EasingMode.EaseOut); + 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), CalculateFrames(1000)); + zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000)); } } @@ -267,7 +267,7 @@ namespace Greenshot.Forms { // "Fade out" Zoom InitializeZoomer(false); // "Fade in" window - windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, CalculateFrames(700), EasingType.Quintic, EasingMode.EaseOut); + windowAnimator = new RectangleAnimator(new Rectangle(cursorPos, Size.Empty), captureRect, FramesForMillis(700), EasingType.Quintic, EasingMode.EaseOut); captureRect = Rectangle.Empty; Invalidate(); break; @@ -275,7 +275,7 @@ namespace Greenshot.Forms { // Set the region capture mode captureMode = CaptureMode.Region; // "Fade out" window - windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), CalculateFrames(700)); + windowAnimator.ChangeDestination(new Rectangle(cursorPos, Size.Empty), FramesForMillis(700)); // Fade in zoom InitializeZoomer(conf.ZoomerEnabled); captureRect = Rectangle.Empty; @@ -469,7 +469,7 @@ namespace Greenshot.Forms { invalidateRectangle = new Rectangle(x1,y1, x2-x1, y2-y1); Invalidate(invalidateRectangle); } else if (captureMode != CaptureMode.Window) { - if (!OptimizeForTerminalServer) { + if (!isTerminalServerSession) { Rectangle allScreenBounds = WindowCapture.GetScreenBounds(); allScreenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location); if (verticalMove) { @@ -492,7 +492,7 @@ namespace Greenshot.Forms { } else { if (selectedCaptureWindow != null && !selectedCaptureWindow.Equals(lastWindow)) { // Window changes, make new animation from current to target - windowAnimator.ChangeDestination(captureRect, CalculateFrames(700)); + windowAnimator.ChangeDestination(captureRect, FramesForMillis(700)); } } // always animate the Window area through to the last frame, so we see the fade-in/out untill the end @@ -784,7 +784,7 @@ namespace Greenshot.Forms { } } } else { - if (!OptimizeForTerminalServer) { + if (!isTerminalServerSession) { using (Pen pen = new Pen(Color.LightSeaGreen)) { pen.DashStyle = DashStyle.Dot; Rectangle screenBounds = capture.ScreenBounds; diff --git a/GreenshotPlugin/Controls/AnimatingForm.cs b/GreenshotPlugin/Controls/AnimatingForm.cs index bea214b15..de58db686 100644 --- a/GreenshotPlugin/Controls/AnimatingForm.cs +++ b/GreenshotPlugin/Controls/AnimatingForm.cs @@ -62,9 +62,9 @@ namespace GreenshotPlugin.Controls { } /// - /// Check if we need to optimize for RDP / Terminal Server sessions + /// Check if we are in a Terminal Server session OR need to optimize for RDP / remote desktop connections /// - protected bool OptimizeForTerminalServer { + protected bool isTerminalServerSession { get { return coreConfiguration.OptimizeForRDP || SystemInformation.TerminalServerSession; } @@ -75,9 +75,9 @@ namespace GreenshotPlugin.Controls { /// /// /// Number of frames, 1 if in Terminal Server Session - protected int CalculateFrames(int milliseconds) { + protected int FramesForMillis(int milliseconds) { // If we are in a Terminal Server Session we return 1 - if (OptimizeForTerminalServer) { + if (isTerminalServerSession) { return 1; } return milliseconds / VRefresh;