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 Greenshot.Helpers;
namespace Greenshot {
partial class AboutForm {
@ -116,7 +117,7 @@ namespace Greenshot {
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 8;
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);
//
// lblBugs
@ -134,7 +135,7 @@ namespace Greenshot {
this.linkLblDonations.Size = new System.Drawing.Size(465, 23);
this.linkLblDonations.TabIndex = 10;
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);
//
// lblDonations
@ -170,7 +171,7 @@ namespace Greenshot {
this.linkLabel1.Size = new System.Drawing.Size(130, 23);
this.linkLabel1.TabIndex = 13;
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.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//

View file

@ -39,7 +39,7 @@ namespace Greenshot {
/// <summary>
/// The about form
/// </summary>
public partial class AboutForm : AnimatingBaseForm {
public sealed partial class AboutForm : AnimatingBaseForm {
private static readonly ILog LOG = LogManager.GetLogger(typeof(AboutForm));
private Bitmap _bitmap;
private readonly ColorAnimator _backgroundAnimation;
@ -145,11 +145,11 @@ namespace Greenshot {
// 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)
// 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);
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
int frames = FramesForMillis(2000);

View file

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

View file

@ -10,14 +10,14 @@
},
"cloudBuild": {
"setVersionVariables": true,
"setAllVariables": true,
"buildNumber": {
"enabled": true,
"includeCommitId": {
"when": "nonPublicReleaseOnly",
"where": "buildMetadata"
"setAllVariables": true,
"buildNumber": {
"enabled": true,
"includeCommitId": {
"when": "nonPublicReleaseOnly",
"where": "buildMetadata"
}
}
}
},
"inherit": false
}