mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-07 07:26:05 +12:00
Use GetApplicationVersion function
This commit is contained in:
parent
0a8d613bab
commit
e91fd94d2b
|
@ -277,6 +277,17 @@ public static string GetProperName(string name, bool keepCase = false)
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetApplicationVersion(bool includeRevision = false)
|
||||||
|
{
|
||||||
|
Version version = Version.Parse(Application.ProductVersion);
|
||||||
|
string result = $"{version.Major}.{version.Minor}.{version.Build}";
|
||||||
|
if (includeRevision)
|
||||||
|
{
|
||||||
|
result = $"{result}.{version.Revision}";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If version1 newer than version2 = 1
|
/// If version1 newer than version2 = 1
|
||||||
/// If version1 equal to version2 = 0
|
/// If version1 equal to version2 = 0
|
||||||
|
@ -302,9 +313,9 @@ public static int CompareVersion(Version version1, Version version2)
|
||||||
/// If version equal to ApplicationVersion = 0
|
/// If version equal to ApplicationVersion = 0
|
||||||
/// If version older than ApplicationVersion = -1
|
/// If version older than ApplicationVersion = -1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static int CompareApplicationVersion(string version)
|
public static int CompareApplicationVersion(string version, bool includeRevision = false)
|
||||||
{
|
{
|
||||||
return CompareVersion(version, Application.ProductVersion);
|
return CompareVersion(version, GetApplicationVersion(includeRevision));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version NormalizeVersion(string version)
|
public static Version NormalizeVersion(string version)
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ShareX.HelpersLib
|
namespace ShareX.HelpersLib
|
||||||
{
|
{
|
||||||
|
@ -86,7 +85,7 @@ protected virtual void OnSettingsSaveFailed(Exception e)
|
||||||
public bool Save(string filePath)
|
public bool Save(string filePath)
|
||||||
{
|
{
|
||||||
FilePath = filePath;
|
FilePath = filePath;
|
||||||
ApplicationVersion = Application.ProductVersion;
|
ApplicationVersion = Helpers.GetApplicationVersion();
|
||||||
|
|
||||||
bool result = SaveInternal(FilePath);
|
bool result = SaveInternal(FilePath);
|
||||||
|
|
||||||
|
@ -112,7 +111,7 @@ public void SaveAsync()
|
||||||
|
|
||||||
public MemoryStream SaveToMemoryStream(bool supportDPAPIEncryption = false)
|
public MemoryStream SaveToMemoryStream(bool supportDPAPIEncryption = false)
|
||||||
{
|
{
|
||||||
ApplicationVersion = Application.ProductVersion;
|
ApplicationVersion = Helpers.GetApplicationVersion();
|
||||||
|
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
SaveToStream(ms, supportDPAPIEncryption, true);
|
SaveToStream(ms, supportDPAPIEncryption, true);
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using ShareX.HelpersLib.Properties;
|
using ShareX.HelpersLib.Properties;
|
||||||
using System;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -40,8 +39,7 @@ public static string UserAgent
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
Version version = Version.Parse(Application.ProductVersion);
|
return $"{Name}/{Helpers.GetApplicationVersion()}";
|
||||||
return $"{Name}/{version.Major}.{version.Minor}.{version.Build}";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ShareX.UploadersLib
|
namespace ShareX.UploadersLib
|
||||||
{
|
{
|
||||||
|
@ -111,7 +110,7 @@ public static CustomUploaderItem Init()
|
||||||
{
|
{
|
||||||
return new CustomUploaderItem()
|
return new CustomUploaderItem()
|
||||||
{
|
{
|
||||||
Version = Application.ProductVersion,
|
Version = Helpers.GetApplicationVersion(),
|
||||||
RequestMethod = HttpMethod.POST,
|
RequestMethod = HttpMethod.POST,
|
||||||
Body = CustomUploaderBody.MultipartFormData
|
Body = CustomUploaderBody.MultipartFormData
|
||||||
};
|
};
|
||||||
|
@ -449,7 +448,7 @@ public void CheckBackwardCompatibility()
|
||||||
DeletionURL = MigrateOldSyntax(DeletionURL);
|
DeletionURL = MigrateOldSyntax(DeletionURL);
|
||||||
ErrorMessage = MigrateOldSyntax(ErrorMessage);
|
ErrorMessage = MigrateOldSyntax(ErrorMessage);
|
||||||
|
|
||||||
Version = Application.ProductVersion;
|
Version = Helpers.GetApplicationVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -745,7 +745,7 @@ private async void btnExport_Click(object sender, EventArgs e)
|
||||||
using (SaveFileDialog sfd = new SaveFileDialog())
|
using (SaveFileDialog sfd = new SaveFileDialog())
|
||||||
{
|
{
|
||||||
sfd.DefaultExt = "sxb";
|
sfd.DefaultExt = "sxb";
|
||||||
sfd.FileName = $"ShareX-{Application.ProductVersion}-backup.sxb";
|
sfd.FileName = $"ShareX-{Helpers.GetApplicationVersion()}-backup.sxb";
|
||||||
sfd.Filter = "ShareX backup (*.sxb)|*.sxb|All files (*.*)|*.*";
|
sfd.Filter = "ShareX backup (*.sxb)|*.sxb|All files (*.*)|*.*";
|
||||||
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
|
Loading…
Reference in a new issue