Fixed some issues with the version being shown in the about.

This commit is contained in:
Krom, Robertus 2020-02-26 15:20:21 +01:00
commit cfdc7a7ec2
4 changed files with 34 additions and 33 deletions

View file

@ -20,6 +20,7 @@
*/ */
using System.Reflection; using System.Reflection;
using Greenshot.Helpers;
namespace Greenshot { namespace Greenshot {
partial class AboutForm { partial class AboutForm {
@ -116,7 +117,7 @@ namespace Greenshot {
this.linkLblBugs.Size = new System.Drawing.Size(465, 23); this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 8; this.linkLblBugs.TabIndex = 8;
this.linkLblBugs.TabStop = true; this.linkLblBugs.TabStop = true;
this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + Assembly.GetEntryAssembly().GetName().Version; this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
// //
// lblBugs // lblBugs
@ -134,7 +135,7 @@ namespace Greenshot {
this.linkLblDonations.Size = new System.Drawing.Size(465, 23); this.linkLblDonations.Size = new System.Drawing.Size(465, 23);
this.linkLblDonations.TabIndex = 10; this.linkLblDonations.TabIndex = 10;
this.linkLblDonations.TabStop = true; this.linkLblDonations.TabStop = true;
this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly().GetName().Version; this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
// //
// lblDonations // lblDonations
@ -170,7 +171,7 @@ namespace Greenshot {
this.linkLabel1.Size = new System.Drawing.Size(130, 23); this.linkLabel1.Size = new System.Drawing.Size(130, 23);
this.linkLabel1.TabIndex = 13; this.linkLabel1.TabIndex = 13;
this.linkLabel1.TabStop = true; this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "http://getgreenshot.org"; this.linkLabel1.Text = "http://getgreenshot.org/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight; this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked); this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
// //

View file

@ -39,7 +39,7 @@ namespace Greenshot {
/// <summary> /// <summary>
/// The about form /// The about form
/// </summary> /// </summary>
public 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;
@ -145,11 +145,11 @@ namespace Greenshot {
// Only use double-buffering when we are NOT in a Terminal Server session // Only use double-buffering when we are NOT in a Terminal Server session
DoubleBuffered = !IsTerminalServerSession; DoubleBuffered = !IsTerminalServerSession;
// Use the self drawn image, first we create the background to be the backcolor (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.GreenshotVersion + (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);

View file

@ -56,9 +56,7 @@ namespace Greenshot.Helpers
return Type.GetType("System.Reflection.ReflectionContext", false) != null; return Type.GetType("System.Reflection.ReflectionContext", false) != null;
} }
public static string GreenshotVersion public static string GetGreenshotVersion(bool shortVersion = false)
{
get
{ {
var executingAssembly = Assembly.GetExecutingAssembly(); var executingAssembly = Assembly.GetExecutingAssembly();
@ -66,28 +64,30 @@ namespace Greenshot.Helpers
string greenshotVersion = executingAssembly.GetName().Version.ToString(); string greenshotVersion = executingAssembly.GetName().Version.ToString();
// Use AssemblyFileVersion if available // Use AssemblyFileVersion if available
var v = executingAssembly.GetName().Version; var assemblyFileVersionAttribute = executingAssembly.GetCustomAttribute<AssemblyFileVersionAttribute>();
var assemblyFileVersion = executingAssembly.GetCustomAttribute<AssemblyFileVersionAttribute>(); if (!string.IsNullOrEmpty(assemblyFileVersionAttribute?.Version))
if (!string.IsNullOrEmpty(assemblyFileVersion?.Version))
{ {
greenshotVersion = assemblyFileVersion.Version; var assemblyFileVersion = new Version(assemblyFileVersionAttribute.Version);
greenshotVersion = assemblyFileVersion.ToString(3);
} }
// Use AssemblyInformationalVersion if available if (!shortVersion)
var assemblyInformationalVersion = executingAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (!string.IsNullOrEmpty(assemblyInformationalVersion?.InformationalVersion))
{ {
greenshotVersion = assemblyInformationalVersion.InformationalVersion; // Use AssemblyInformationalVersion if available
var informationalVersionAttribute = executingAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (!string.IsNullOrEmpty(informationalVersionAttribute?.InformationalVersion))
{
greenshotVersion = informationalVersionAttribute.InformationalVersion;
}
} }
return greenshotVersion.Replace("+", " - "); return greenshotVersion.Replace("+", " - ");
} }
}
public static string EnvironmentToString(bool newline) public static string EnvironmentToString(bool newline)
{ {
StringBuilder environment = new StringBuilder(); StringBuilder environment = new StringBuilder();
environment.Append("Software version: " + GreenshotVersion); environment.Append("Software version: " + GetGreenshotVersion());
if (IniConfig.IsPortable) { if (IniConfig.IsPortable) {
environment.Append(" Portable"); environment.Append(" Portable");
} }