WinForms and Avalonia now share all GridEntry view models
This commit is contained in:
parent
e1cd8b8f94
commit
fb9d062545
41 changed files with 1032 additions and 1704 deletions
41
Source/LibationUiBase/GridView/LastDownloadStatus.cs
Normal file
41
Source/LibationUiBase/GridView/LastDownloadStatus.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using DataLayer;
|
||||
using System;
|
||||
|
||||
namespace LibationUiBase.GridView
|
||||
{
|
||||
public class LastDownloadStatus : IComparable
|
||||
{
|
||||
public bool IsValid => LastDownloadedVersion is not null && LastDownloaded.HasValue;
|
||||
public Version LastDownloadedVersion { get; }
|
||||
public DateTime? LastDownloaded { get; }
|
||||
public string ToolTipText => IsValid ? $"Double click to open v{LastDownloadedVersion.ToString(3)} release notes" : "";
|
||||
|
||||
public LastDownloadStatus() { }
|
||||
public LastDownloadStatus(UserDefinedItem udi)
|
||||
{
|
||||
LastDownloadedVersion = udi.LastDownloadedVersion;
|
||||
LastDownloaded = udi.LastDownloaded;
|
||||
}
|
||||
|
||||
public void OpenReleaseUrl()
|
||||
{
|
||||
if (IsValid)
|
||||
Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{LastDownloadedVersion.ToString(3)}");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
=> IsValid ? $"{dateString()}\n\nLibation v{LastDownloadedVersion.ToString(3)}" : "";
|
||||
|
||||
//Call ToShortDateString to use current culture's date format.
|
||||
private string dateString() => $"{LastDownloaded.Value.ToShortDateString()} {LastDownloaded.Value:HH:mm}";
|
||||
|
||||
public int CompareTo(object obj)
|
||||
{
|
||||
if (obj is not LastDownloadStatus second) return -1;
|
||||
else if (IsValid && !second.IsValid) return -1;
|
||||
else if (!IsValid && second.IsValid) return 1;
|
||||
else if (!IsValid && !second.IsValid) return 0;
|
||||
else return LastDownloaded.Value.CompareTo(second.LastDownloaded.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue