Add Windows desktop version

This commit is contained in:
renato97
2025-12-17 19:20:55 +00:00
parent 93dbe0941e
commit 8921d7f2a6
36 changed files with 2760 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
using System;
using System.Globalization;
namespace StreamPlayer.Desktop.Models;
public sealed record UpdateInfo(
int VersionCode,
string VersionName,
string ReleaseNotes,
string DownloadUrl,
string DownloadFileName,
long DownloadSizeBytes,
int DownloadCount,
string ReleasePageUrl,
int MinSupportedVersionCode,
bool ForceUpdate)
{
public bool IsUpdateAvailable(int currentVersionCode) => VersionCode > currentVersionCode;
public bool IsMandatory(int currentVersionCode) =>
ForceUpdate || (MinSupportedVersionCode > 0 && currentVersionCode < MinSupportedVersionCode);
public string GetReleaseNotesPreview(int maxLength = 900)
{
if (string.IsNullOrWhiteSpace(ReleaseNotes))
{
return string.Empty;
}
if (ReleaseNotes.Length <= maxLength)
{
return ReleaseNotes.Trim();
}
return ReleaseNotes[..maxLength].TrimEnd() + Environment.NewLine + "…";
}
public string FormatSize()
{
if (DownloadSizeBytes <= 0)
{
return string.Empty;
}
string[] suffixes = { "B", "KB", "MB", "GB" };
double size = DownloadSizeBytes;
int index = 0;
while (size >= 1024 && index < suffixes.Length - 1)
{
size /= 1024;
index++;
}
return $"{size:0.##} {suffixes[index]}";
}
}