mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Fix for the G animation not being drawn correctly when using different DPI settings, it doesn't get prettier though [skip ci]
This commit is contained in:
parent
e089fff547
commit
3263ce0aa9
2 changed files with 67 additions and 66 deletions
5
Greenshot/Forms/AboutForm.Designer.cs
generated
5
Greenshot/Forms/AboutForm.Designer.cs
generated
|
@ -19,10 +19,10 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.Reflection;
|
using System.Windows.Forms;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
|
|
||||||
namespace Greenshot {
|
namespace Greenshot.Forms {
|
||||||
partial class AboutForm {
|
partial class AboutForm {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Designer variable used to keep track of non-visual components.
|
/// Designer variable used to keep track of non-visual components.
|
||||||
|
@ -183,6 +183,7 @@ namespace Greenshot {
|
||||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||||
this.pictureBox1.TabIndex = 14;
|
this.pictureBox1.TabIndex = 14;
|
||||||
this.pictureBox1.TabStop = false;
|
this.pictureBox1.TabStop = false;
|
||||||
|
this.pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
//
|
//
|
||||||
// lblTranslation
|
// lblTranslation
|
||||||
//
|
//
|
||||||
|
|
|
@ -20,32 +20,31 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.IO;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using Greenshot.Helpers;
|
using System.IO;
|
||||||
using Greenshot.Configuration;
|
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Greenshot.Configuration;
|
||||||
|
using Greenshot.Helpers;
|
||||||
|
using GreenshotPlugin.Core;
|
||||||
using GreenshotPlugin.IniFile;
|
using GreenshotPlugin.IniFile;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
|
||||||
namespace Greenshot {
|
namespace Greenshot.Forms {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The about form
|
/// The about form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed partial class AboutForm : AnimatingBaseForm {
|
public sealed partial class AboutForm : AnimatingBaseForm {
|
||||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(AboutForm));
|
private static readonly ILog Log = LogManager.GetLogger(typeof(AboutForm));
|
||||||
private Bitmap _bitmap;
|
private Bitmap _bitmap;
|
||||||
private readonly ColorAnimator _backgroundAnimation;
|
private readonly ColorAnimator _backgroundAnimation;
|
||||||
private readonly IList<RectangleAnimator> _pixels = new List<RectangleAnimator>();
|
private readonly List<RectangleAnimator> _pixels = new List<RectangleAnimator>();
|
||||||
private readonly IList<Color> _colorFlow = new List<Color>();
|
private readonly List<Color> _colorFlow = new List<Color>();
|
||||||
private readonly IList<Color> _pixelColors = new List<Color>();
|
private readonly List<Color> _pixelColors = new List<Color>();
|
||||||
private readonly Random _rand = new Random();
|
private readonly Random _rand = new Random();
|
||||||
private readonly Color _backColor = Color.FromArgb(61, 61, 61);
|
private readonly Color _backColor = Color.FromArgb(61, 61, 61);
|
||||||
private readonly Color _pixelColor = Color.FromArgb(138, 255, 0);
|
private readonly Color _pixelColor = Color.FromArgb(138, 255, 0);
|
||||||
|
@ -57,54 +56,55 @@ namespace Greenshot {
|
||||||
private bool _hasAnimationsLeft;
|
private bool _hasAnimationsLeft;
|
||||||
|
|
||||||
// Variables are used to define the location of the dots
|
// Variables are used to define the location of the dots
|
||||||
private const int w = 13;
|
private const int W = 13;
|
||||||
private const int p1 = 7;
|
private const int P1 = 7;
|
||||||
private const int p2 = p1 + w;
|
private const int P2 = P1 + W;
|
||||||
private const int p3 = p2 + w;
|
private const int P3 = P2 + W;
|
||||||
private const int p4 = p3 + w;
|
private const int P4 = P3 + W;
|
||||||
private const int p5 = p4 + w;
|
private const int P5 = P4 + W;
|
||||||
private const int p6 = p5 + w;
|
private const int P6 = P5 + W;
|
||||||
private const int p7 = p6 + w;
|
private const int P7 = P6 + W;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The location of every dot in the "G"
|
/// The location of every dot in the "G"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly List<Point> gSpots = new List<Point>() {
|
private readonly List<Point> _gSpots = new List<Point>
|
||||||
|
{
|
||||||
// Top row
|
// Top row
|
||||||
new Point(p2, p1), // 0
|
new Point(P2, P1), // 0
|
||||||
new Point(p3, p1), // 1
|
new Point(P3, P1), // 1
|
||||||
new Point(p4, p1), // 2
|
new Point(P4, P1), // 2
|
||||||
new Point(p5, p1), // 3
|
new Point(P5, P1), // 3
|
||||||
new Point(p6, p1), // 4
|
new Point(P6, P1), // 4
|
||||||
|
|
||||||
// Second row
|
// Second row
|
||||||
new Point(p1, p2), // 5
|
new Point(P1, P2), // 5
|
||||||
new Point(p2, p2), // 6
|
new Point(P2, P2), // 6
|
||||||
|
|
||||||
// Third row
|
// Third row
|
||||||
new Point(p1, p3), // 7
|
new Point(P1, P3), // 7
|
||||||
new Point(p2, p3), // 8
|
new Point(P2, P3), // 8
|
||||||
|
|
||||||
// Fourth row
|
// Fourth row
|
||||||
new Point(p1, p4), // 9
|
new Point(P1, P4), // 9
|
||||||
new Point(p2, p4), // 10
|
new Point(P2, P4), // 10
|
||||||
new Point(p5, p4), // 11
|
new Point(P5, P4), // 11
|
||||||
new Point(p6, p4), // 12
|
new Point(P6, P4), // 12
|
||||||
new Point(p7, p4), // 13
|
new Point(P7, P4), // 13
|
||||||
|
|
||||||
// Fifth row
|
// Fifth row
|
||||||
new Point(p1, p5), // 14
|
new Point(P1, P5), // 14
|
||||||
new Point(p2, p5), // 15
|
new Point(P2, P5), // 15
|
||||||
new Point(p6, p5), // 16
|
new Point(P6, P5), // 16
|
||||||
new Point(p7, p5), // 17
|
new Point(P7, P5), // 17
|
||||||
|
|
||||||
// Sixth row
|
// Sixth row
|
||||||
new Point(p1, p6), // 18
|
new Point(P1, P6), // 18
|
||||||
new Point(p2, p6), // 19
|
new Point(P2, P6), // 19
|
||||||
new Point(p3, p6), // 20
|
new Point(P3, P6), // 20
|
||||||
new Point(p4, p6), // 21
|
new Point(P4, P6), // 21
|
||||||
new Point(p5, p6), // 22
|
new Point(P5, P6), // 22
|
||||||
new Point(p6, p6) // 23
|
new Point(P6, P6) // 23
|
||||||
};
|
};
|
||||||
|
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
|
@ -114,18 +114,17 @@ namespace Greenshot {
|
||||||
// 14 15 16 17
|
// 14 15 16 17
|
||||||
// 18 19 20 21 22 23
|
// 18 19 20 21 22 23
|
||||||
|
|
||||||
// The order in which we draw the dots & flow the collors.
|
// The order in which we draw the dots & flow the colors.
|
||||||
private readonly List<int> flowOrder = new List<int>() { 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 };
|
private readonly List<int> _flowOrder = new List<int>{ 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleanup all the allocated resources
|
/// Cleanup all the allocated resources
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void Cleanup(object sender, EventArgs e) {
|
private void Cleanup(object sender, EventArgs e) {
|
||||||
if (_bitmap != null) {
|
if (_bitmap == null) return;
|
||||||
_bitmap.Dispose();
|
_bitmap.Dispose();
|
||||||
_bitmap = null;
|
_bitmap = null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -146,10 +145,11 @@ namespace Greenshot {
|
||||||
DoubleBuffered = !IsTerminalServerSession;
|
DoubleBuffered = !IsTerminalServerSession;
|
||||||
|
|
||||||
// Use the self drawn image, first we create the background to be the back-color (as we animate from this)
|
// Use the self drawn image, first we create the background to be the back-color (as we animate from this)
|
||||||
|
|
||||||
_bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
|
_bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
|
||||||
pictureBox1.Image = _bitmap;
|
pictureBox1.Image = _bitmap;
|
||||||
|
|
||||||
lblTitle.Text = "Greenshot " + EnvironmentInfo.GetGreenshotVersion() + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)";
|
lblTitle.Text = $@"Greenshot {EnvironmentInfo.GetGreenshotVersion()} {(IniConfig.IsPortable ? " Portable" : "")} ({OsInfo.Bits}) bit)";
|
||||||
|
|
||||||
// Number of frames the pixel animation takes
|
// Number of frames the pixel animation takes
|
||||||
int frames = FramesForMillis(2000);
|
int frames = FramesForMillis(2000);
|
||||||
|
@ -159,25 +159,25 @@ namespace Greenshot {
|
||||||
// Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
|
// Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
|
||||||
int pixelWaitFrames = FramesForMillis(2000);
|
int pixelWaitFrames = FramesForMillis(2000);
|
||||||
// Create pixels
|
// Create pixels
|
||||||
for (int index = 0; index < gSpots.Count; index++) {
|
for (int index = 0; index < _gSpots.Count; index++) {
|
||||||
// Read the pixels in the order of the flow
|
// Read the pixels in the order of the flow
|
||||||
Point gSpot = gSpots[flowOrder[index]];
|
Point gSpot = _gSpots[_flowOrder[index]];
|
||||||
// Create the animation, first we do nothing (on the final destination)
|
// Create the animation, first we do nothing (on the final destination)
|
||||||
RectangleAnimator pixelAnimation;
|
RectangleAnimator pixelAnimation;
|
||||||
|
|
||||||
// Make the pixel grow from the middle, if this offset isn't used it looks like it's shifted
|
// Make the pixel grow from the middle, if this offset isn't used it looks like it's shifted
|
||||||
int offset = (w - 2) / 2;
|
int offset = (W - 2) / 2;
|
||||||
|
|
||||||
// If the optimize for Terminal Server is set we make the animation without much ado
|
// If the optimize for Terminal Server is set we make the animation without much ado
|
||||||
if (IsTerminalServerSession) {
|
if (IsTerminalServerSession) {
|
||||||
// No animation
|
// 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);
|
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 {
|
} else {
|
||||||
// Create the animation, first we do nothing (on the final destination)
|
// Create the animation, first we do nothing (on the final destination)
|
||||||
Rectangle standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0);
|
Rectangle standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0);
|
||||||
pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingType.Quintic, EasingMode.EaseIn);
|
pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingType.Quintic, EasingMode.EaseIn);
|
||||||
// And than we size to the wanted size.
|
// And than we size to the wanted size.
|
||||||
pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, w - 2, w - 2), frames);
|
pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, W - 2, W - 2), frames);
|
||||||
}
|
}
|
||||||
// Increase the wait frames
|
// Increase the wait frames
|
||||||
pixelWaitFrames += FramesForMillis(100);
|
pixelWaitFrames += FramesForMillis(100);
|
||||||
|
@ -307,10 +307,10 @@ namespace Greenshot {
|
||||||
// nothing to do, just using dispose to cleanup
|
// nothing to do, just using dispose to cleanup
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
MessageBox.Show("Greenshot can't find the logfile, it should have been here: " + MainForm.LogFileLocation);
|
MessageBox.Show(@"Greenshot can't find the logfile, it should have been here: " + MainForm.LogFileLocation);
|
||||||
}
|
}
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
MessageBox.Show("Couldn't open the greenshot.log, it's located here: " + MainForm.LogFileLocation, "Error opening greeenshot.log", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
MessageBox.Show(@"Couldn't open the greenshot.log, it's located here: " + MainForm.LogFileLocation, @"Error opening greenshot.log", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Keys.I:
|
case Keys.I:
|
||||||
|
@ -318,14 +318,14 @@ namespace Greenshot {
|
||||||
using (Process.Start("\"" + IniConfig.ConfigLocation + "\"")) {
|
using (Process.Start("\"" + IniConfig.ConfigLocation + "\"")) {
|
||||||
}
|
}
|
||||||
} catch (Exception) {
|
} catch (Exception) {
|
||||||
MessageBox.Show("Couldn't open the greenshot.ini, it's located here: " + IniConfig.ConfigLocation, "Error opening greeenshot.ini", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
MessageBox.Show(@"Couldn't open the greenshot.ini, it's located here: " + IniConfig.ConfigLocation, @"Error opening greenshot.ini", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return base.ProcessCmdKey(ref msg, keyData);
|
return base.ProcessCmdKey(ref msg, keyData);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
LOG.Error($"Error handling key '{keyData}'", ex);
|
Log.Error($"Error handling key '{keyData}'", ex);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue