Add Windows desktop version
This commit is contained in:
14
windows/StreamPlayer.Desktop/Models/ChannelSection.cs
Normal file
14
windows/StreamPlayer.Desktop/Models/ChannelSection.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StreamPlayer.Desktop.Models;
|
||||
|
||||
public enum SectionType
|
||||
{
|
||||
Events,
|
||||
Channels
|
||||
}
|
||||
|
||||
public sealed record ChannelSection(string Title, SectionType Type, IReadOnlyList<StreamChannel> Channels)
|
||||
{
|
||||
public bool IsEvents => Type == SectionType.Events;
|
||||
}
|
||||
6
windows/StreamPlayer.Desktop/Models/DeviceStatus.cs
Normal file
6
windows/StreamPlayer.Desktop/Models/DeviceStatus.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace StreamPlayer.Desktop.Models;
|
||||
|
||||
public sealed record DeviceStatus(bool IsBlocked, string Reason, string TokenPart)
|
||||
{
|
||||
public static DeviceStatus Allowed() => new(false, string.Empty, string.Empty);
|
||||
}
|
||||
37
windows/StreamPlayer.Desktop/Models/LiveEvent.cs
Normal file
37
windows/StreamPlayer.Desktop/Models/LiveEvent.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace StreamPlayer.Desktop.Models;
|
||||
|
||||
public sealed record LiveEvent(
|
||||
string Title,
|
||||
string DisplayTime,
|
||||
string Category,
|
||||
string Status,
|
||||
string PageUrl,
|
||||
string ChannelName,
|
||||
long StartTimestamp)
|
||||
{
|
||||
public bool IsLive =>
|
||||
!string.IsNullOrWhiteSpace(Status) &&
|
||||
Status.Contains("live", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public string Subtitle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(DisplayTime) && string.IsNullOrWhiteSpace(Category))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(Category))
|
||||
{
|
||||
return DisplayTime;
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(DisplayTime))
|
||||
{
|
||||
return Category;
|
||||
}
|
||||
return $"{DisplayTime} · {Category}";
|
||||
}
|
||||
}
|
||||
}
|
||||
3
windows/StreamPlayer.Desktop/Models/StreamChannel.cs
Normal file
3
windows/StreamPlayer.Desktop/Models/StreamChannel.cs
Normal file
@@ -0,0 +1,3 @@
|
||||
namespace StreamPlayer.Desktop.Models;
|
||||
|
||||
public sealed record StreamChannel(string Name, string PageUrl);
|
||||
52
windows/StreamPlayer.Desktop/Models/UpdateInfo.cs
Normal file
52
windows/StreamPlayer.Desktop/Models/UpdateInfo.cs
Normal 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]}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user