Some more fixes for the version information.

Small fix to a language file.
Small fix for the log4net configuration, as we changed to net472 it was ending in the wrong directory.
This commit is contained in:
Krom, Robertus 2020-02-25 15:20:37 +01:00
commit 3c7a93a8a7
4 changed files with 45 additions and 41 deletions

View file

@ -21,7 +21,6 @@
using System;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using System.IO;
using System.Drawing;
@ -149,32 +148,8 @@ namespace Greenshot {
// Use the self drawn image, first we create the background to be the backcolor (as we animate from this)
_bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
pictureBox1.Image = _bitmap;
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;
}
// Use AssemblyInformationalVersion if available
var assemblyInformationalVersion = executingAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (!string.IsNullOrEmpty(assemblyInformationalVersion?.InformationalVersion))
{
greenshotVersion = assemblyInformationalVersion.InformationalVersion;
}
greenshotVersion = greenshotVersion.Replace("+", " - ");
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")]
lblTitle.Text = "Greenshot " + greenshotVersion + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)";
//Random rand = new Random();
lblTitle.Text = "Greenshot " + EnvironmentInfo.GreenshotVersion + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)";
// Number of frames the pixel animation takes
int frames = FramesForMillis(2000);
@ -190,7 +165,7 @@ namespace Greenshot {
// 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
// Make the pixel grow 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
@ -295,7 +270,7 @@ namespace Greenshot {
using SolidBrush brush = new SolidBrush(_pixelColor);
int index = 0;
// We asume there is nothing to animate in the next Animate loop
// We assume there is nothing to animate in the next Animate loop
_hasAnimationsLeft = false;
// Pixels of the G
foreach (RectangleAnimator pixel in _pixels) {

View file

@ -78,7 +78,7 @@
</Target>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<PostBuildEvent>
copy "$(SolutionDir)Greenshot\log4net-debug.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\net471\log4net.xml"
copy "$(SolutionDir)Greenshot\log4net-debug.xml" "$(SolutionDir)Greenshot\bin\$(Configuration)\net472\log4net.xml"
</PostBuildEvent>
</PropertyGroup>
</Project>

View file

@ -23,9 +23,10 @@ using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.UnmanagedHelpers;
using Microsoft.Win32;
namespace Greenshot.Helpers
{
@ -55,10 +56,38 @@ namespace Greenshot.Helpers
return Type.GetType("System.Reflection.ReflectionContext", false) != null;
}
public static string GreenshotVersion
{
get
{
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;
}
// Use AssemblyInformationalVersion if available
var assemblyInformationalVersion = executingAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
if (!string.IsNullOrEmpty(assemblyInformationalVersion?.InformationalVersion))
{
greenshotVersion = assemblyInformationalVersion.InformationalVersion;
}
return greenshotVersion.Replace("+", " - ");
}
}
public static string EnvironmentToString(bool newline)
{
StringBuilder environment = new StringBuilder();
environment.Append("Software version: " + Application.ProductVersion);
environment.Append("Software version: " + GreenshotVersion);
if (IniConfig.IsPortable) {
environment.Append(" Portable");
}
@ -225,16 +254,11 @@ namespace Greenshot.Helpers
/// <summary>
/// Determines if the current application is 32 or 64-bit.
/// </summary>
public static int Bits
{
get
{
return IntPtr.Size * 8;
}
}
public static int Bits => IntPtr.Size * 8;
private static string _sEdition;
/// <summary>
/// <summary>
/// Gets the edition of the operating system running on this computer.
/// </summary>
public static string Edition
@ -578,7 +602,8 @@ namespace Greenshot.Helpers
}
break;
case 10:
name = "Windows 10";
string releaseId = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "").ToString();
name = $"Windows 10 {releaseId}";
break;
}
break;
@ -771,6 +796,10 @@ namespace Greenshot.Helpers
{
get
{
if (WindowsVersion.IsWindows10OrLater)
{
return $"build {Environment.OSVersion.Version.Build}";
}
if (Environment.OSVersion.Version.Revision != 0)
{
return $"{Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.Minor} build {Environment.OSVersion.Version.Build} revision {Environment.OSVersion.Version.Revision:X}";

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<language description="简体中文" ietf="" version="1.0.0" languagegroup="">
<language description="简体中文" ietf="zh-CN" version="1.0.0" languagegroup="">
<resources>
<resource name="contextmenu_configure">配置外部命令</resource>
<resource name="label_argument">参数</resource>