mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Use GetApplicationVersion function
This commit is contained in:
parent
0a8d613bab
commit
e91fd94d2b
5 changed files with 19 additions and 12 deletions
|
@ -277,6 +277,17 @@ public static string GetProperName(string name, bool keepCase = false)
|
|||
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>
|
||||
/// If version1 newer than version2 = 1
|
||||
/// 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 older than ApplicationVersion = -1
|
||||
/// </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)
|
||||
|
|
|
@ -32,7 +32,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.HelpersLib
|
||||
{
|
||||
|
@ -86,7 +85,7 @@ protected virtual void OnSettingsSaveFailed(Exception e)
|
|||
public bool Save(string filePath)
|
||||
{
|
||||
FilePath = filePath;
|
||||
ApplicationVersion = Application.ProductVersion;
|
||||
ApplicationVersion = Helpers.GetApplicationVersion();
|
||||
|
||||
bool result = SaveInternal(FilePath);
|
||||
|
||||
|
@ -112,7 +111,7 @@ public void SaveAsync()
|
|||
|
||||
public MemoryStream SaveToMemoryStream(bool supportDPAPIEncryption = false)
|
||||
{
|
||||
ApplicationVersion = Application.ProductVersion;
|
||||
ApplicationVersion = Helpers.GetApplicationVersion();
|
||||
|
||||
MemoryStream ms = new MemoryStream();
|
||||
SaveToStream(ms, supportDPAPIEncryption, true);
|
||||
|
|
|
@ -24,7 +24,6 @@ You should have received a copy of the GNU General Public License
|
|||
#endregion License Information (GPL v3)
|
||||
|
||||
using ShareX.HelpersLib.Properties;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
|
@ -40,8 +39,7 @@ public static string UserAgent
|
|||
{
|
||||
get
|
||||
{
|
||||
Version version = Version.Parse(Application.ProductVersion);
|
||||
return $"{Name}/{version.Major}.{version.Minor}.{version.Build}";
|
||||
return $"{Name}/{Helpers.GetApplicationVersion()}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ You should have received a copy of the GNU General Public License
|
|||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.UploadersLib
|
||||
{
|
||||
|
@ -111,7 +110,7 @@ public static CustomUploaderItem Init()
|
|||
{
|
||||
return new CustomUploaderItem()
|
||||
{
|
||||
Version = Application.ProductVersion,
|
||||
Version = Helpers.GetApplicationVersion(),
|
||||
RequestMethod = HttpMethod.POST,
|
||||
Body = CustomUploaderBody.MultipartFormData
|
||||
};
|
||||
|
@ -449,7 +448,7 @@ public void CheckBackwardCompatibility()
|
|||
DeletionURL = MigrateOldSyntax(DeletionURL);
|
||||
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())
|
||||
{
|
||||
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 (*.*)|*.*";
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
|
|
Loading…
Reference in a new issue