Windows GUI: Some improvements in detecting the program "patch" version.
This commit is contained in:
parent
968a5f7032
commit
270430b9d8
@ -81,13 +81,13 @@ namespace com.muldersoft.slunkcrypt.gui.process
|
|||||||
executableFile = new FileStream(Path.Combine(appBaseDirectory, String.Format(FILENAME_FORMAT, suffix)), FileMode.Open, FileAccess.Read, FileShare.Read);
|
executableFile = new FileStream(Path.Combine(appBaseDirectory, String.Format(FILENAME_FORMAT, suffix)), FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Version appVersion = VersionInfo.Version;
|
|
||||||
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(executableFile.Name);
|
FileVersionInfo fileVersion = FileVersionInfo.GetVersionInfo(executableFile.Name);
|
||||||
|
Version appVersion = VersionInfo.Version;
|
||||||
if (string.Equals(fileVersion.FileDescription, "SlunkCrypt", StringComparison.OrdinalIgnoreCase) &&
|
if (string.Equals(fileVersion.FileDescription, "SlunkCrypt", StringComparison.OrdinalIgnoreCase) &&
|
||||||
string.Equals(fileVersion.CompanyName, "Muldersoft", StringComparison.OrdinalIgnoreCase) &&
|
string.Equals(fileVersion.CompanyName, "Muldersoft", StringComparison.OrdinalIgnoreCase) &&
|
||||||
(fileVersion.FileMajorPart == appVersion.Major) && (fileVersion.FileMinorPart == appVersion.Minor))
|
(fileVersion.FileMajorPart == appVersion.Major) && (fileVersion.FileMinorPart == appVersion.Minor))
|
||||||
{
|
{
|
||||||
success = true;
|
success = (fileVersion.FilePrivatePart >= appVersion.Revision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -7,6 +7,8 @@ using System.Reflection;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
using static com.muldersoft.slunkcrypt.gui.Properties._Version;
|
||||||
|
|
||||||
[assembly: AssemblyTitle("SlunkCrypt GUI")]
|
[assembly: AssemblyTitle("SlunkCrypt GUI")]
|
||||||
[assembly: AssemblyDescription("SlunkCrypt GUI")]
|
[assembly: AssemblyDescription("SlunkCrypt GUI")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
@ -19,5 +21,6 @@ using System.Windows;
|
|||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(false)]
|
||||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
||||||
|
|
||||||
[assembly: AssemblyVersion("1.2.*")]
|
[assembly: AssemblyVersion(VERS_MAJOR + "." + VERS_MINOR + ".*")]
|
||||||
[assembly: AssemblyFileVersion("1.2.0.0")]
|
[assembly: AssemblyFileVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)]
|
||||||
|
[assembly: AssemblyInformationalVersion(VERS_MAJOR + "." + VERS_MINOR + ".0." + VERS_PATCH)]
|
||||||
|
14
gui/Properties/_Version.cs
Normal file
14
gui/Properties/_Version.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/******************************************************************************/
|
||||||
|
/* SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de> */
|
||||||
|
/* This work has been released under the CC0 1.0 Universal license! */
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
namespace com.muldersoft.slunkcrypt.gui.Properties
|
||||||
|
{
|
||||||
|
internal static class _Version
|
||||||
|
{
|
||||||
|
public const string VERS_MAJOR = "1";
|
||||||
|
public const string VERS_MINOR = "2";
|
||||||
|
public const string VERS_PATCH = "1";
|
||||||
|
}
|
||||||
|
}
|
@ -81,6 +81,7 @@
|
|||||||
<Compile Include="Controls\PasswordToggleBox.xaml.cs">
|
<Compile Include="Controls\PasswordToggleBox.xaml.cs">
|
||||||
<DependentUpon>PasswordToggleBox.xaml</DependentUpon>
|
<DependentUpon>PasswordToggleBox.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Properties\_Version.cs" />
|
||||||
<Compile Include="Utilities\EnumHelper.cs" />
|
<Compile Include="Utilities\EnumHelper.cs" />
|
||||||
<Compile Include="Process\ExecutableHelper.cs" />
|
<Compile Include="Process\ExecutableHelper.cs" />
|
||||||
<Compile Include="Utilities\ApplicationConfig.cs" />
|
<Compile Include="Utilities\ApplicationConfig.cs" />
|
||||||
|
@ -852,7 +852,7 @@ namespace com.muldersoft.slunkcrypt.gui
|
|||||||
CPUFeatures cpuFeatures = CPUFeatures.Features;
|
CPUFeatures cpuFeatures = CPUFeatures.Features;
|
||||||
return new StringBuilder()
|
return new StringBuilder()
|
||||||
.AppendLine("SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de>")
|
.AppendLine("SlunkCrypt, by LoRd_MuldeR <MuldeR2@GMX.de>")
|
||||||
.AppendLine(VersionInfo.VersionStr)
|
.AppendLine(VersionInfo.ToString())
|
||||||
.AppendLine("This work has been released under the \u201CCC0 1.0\u201D license!")
|
.AppendLine("This work has been released under the \u201CCC0 1.0\u201D license!")
|
||||||
.AppendLine()
|
.AppendLine()
|
||||||
.AppendLine("Official web-site: http://slunkcrypt.osdn.io/")
|
.AppendLine("Official web-site: http://slunkcrypt.osdn.io/")
|
||||||
|
@ -10,49 +10,60 @@ namespace com.muldersoft.slunkcrypt.gui.utils
|
|||||||
{
|
{
|
||||||
static class VersionInfo
|
static class VersionInfo
|
||||||
{
|
{
|
||||||
private static readonly Lazy<Version> m_version = new Lazy<Version>(GetAssemblyVersion);
|
private static readonly Lazy<Version> m_version = new Lazy<Version> (InitializeVersion);
|
||||||
private static readonly Lazy<string> m_versionStr = new Lazy<string>(InitVersionString);
|
private static readonly Lazy<DateTime> m_buildDateTime = new Lazy<DateTime>(InitializeBuildDateTime);
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Properties
|
// Properties
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
public static Version Version
|
public static Version Version { get { return m_version.Value; } }
|
||||||
{
|
|
||||||
get { return m_version.Value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string VersionStr
|
public static DateTime BuildDate { get { return m_buildDateTime.Value; } }
|
||||||
|
|
||||||
|
public static new string ToString()
|
||||||
{
|
{
|
||||||
get { return m_versionStr.Value; }
|
Version version = m_version.Value;
|
||||||
|
return string.Format(
|
||||||
|
(version.Revision > 0) ? "Version {0:D}.{1:D}.{2:D}, built on {3}" : "Version {0:D}.{1:D}, built on {3}",
|
||||||
|
version.Major, version.Minor, version.Revision, BuildDate.ToString("yyyy-MM-dd"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
// Internal methods
|
// Internal methods
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
private static Version GetAssemblyVersion()
|
private static Version InitializeVersion()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return Assembly.GetExecutingAssembly().GetName().Version;
|
AssemblyFileVersionAttribute fileVersionAttribute = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyFileVersionAttribute), false) as AssemblyFileVersionAttribute;
|
||||||
|
Version fileVersion;
|
||||||
|
if (Version.TryParse(fileVersionAttribute?.Version, out fileVersion))
|
||||||
|
{
|
||||||
|
return fileVersion;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return new Version();
|
return new Version(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string InitVersionString()
|
private static DateTime InitializeBuildDateTime()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DateTime buildDate = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * Version.Build + TimeSpan.TicksPerSecond * 2 * Version.Revision));
|
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
return String.Format("Version {0:D}.{1:D}, built on {2}", Version.Major, Version.Minor, buildDate.ToString("yyyy-MM-dd"));
|
return new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return "Unknown version";
|
return new DateTime(1928, 6, 14, 0, 0, 0, DateTimeKind.Utc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user